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". Link to comment https://forums.phpfreaks.com/topic/163374-solved-how-to-set-div-ids/ 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>'; } Link to comment https://forums.phpfreaks.com/topic/163374-solved-how-to-set-div-ids/#findComment-862011 Share on other sites More sharing options...
DBookatay Posted June 23, 2009 Author Share Posted June 23, 2009 Wow, that simple hunh? Thanks... Link to comment https://forums.phpfreaks.com/topic/163374-solved-how-to-set-div-ids/#findComment-862016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.