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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.