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
https://forums.phpfreaks.com/topic/240913-help-with-back-to-back-loops/
Share on other sites

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.