Ive got a bit of knowledge of PHP but not enough to construct a working search box for the school site.
I have created a table full of telephone numbers, names and departments. I have created a page that displays the info, all I need is a simple search to find records in a table named telephone.
There are 6 rows
ID (primary) - not really fussed about this one
int_no - Internal Number
ext_no - External Number
mob_no - Mobile Number
name -
other - location / department info
It would be amazing if I could construct some kind of ajax search, but this is not essential.
I can connect to the db and table alright, the problem comes when I start searching. I want the user to be able to search the last 5 rows (I dont want users searching the ID as this will just confuse things) and display the results in a table. This is the code for the table which displays all the info. If I could use the same one that would save so much time!
I have tried searching around to get a working search script but I'm starting to loose the will... Any help would be greatly appreciatedPHP Code:<?php
$table = 'telephone';
$query = "SELECT * FROM $table";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
echo '<table id="sortable" style="width: 100%;" align="center" border="0" cellspacing="0" cellpadding="5" >';
echo "<thead>";
echo "<tr>";
echo '<th style="text-align:center" scope="col">Internal Extension</th> <th style="text-align:center" scope="col">External Number</th> <th style="text-align:center" scope="col">Mobile Number</th> <th style="text-align:center" scope="col">Name / Department</th> <th style="text-align:center" scope="col">Other Info</th>';
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($i<$num){
$int_no=mysql_result($result,$i,"int_no");
$ext_no=mysql_result($result,$i,"ext_no");
$mob_no=mysql_result($result,$i,"mob_no");
$name=mysql_result($result,$i,"name");
$other=mysql_result($result,$i,"other");
echo "<tr>";
echo '<td style="text-align:center" width="5px">', "$int_no</td>";
echo '<td style="text-align:center" width="100px">', "$ext_no</td>";
echo '<td style="text-align:center" width="100px">', "$mob_no</td>";
echo "<td>$name</td>";
echo "<td> $other</td>";
echo "</tr>";
$i++;
};
echo "</tbody>";
echo "</table>";
?>



LinkBack URL
About LinkBacks
Reply With Quote



