<?php include("../config.php"); include("common.php"); $result = mysql_query("Select * from url",$link); $num = mysql_num_rows($result); $n = 0; ?> <?php while($row = mysql_fetch_array($result, MYSQL_BOTH)){ $n++; ?> <tr> <td> <a href="<?php echo $row['url'];?>"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row['url'];?></font></a> </td> <td> has had </td> <td> <?php echo $row['count'];?> hits</td> </tr> <?php }?> PHP: in the database there are urls and each has an id. that code displays all the urls. what i want is a search box to search for an id and just display that url.
Untested, but this should work. <?php include("../config.php"); include("common.php"); if ($_POST['id']) { $query = "SELECT * FROM url WHERE id = ". intval($_POST['id']); } else { $query = "SELECT * FROM url"; } $result = mysql_query($query); $num = mysql_num_rows($result); $n = 0; while($row = mysql_fetch_array($result, MYSQL_BOTH)) { $n++; ?> <tr> <td> <a href="<?php echo $row['url'];?>"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row['url'];?></font></a> </td> <td> has had </td> <td> <?php echo $row['count'];?> hits</td> </tr> <?php } ?> <form action="" method="post"> ID: <input type="text" name="id" /> <input type="submit" value="Search" /> </form> PHP: