Jump to content

Not sure how to Honestly


SkyRanger

Recommended Posts

$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno())
{
       printf("Connect failed: %s\n", mysqli_connect_error());
       exit();
}

$phtocat = $_GET['cid'];

$query = "SELECT  * FROM `gallery_photos` WHERE photo_category='$phtocat' and `photo_owner`='$client'";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);

//Define number of columns to use
$maxColumns  = 5;

$count = 0;              //Var to count records
$categoryList = ''; //Var to hold HTML output
while($row = $result->fetch_assoc())
{
       $count++; //Increment count

       //Open new row if first record in row
       if($count % $maxColumns == 1)
       {
               $categoryList .= "<tr>\n";
       }
$image_dir = "members/$client/photos";
$pid = $row['photo_id'];
      //Output current record
       $categoryList .= "<td align=center width=20%>
<a href={$image_dir}/{$row[photo_filename]} rel=lightbox title='{$row[photo_caption]}'><img src={$image_dir}/tb_{$row[photo_filename]} border='0' alt='{$row[photo_caption]}' /></a>
<br>
<A HREF=\"javascript:popUpPic('printimage.php?pid={$pid}&client={$client}')\"><img src=images/print.jpg></a>
<a href=\"downloadimage.php?file={$image_dir}/{$row[photo_filename]}\" onclick=\"this.blur();\"><img src=images/download.jpg></a>
<a href=removephoto.php?pid=$pid&photo_owner=$client><img src=images/delete2.jpg></a>
</td>\n";

       //Close row if last record in row
       if($count % $maxColumns == 0)
       {
               $categoryList .= "</tr>\n";
       }
}

//Close last row if needed
if($maxColumns % $count != 0)
{
       $categoryList .= "</tr>\n";
} 

?>
<table align="center" width="95%" border="0">
<?php echo $categoryList; ?>
</table>

 

Error I am getting:

Warning: Division by zero in showphoto.php on line 259

 

I am not sure how to make it say "There are no pictures in this category"

 

Could somebody please give me a hand. I have tried an else { echo "There are no......."; but with no luck I still get the error.

Link to comment
https://forums.phpfreaks.com/topic/273346-not-sure-how-to-honestly/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.