Jump to content

help with back to back loops


Recommended Posts

<?
// find witch page user is trying to acces

// if they are looking for cities
i want to do the same thing for my citities(children category but im doin this on a page but i want it to show on my indexpage///
if(isset($_REQUEST['sid'])){
$sid = $_REQUEST['sid'];
$i = 1;
$tbl_st = "<table class=\"states_table\">";
	mysql_connect("*****", "*****", "*********") or die(mysql_error());
	mysql_select_db("young17_nateads")or die (mysql_error());
		$cats = "SELECT * FROM  `citys` WHERE  sid = '$sid'  ORDER BY  `citys`.`name` ASC ";
		$sql = mysql_query($cats)or die(mysql_error());
		$row = mysql_fetch_assoc($sql)or die(mysql_error());
		do{
			if($i % 6 == 0){
		$name = $row['name'];
		$id = $row['id'];
		$rand = rand(100000000,999999999);
		$tbl_st .= "<tr class=\"states_tr1\"><td><a href=\"?explosion=find%sid=".$id."&name=".$rand."\">".$name."</a></td>";
			}else{
			$name = $row['name'];
		$id = $row['id'];
		$rand = rand(100000000,999999999);
		$tbl_st .= "<td><a href=\"?explosion=find%sid=".$id."&name=".$rand."\">".$name."</a></td>";

			}
		$i++;	
		}while ($row = mysql_fetch_assoc($sql)); 	
		$tbl_st .= "</table>";
		}
		echo $tbl_st;
}else{
// if they have not selected a state
$i = 1;
$tbl_st = "<table class=\"states_table\">";
	mysql_connect("*****", "*****", "*********") or die(mysql_error());
	mysql_select_db("young17_nateads")or die (mysql_error());
		$cats = "SELECT * FROM  `states` ORDER BY  `states`.`name` ASC ";
		$sql = mysql_query($cats)or die(mysql_error());
		$row = mysql_fetch_assoc($sql)or die(mysql_error());
		do{
			if($i % 6 == 0){
		$name = $row['name'];
		$id = $row['id'];
		$rand = rand(100000000,999999999);
		$tbl_st .= "<tr class=\"states_tr1\"><td><a href=\"?explosion=find%sid=".$id."&name=".$rand."\">".$name."</a></td>";
			}else{
			$name = $row['name'];
		$id = $row['id'];
		$rand = rand(100000000,999999999);
		$tbl_st .= "<td><a href=\"?explosion=find%sid=".$id."&name=".$rand."\">".$name."</a></td>";

			}
		$i++;	
		}while ($row = mysql_fetch_assoc($sql)); 	
		$tbl_st .= "</table>";
		}
		echo $tbl_st;
?> 

do anybody see anything wrong with my code? beacuse i cant get my citites table to echo out after a user has  hit one of the states links.....

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.