hi all, newbie again. i've passed a variable $search from a form to the following script,
<?php
// create connection
$connection = mysql_connect("server1","user1","password1") or die("Couldn't make connection.");
// select database
$db = mysql_select_db("BricompProducts", $connection);
// $search is your passed variable
$sql = "SELECT * FROM cameras WHERE Manufacturer LIKE '$search'";
$sql_result = mysql_query($sql,$connection);
$stmt = mysql_query ("SELECT * FROM cameras WHERE Manufacturer LIKE '$search'");
$limit=5;
$numrows=mysql_num_rows($stmt);
// Format however
$countresults = ("<font face=Tahoma size=2>Search Performed for $search : Found $numrows results <br>Page >> </font>");
echo "$countresults";
if (empty($offset) || $offset < 0)
{
$offset = 0;
}
$NumOfPages = intval($numrows/$limit);
if ($numrows%$limit)
{
$NumOfPages++;
}
$sql_result = mysql_query ("SELECT * FROM cameras WHERE Manufacturer LIKE '$search' LIMIT $offset,$limit");
for ($pagenumber = 1; $pagenumber <= $NumOfPages; ++$pagenumber)
{
$offset = $limit * ($pagenumber - 1);
//my problem occured here,the search
//performed ok,and display the result
//into multiple pages. but when i click
//on the page link for the second page
//it doesn't show anything and return me
//an error message saying the variable
//search wasn't defined.
//the url is
//http://evaluation.bricomp.net/search.php
//search for samsung or sanyo or ppc only.
//seems to me that the $search wasn't passed
//to the second page. can't figure it out.
//please help.
echo ("<a href=$PHP_SELF?offset=$offset>$pagenumber </a>");
}
// results
echo "<br>";
//color format for everyother row
$setcolor = 0;
while ($row = mysql_fetch_array($sql_result))
{
if($setcolor == 0)
{
$bgcolor = "#DCECFC";
$setcolor = 1;
}
else {
$bgcolor = "#FFFFFF";
$setcolor = 0;
}
$Man = $row["Manufacturer"];
$Model = $row["ModelNo"];
$HR=$row["HorResolution"];
$Description=$row["Description"];
$FullDesc=$row["FullDesc"];
// format however
echo "<tr bgcolor='$bgcolor' align=left valign=top>
<td><font face=Tahoma size=2>$Man</font></td>
</tr>";
}
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
thanks in advance.