开发者

How could I show only selected row in PHP?

I'm working at this thing that takes information from a MySQL database that comes from a contact form and displays it all to the user. Well, I got that far without issues using:

 $result = mysql_query("SELECT * FROM contact");
 while($row = mysql_fetch_array($result))
   {
  echo $row['name'] . "<br/>" . "<a href=mailto:" . $row['email']. "> " . $row['email'] . "</a>";
  echo "<br/>";
  echo $row['message'];
  echo "<br />";
  }

Now I would like to add a button next to each item that would single them out, basically taking开发者_如何学Python me to a page where only the selected row shows up, not all of them, as happens on this page.

The thing is that i don't know how to do that. So, does anyone have any ideas?

Thanks!


Add a button that refreshes the page with a "GET" parameter, such as yourpage.php?uid=123; Then do

if ($_GET['uid'] !== null) {
    $id = (int) $_GET['uid'];
    $result = mysql_query('SELECT * FROM contact WHERE id='.$id);
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜