DBookatay Posted June 23, 2009 Share Posted June 23, 2009 Hopefully someone can help with a simple problem: The PHP if(!$_GET['page']) {$_GET['page'] =1;} $num = '35'; $offset = ($_GET['page']-1) * $num; $query = "SELECT count(*) as thecount from photos"; $result = mysql_query($query); $row = mysql_fetch_array($result); $total = $row[thecount]; $pages = ceil($total/$num); $query = "SELECT * FROM photos WHERE category = '{$_GET['Gallery']}' and status = 'on' ORDER BY id limit $offset,$num"; $result = mysql_query($query); $numrows = mysql_num_rows($result); for($x = 0; $row = mysql_fetch_array($result); $x++) { $id = $row['id']; $body .= '<div id="img01" class="pic"><a href="Gallery/'.$id.'.jpg" rel="lightbox[Gallery]" title="" onmouseover="MM_swapImage(\'thmb'.$id.'\',\'\',\'Gallery/thumbs/on/'.$id.'.jpg\',1)" onmouseout="MM_swapImgRestore()"><img src="Gallery/thumbs/off/'.$id.'.jpg" id="thmb'.$id.'" alt="" /></a><p>'.$id.'A</p></div>'; } Every thing is working correctly, the query and images are showing up but I need to change the image id for each result, since the CSS determines where on the page the image should line up. Right now since their all named "img01" they are all laying on top of one another. How do I make it so that each as the next sequential number: "img01", "img02", "img03", ... "img33", "img34", "img35". Quote Link to comment Share on other sites More sharing options...
flyhoney Posted June 23, 2009 Share Posted June 23, 2009 <?php if(!$_GET['page']) {$_GET['page'] =1;} $num = '35'; $offset = ($_GET['page']-1) * $num; $query = "SELECT count(*) as thecount from photos"; $result = mysql_query($query); $row = mysql_fetch_array($result); $total = $row[thecount]; $pages = ceil($total/$num); $query = "SELECT * FROM photos WHERE category = '{$_GET['Gallery']}' and status = 'on' ORDER BY id limit $offset,$num"; $result = mysql_query($query); $numrows = mysql_num_rows($result); for($x = 0; $row = mysql_fetch_array($result); $x++) { $id = $row['id']; $body .= '<div id="img'.$x.'" class="pic"><a href="Gallery/'.$id.'.jpg" rel="lightbox[Gallery]" title="" onmouseover="MM_swapImage(\'thmb'.$id.'\',\'\',\'Gallery/thumbs/on/'.$id.'.jpg\',1)" onmouseout="MM_swapImgRestore()"><img src="Gallery/thumbs/off/'.$id.'.jpg" id="thmb'.$id.'" alt="" /></a><p>'.$id.'A</p></div>'; } Quote Link to comment Share on other sites More sharing options...
DBookatay Posted June 23, 2009 Author Share Posted June 23, 2009 Wow, that simple hunh? Thanks... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.