Jump to content

[SOLVED] How to set DIV id's


DBookatay

Recommended Posts

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

<?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>';
      }

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.