开发者

How to hyperlink the fetched data?

I am new to php,开发者_开发百科 mysql. currently i'm building a website. with the search query the data is displayed well. (in this case the search query is 'name %like%'). now i want to open another page that will display the profile of any one of the name displayed (when clicked) in the previous query. how to acheive this?


you'll have to select, for example, user_id when searching.

and then, your code could look like

<?php
include("db.php");
$result = mysql_query("SELECT user_id, username FROM user WHERE username LIKE '%".mysql_real_escape_string($_POST['username'])."%'");
echo "<table>";
while($row = mysql_fetch_assoc($result)
{
    echo '<tr><td><a href="profile.php?uid='.$row['user_id'].'">'.$row['username'].'</a></td></tr>';

}
echo "</Table>";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜