1

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!

4

1 回答 1

3

注意不要使用函数mysql_*。它们在 PHP 5.5 中已被弃用,并且可能会从 PHP 的未来版本中删除。相反,请考虑PHP 中可用的替代 MySQL 数据库接口,如PDOMySQLi,它们功能更丰富维护良好

你需要echo输出所有你想要的 HTML。

$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>";
}

我建议阅读 PHP 和 HTML 基础知识

于 2013-02-13T21:23:51.703 回答