output more than one results on a page?

wxdqz

New Member
Hi!

I am a fairly new to PHP, and I wanted to know how I would go about displaying the results of a wild card query?

Here what I got: (see //Display Data at the bottom). Also, how can I combine the follwing to one file?

-----Begin Search.php3-----
<FORM ACTION="./Search_Descr.php3" METHOD="GET">
<INPUT TYPE="text" NAME="descr" SIZE="25" MAXLENGTH="115" VALUE=http://www.phpbuilder.com/board/archive/index.php/"Enter
Description">
<INPUT TYPE="submit" VALUE="Submit">
<INPUT TYPE="reset" VALUE="Rest">
</FORM>
-----End Search.php3-----


-----Begin Search_Descr.php3-----
<?
$server = "localhost";
$userid = "root";
$pass = "";
$database = "XYZ";
$dbtable = "products";
$limit = 20;

$con = mysql_connect("$server","$userid","$pass") or die ("Huh? What
Server");
$db = mysql_select_db("$database",$con) or die("I said WHAT database");

if (empty($offset) || $offset< 0) {
$offset=0;
}
if (empty($index)) $index=0;

$getrows = mysql_query("SELECT COUNT(*) from products", $con);
$numrows=mysql_result($getrows,0);

$query = mysql_query("SELECT descr, cost, manu_part, part_num from
products where descr LIKE'%memory%' limit $offset,$limit", $con);

list($descr, $cost, $manu_part, $part_num) = mysql_fetch_row($query);

while ($result=mysql_fetch_array($query)){

$index++;
}

if ($numrows <= $limit) {
}
else {

if ($offset!=0) {
$prevoffset=$offset-$limit;
echo "<a onMouseOver=\"window.status='Previous $limit Results'; return
true\";
href=\"$PHP_SELF?offset=$prevoffset&index=$prevoffset\">[Previous]</a>
";
}

else echo "[Previous] ";
$pages = intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}

for ($i=1;$i<=$pages;$i++) {
if (($offset/$limit) == ($i-1)) {
echo " $i ";
} else {
$newoffset=$limit*($i-1);
echo " <a onMouseOver=\"window.status='Page $i Results'; return true\";
href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\">$i</a> \n";
}

}

if (!((($offset/$limit)+1)==$pages) && $pages!=1) {
$newoffset=$offset+$limit;
echo " <a onMouseOver=\"window.status='Next $limit Results'; return
true\";
href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\">[Next]</a><p>\n";

}
else echo " [Next]";
}

//Add Percentage & Round
function add_percent ($price, $percent) {
$newprice = $price * (1 + ($percent/100));
return number_format($newprice,2);
}

//Display Data
print ("\n Manufactuer Part Number: $manu_part <P>");
print ("\n Our Part Number: $part_num <P>");
print ("\n Description: $descr <P>");
print ("\n Our Price: $".add_percent($cost, 15));
print ("<P>");

mysql_close($con);
?>
-----End Search_Descr.php3-----


Thanks In Advance!!
 
Back
Top