I have two different things I want to have happen in one page of code. I have one that opens a mysql database and pulls tshirt images and names based off the category chosen and is paginated. Everything works fine. I have another one that resizes the image to a specified size. Everything works fine. I am having a problem making all these things work at once. Can someone show me how to combine these?
Images & Pagination Code
<?
$server = "xxx";
$userid = "xxx";
$pass = "xxx";
$database = "xxx";
$limit = 50;
$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 tshirts", $con);
$numrows=mysql_num_rows($getrows);
$query = mysql_query("SELECT * from tshirts, category where (category.category = '$CatList') and (tshirts.catID = category.catID) limit $offset,$limit", $con);
echo "<table align=center width=500 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 id=links>
<a href='/displaytshirts.html?id=$result[id]'><img border=1 height=200 width=150 alt='$result[shirtname]' src=/Images/TShirts/$result[image]></a><br>$result[shirtname]
</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>[Previous]</B></a> ";
}
else echo "<b>[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>";
}
mysql_close($con);
?>
Image Resize Code
<?php
$count = 1; / this starts counting the images until there's none left /
$dirstring = "TShirts/"; / I"m not sure what this does/
$mydir = dir('/xxx); /this directs it to where the image files are/
/ sets up the table for display /
echo "<table border='0' cellpadding='0' cellspacing='20' style='border-collapse: collapse; bordercolor=#111111; width=100%;'>";
while(($file = $mydir->read()) !== false) {
if ($file !== "." && $file !== "..") {
if ($count == 1) {
$fstring = substr("$file", 0, -4);
$display = "$dirstring" . "$file";
echo "<table border='0' cellpadding='0' cellspacing='20px' style='border-collapse: collapse; bordercolor=#111111; width=100%;'><tr><td width='33%' align='center'><IMG src=" . "$display width=178 height=174><BR>" . $fstring . "</TD>";
$count++;
}
elseif ($count == 2) {
$fstring = substr("$file", 0, -4);
$display = "$dirstring" . "$file";
echo "<td width=33% align=center><IMG src=" . "$display width='178px' height='174px'><BR>" . $fstring . "</TD>";
$count++;
}
elseif ($count == 3) {
$fstring = substr("$file", 0, -4);
$display = "$dirstring" . "$file";
echo "<td width=33% align=center><IMG src=" . "$display width=178 height=174><BR>" . $fstring . "</TD></tr>";
$count = 1;
}
}
}
echo "</table>";
$mydir->close();
?>