Hey, wondered if someone could help me with how to go about doing the following:
I have some code which generates bits of text randomly from a database. But I was wondering if there's a way for a user to download an individual file, which corresponds to the one they're viewing.
So say this is my code:
<?php
if($_GET['act'] == "generate_quotes") {
$con = mysql_connect("*", "*", "*");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("quote", $con);
$result = mysql_query( " SELECT * FROM `quote` ORDER BY RAND() LIMIT 0,1 " );
while($row = mysql_fetch_array($result))
{
echo '<span class="pink">' . $row['q_quote'] . "</span>";
}
echo "</table>";
mysql_close($con);
} else {
echo "<img src=\"vpbgt.png\">";
}
?>
And an example of things in the bd are:
test 1 [id = 1]
test 2 [id = 2]
test 3 [id = 3]
If the user clicks the link to generate a piece of text, they can download what's being shown. So if they saw 'test 1' they could click a download link and download 'test1.txt'. But if they were to hit generate again it'd maybe show 'test3' so they'd click the link to download and it'd download 'test3.txt' etc... I'm sure you know the kind of thing I'm after.
I've assigned id's to each field in the bd, which I'm sure I'll need, but can someone elaborate on where to go from here? or some examples / tutorials would be great.
Thanks for any advice