登录 | 注册 | FAQ
Anonymous

PHP lesson 20- retrieving data

+ 发表回复

3 篇帖子 分页: 1 / 1


PHP lesson 20- retrieving data

Black_jack » 周六 3月 07, 2015 5:18 pm

I was going through your lesson and managed to get most of it to work and even add a tweaks of my own to it. But for some reason the link isn't showing up. Ideally I would like each name in the table to appear as a link to a detailed stat page, similar to the lesson example. I am not sure if I am missing something in the code which is very possible since I am very new at this.
**Note** I did leave out the connection code for security reasons mainly.**

Code:

// SQL query
$strSQL = "SELECT * FROM JockeyClub ORDER BY horseID ASC";


// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);

echo "<table>"; //start a table tag in the HTML

echo
"<table border=\"1\"><tr>";


// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {

// Name of the person
echo "<tr><td>" . $row['horseID'] . "</td><td>" . $row['horsename'] . "</td><td>" . $row['Owner']. "</td></tr>";

}


echo "</table>"; //Close the table in HTML


// Create a link to person.php with the id-value in the URL
$strLink = "<a href = 'person.php?id = " . $row['horsename'] . "'>" . $strNavn . "</a>";

// List link
echo "<li>" . $strLink . "</li>";



// Close the database connection
mysql_close();
?>

</ul>
</body>
头像

Black_jack

  • 帖子: 3
  • 注册: 周六 3月 07, 2015 4:48 pm

Re: PHP lesson 20- retrieving data

nanoverso » 周日 3月 08, 2015 11:37 pm

If you wanna a link to each table record you should put the link generation echo inside the recordset loop.
头像

nanoverso

  • 帖子: 253
  • 注册: 周六 5月 10, 2014 12:08 am
  • 地址: Brazil
--
Free VST Plugins Download.

Re: PHP lesson 20- retrieving data

Black_jack » 周一 3月 09, 2015 11:47 am

nanoverso 写道:If you wanna a link to each table record you should put the link generation echo inside the recordset loop.


can you send a example of what the code should look like please, I am getting some really odd results when I try it. Mainly I get a series of bullets before the table and still no links showing up.
头像

Black_jack

  • 帖子: 3
  • 注册: 周六 3月 07, 2015 4:48 pm


+ 发表回复

分页: 1 / 1