You are here: Re: downloadable files « All PHP « IT news, forums, messages
Re: downloadable files

Posted by Mushroom_bobble on 10/13/73 11:30

ok, finally I figure out how to do this!

First, it is relatively simple
Second, its highly useful.

1. within main .php file
Code:
echo "<center>
<a href=#
onClick=\""."window.open('name_of_link_page.php?id=".$row['ID']."','data
window','height=10,width=10');\"".">Area</a>\n
</center>";
>>>> id=".$row['ID'] >>>> ID is something I queried for. I put it in the form $row[] because this is how I set to find the data >>>>> $row = mysqli_fetch_array($result) >>>> $result is = to my query...its an array of id values.

2. within link page
Code:
<?php
$id = $_GET["id"]; //notice how i set $id to $_get['id'] (which is from
the main document)
$db = mysqli_connect("localhost", ....etc....I need to connect
again...though u can probably carry it over like i did with 'id');
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit(); }

if($result = mysqli_query($db, "SELECT tree FROM youho WHERE
ID='$id'")){
$row = mysqli_fetch_array($result);
header('Content-type: plain/text');
header('Content-Disposition: attachment; filename="data.txt"');
echo $row["tree"];
echo "$id\n";
}
else {echo "query failed\n";}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация