Hello,
I got these codes recently from this site. It performs a seach on a database.
Could someone explain some line of codes, please.
They are followed with the "//??" comment
thanks
// Search
<?php
if ($search) // perform search only if a string was entered.
{
mysql_connect() or die ("Problem connecting to seachsample");
// connect to mysql
$srch="%".$search."%";
// ?? What does this means
$query = "select * from seachsample WHERE IDno LIKE '$srch' || Name LIKE '$srch' || Link LIKE '$srch' || Category LIKE '$srch' || address LIKE '$srch' || section LIKE '$srch'|| keywords LIKE '$srch'|| phone LIKE '$srch'|| email LIKE '$srch'";
$result = mysql_db_query("test_database", $query);
// ?? what does this do ?
if ($result)
{
echo "Here are the results:<br>
<table width=100% align=center border=0>
<tr>
<td align='left' bgcolor='White' valign='middle'><h4>Business Details</h1></td>
<td align='right' bgcolor='White' valign='middle'><h4>Category</h1></td>
</tr>
</table>";
while ($r = mysql_fetch_array($result)) { // Begin while
// ?? what does this means
$idno = $r["IDno"];
// ??what does $r["IDno"] means??
$name = $r["Name"];
$link = $r["Link"];
$category = $r["Category"];
$address = $r["address"];
$phone = $r["phone"];
$email = $r["email"];
$section = $r["section"];
$keywords = $r["keywords"];
echo "<table width=100% align=center border=0>
<tr>
<td align=left>$name</td>
<td rowspan='6' valign='top' align='right'>$category</td>
</tr>
<tr><td align=left>$address</td>
</tr>
<tr>
<td align=left>$phone</td>
</tr>
<tr>
<td align=left>$email</td>
</tr>
<tr>
<td align=left>$link</td>
</tr>
<tr>
<td align=left>Business ID Number: $idno</td>
</tr>
<tr><td colspan='2'><hr color='white'></td>
</tr>";
} // end while
echo "</table>";
} else { echo "problems...."; }
} else {
echo "Search box was empty. <br> Go back and try again.";
}
?>
//And the coding on the form to search is:
<form method="post" action="../admin/srch.php">
<input type=text name='search' size=15 maxlength=255><br><br>
<input type=submit value="Search..">
</form>