Reputation: 51
I have created a webpage using html/php which contains a form to collect informtaion which I am storing in a mysql database, each record in the database has the date stored automatically, I want to be able to retrieve this information from the database and display is on the webpage as a list of the dates and then I want to make each date a hyperlink so that when click it will show all the data stored in that form on that specific date.
so far I have been able to retrieve the list of the dates using the following (this works as i need it to) :
$query="SELECT Date FROM form";
$result=mysql_query($Query,$db);
while ($dbRow=mysql_fetch_array($Result))
{
$theDate=$dbRow["Date"];
echo "$theDate<br>";
}
I can not figure out at all how to make each of these dates into a hyperlink... any advice anyone?? thanks!
Upvotes: 1
Views: 2924
Reputation: 1971
NOTICE do NOT use mysql_*
functions. They have been deprecated in PHP 5.5 and may be removed from future versions of PHP. Instead, consider the alternative MySQL database interfaces available in PHP like PDO or MySQLi, which are more feature-rich and well-maintained.
You need to echo
out all the HTML you want.
$query = "SELECT Date FROM form";
$result = mysql_query($Query,$db);
while ($dbRow = mysql_fetch_array($Result))
{
$theDate = $dbRow["Date"];
echo "<a href='showDateInfo.php?date=$theDate'>$theDate</a><br>";
}
I suggest reading up on PHP and HTML basics
Upvotes: 3