Gossamer Forum
Home : General : Perl Programming :

Php help, Please

Quote Reply
Php help, Please
Hi,
I have gotten into php a lot and have written a simple gallery script. I neeed the results to be split into different pages.

Code:
<?require "/home/fanaticn/www/php/header.php";
?>
<?
$username="xxxx_xxxxxx";
$password="xxxxxxxx";
$database="xxx_xxxxxxxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contacts WHERE 1 ORDER BY title DESC";
$querypic="SELECT * FROM pictures WHERE id='$id'";
$result=mysql_query($query);
$resultpic=mysql_query($querypic);
$num=mysql_numrows($result);
mysql_close();
?>
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tr>
<td bgcolor="000000">
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tr>
<td bgcolor="FFFFFF" width="70%" valign="100%">
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<?
$z=0;
$idpic=mysql_result($resultpic,$z,"id");
$catnamepic=mysql_result($resultpic,$z,"catname");
$picspic=mysql_result($resultpic,$z,"pics");
$picurl=mysql_result($resultpic,$z,"picurl");





if ($x < 10){



while ($x < $picspic) {
echo"<tr> ";
for($i=0; $i<4; $i++){ //loops thru until 3 TD are made
if ($x < $picspic) {
echo"<td bgcolor=\"FFFFFF\"> ";
echo "<a href=\"$picurl/$x.jpg\"><img src=\"$picurl/thumb/$x.jpg\"></a><br>";
} else {
echo "";
}
$x++;
echo "</td>";
}
echo"</tr>";
$x++; // once done with cells, close TR and start over with new TR




}

}else{ // if $times is greater than 10

while ($x < $picspic) {
echo"<tr>";
for($i=0; $i<4; $i++){
echo"<td bgcolor=\"FFFFFF\"> ";
if ($x < $picspic) {
echo "<a href=\"$picurl/$x.jpg\">";
echo "<img src=\"$picurl/thumb/$x.jpg\" border=\"0\"></a><br>";
$x++;
echo "</td>";
} else {
echo "";
}




}
echo"</tr>";
$x++;




}

}
?>
</table>
</td>
<td width="30%" bgcolor="#ffffff" valign="top">
<table width="100%">
<tr>
<td width="100%" bgcolor="#ffffff" valign="top">





<tr>
<font face="verdana" size="2"><b>Links (<? echo "$num"; ?>)
</b></font>
</tr>
<tr>
<?





$i=0;
while ($i < $num) {




$url=mysql_result($result,$i,"url");
$title=mysql_result($result,$i,"title");
$description=mysql_result($result,$i,"description");




echo "<b><font face=\"verdana\" size=\"1\"><a href=\"$url\">$title</a><br>$description</font></b><br>";

++$i;
}




?>
<tr>
<a href="
http://www.fanaticnetwork.com/php/open.htm"><font face="verdana" size="2">Add A Site</a></font>
</tr>
</tr>
</td>
</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>


In there you will see a varible $picspic . This varible is a field that says how many pics are in the category. This then loops the information like this:

1.jpg
2.jpg
3.jpg
etc...

Now if I could only split these into pages with about 15 results a page. A demo can be found here.
Thank You,
Paul
Webmaster Discussions