I have a script that pulls images and info out of a database. I want it to list the images based on its card pack name (cpname). I then want to create another row once all the images are loaded. Basically I want each category to be in its own row on a web page.
Please help.
<br><br>
<?
$server = "**";
$userid = "";
$pass = "";
$database = "**";
$limit = 6;
$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 * from greetingcards", $con);
$numrows=mysql_num_rows($getrows);
$query = mysql_query("SELECT * FROM greetingcards, cardpacks where (greetingcards.packid = cardpacks.packid) order by cardpacks.cpname limit $offset,$limit", $con);
echo "<table align=center width=100% border=0><tr>";
$num=1;
while ($result=mysql_fetch_array($query)){
$num = ($num < 4 ? $num : 1);
$index++; / Increment the line index by 1 /
echo "<td align=center valign=top class=title>
<? include('includes/main.php');?><br><b>$result[gcname]</b><br>
<a href='displaygreetingcards.php?cpname=$result[cpname]'><img border=0 height=156 width=116 alt='$result[gcname]' src=/images/greetingcards/$result[filename]></a><br>$$result[price]<br>$result[cardcategory]</td>";
if ($num==3 && $index!=$numrows)
echo '</tr><tr>';
$num++;
}
echo ("</tr></table>");
if ($numrows <= $limit) {
}
else {
if ($offset!=0) {
$prevoffset=$offset-$limit;
echo "<br><a onMouseOver=\"window.status='Previous $limit Results'; return true\"; href=\"$PHP_SELF?offset=$prevoffset&index=$prevoffset\"><B><b><br><br><p align='center'>[Previous]</B></a> ";
}
else echo "<b><br><br><p align='center'>[Previous]</b> ";
$pages = intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
for ($i=1;$i<=$pages;$i++) {
if (($offset/$limit) == ($i-1)) {
echo " <b>$i</b> ";
} else {
$newoffset=$limit*($i-1);
echo " <a onMouseOver=\"window.status='Page $i Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>$i</B></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\"><B>[Next]</B></a><p>\n";
} else echo " <b>[Next]</b></p>";
}
mysql_close($con);
?>