YoungNate_Black_coder Posted July 2, 2011 Share Posted July 2, 2011 <? // 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..... Quote Link to comment https://forums.phpfreaks.com/topic/240913-help-with-back-to-back-loops/ Share on other sites More sharing options...
QuickOldCar Posted July 2, 2011 Share Posted July 2, 2011 You need to use AJAX or jQuery to get the results fetched dynamic upon input without page reload. http://www.w3schools.com/ajax/ajax_intro.asp http://rickyrosario.com/blog/sorting-dropdown-select-options-using-jquery/ Quote Link to comment https://forums.phpfreaks.com/topic/240913-help-with-back-to-back-loops/#findComment-1237503 Share on other sites More sharing options...
QuickOldCar Posted July 2, 2011 Share Posted July 2, 2011 I'm sorry, I didn't fully read the code. $sid = $_REQUEST['sid']; if(isset($_REQUEST['sid']) && $sid != ""){ echo "first code"; } else { echo "second code"; } can also use empty() Quote Link to comment https://forums.phpfreaks.com/topic/240913-help-with-back-to-back-loops/#findComment-1237506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.