Heres a stripped down version of what I came up with and some added options.. and functions... Hope it helps.. It taught me alot
If anyone knows a more efficient way, please tell me
<?php
// create connection
$connection = mysql_connect(\"localhost\",\"user\",\"pass\")
or die(\"Couldn\'t make connection.\");
// select database
$db = mysql_select_db(\"your_db\", $connection)
or die(\"Couldn\'t select database.\");
// $search is your passed variable
$sql = \"SELECT * FROM table_name WHERE field_name LIKE \'%$search%\'\";
$sql_result = mysql_query($sql,$connection)
or die(\"Couldn\'t execute query.\");
$stmt = mysql_query (\"SELECT * FROM table_name WHERE field_name LIKE \'%$search%\'\");
$limit=5;
$numrows=mysql_num_rows($stmt);
// Format however
$countresults = (\"Current Search:</b> $search  <b>Number of Results:</b> $numrows. <br><br>Page Results>>  </font>\");
echo \"$countresults\";
if (empty($offset) || $offset < 0)
{
$offset = 0;
}
$NumOfPages = intval($numrows/$limit);
if ($numrows%$limit)
{
$NumOfPages++;
}
$sql_result = mysql_query (\"SELECT * FROM table_name WHERE field_name LIKE \'%$search%\' LIMIT $offset,$limit\");
for ($pagenumber = 1; $pagenumber <= $NumOfPages; ++$pagenumber)
{
$offset = $limit * ($pagenumber - 1);
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 = \"#ffffff\";
$setcolor = 1;
} else {
$bgcolor = \"#006699\";
$setcolor = 0;
}
$fields = $row[\"fields\"];
$lalalla = $row[\"lallala\"];
//option if pic1 = 0 then replace with default pic
if ($row[\"pic1\"] == \"\")
{
$thumbnail = \"default.jpg\";
}
// format however
echo \"$results
\";
}
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>