TeamCIT Posted February 3, 2010 Share Posted February 3, 2010 Hey guys, I'm having trouble getting my MySQL queries to work. What I am trying to do is update the value of a column in my database with a counter, depending on which item is selected from a drop-down list in my form. Each item is selected with a Submit button. If you need me to go into further detail about anything feel free to ask, I'd be more than happy to elaborate. Here is my code: if($_POST['submitted'] == true) { $Col_result = mysql_query("SELECT selected,FROM destinations"); $column_array = mysql_fetch_array($Col_result); $High_column_rank = 0; for($i = 0; $i<14;$i++) { $column_current_rank = $column_array[$i]; if ($column_current_rank > $High_column_rank) {$High_column_rank = $column_current_rank;} } mysql_query("update destinations set in_order= $High_column_rank where id= $destChose"); mysql_close($link); mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error connecting to mysql"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } }else{ mysql_query("update destinations set in_order= $High_column_rank where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } echo "<br />"; echo "<br />"; echo "Please select a destination."; } if($_POST['reset'] == true) { mysql_query("update destinations set selected=0 where selected='1'"); } if($_POST['linkgen'] == true) { $result = mysql_query("SELECT dest_addr FROM destinations WHERE selected = '1'"); $counter = mysql_num_rows($result); echo "<a href=\""; while ($row = mysql_fetch_array($result)) { $address[] = $row["dest_addr"]; } switch($counter) { case 1: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; break; case 2: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; break; case 3: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; break; case "4": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; break; case "5": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; break; case "6": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; break; case "7": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; break; case "8": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; break; case "9": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; break; case "10": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; break; case "11": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; break; case "12": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; break; case "13": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; break; case "14": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; echo "+to:"; echo $address[13]; break; default: break; } echo "&pw=2"; echo "\">" . "Directions" . "</a>"; } ?> <html> <head> <title>Create a Tour</title> </head> <body> <br /> <br /> <form name="tourCreation" action="createTour_inorderRedone.php" method="post"> Please complete this form to create your tour: <br /> <br /> Destinations:<br /> <select name="destList" size="10"> <option value="1">National Gallery of Art</option> <option value="2">National Archives & Records Administration</option> <option value="3">National Law Enforcement Officers Memorial</option> <option value="4">Kenilworth Aquatic Gardens</option> <option value="5">White House Park</option> <option value="6">Washington Photo Safari</option> <option value="7">Federal Bureau of Investigation</option> <option value="8">Franciscan Monastery - Commissariat of the Holy Land in America</option> <option value="9">National Portrait Gallery Special Events Department</option> <option value="10">Rock Creek Park</option> <option value="11">Anacostia Community Museum</option> <option value="12">National Shrine of the Immaculate Conception </option> <option value="13">U.S. National Arboretum</option> <option value="14">Union Station</option> <option value="23">Tommy J</option> </select> <br /> <br /> <br /> <input type="submit" name="submitted" value="Select Destination" /> <input type="submit" name="reset" value="Reset" /> <input type="submit" name="linkgen" value="Get Link" /> </form> <br /> <br /> </body> </html> Whenever I click the Submit button to select an item, it gives me these warning errors: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\www\...\createTour_inorderRedone.php on line 16 $column_array = mysql_fetch_array($Col_result); Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\www\...\createTour_inorderRedone.php on line 36 while ($row = mysql_fetch_array($result)) { Any input or advice would be greatly appreciated, thanks in advance! Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/ Share on other sites More sharing options...
aeroswat Posted February 3, 2010 Share Posted February 3, 2010 This $Col_result = mysql_query("SELECT selected,FROM destinations"); should be this $Col_result = mysql_query("SELECT selected FROM destinations"); Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006248 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 should be this $Col_result = mysql_query("SELECT selected FROM destinations"); Thanks, I fixed that. I changed a few other things in my code as well and am no longer getting errors or warnings, however my database is not being updated still, any ideas? (I starred the lines in my code that I changed): if($_POST['submitted'] == true) { $Col_result = mysql_query("SELECT in_order FROM destinations"); ** $column_array = mysql_fetch_array($Col_result); $High_column_rank = 0; for($i = 0; $i<14;$i++) { $column_current_rank = $column_array[$i]; $High_column_rank++; ** if ($column_current_rank > $High_column_rank) {$High_column_rank = $column_current_rank;} } mysql_query("update destinations set in_order= $High_column_rank where id= $destChose"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } }else{ mysql_query("update destinations set in_order= $High_column_rank where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } echo "<br />"; echo "<br />"; echo "Please select a destination."; } if($_POST['reset'] == true) { mysql_query("update destinations set selected=0 where selected='1'"); } if($_POST['linkgen'] == true) { $result = mysql_query("SELECT dest_addr FROM destinations WHERE selected = '1'"); $counter = mysql_num_rows($result); echo "<a href=\""; while ($row = mysql_fetch_array($result)) { $address[] = $row["dest_addr"]; } switch($counter) { case 1: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; break; case 2: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; break; case 3: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; break; case "4": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; break; case "5": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; break; case "6": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; break; case "7": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; break; case "8": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; break; case "9": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; break; case "10": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; break; case "11": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; break; case "12": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; break; case "13": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; break; case "14": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; echo "+to:"; echo $address[13]; break; default: break; } echo "&pw=2"; echo "\">" . "Directions" . "</a>"; } ?> <html> <head> <title>Create a Tour</title> </head> <body> <br /> <br /> <form name="tourCreation" action="createTour_inorderRedone.php" method="post"> Please complete this form to create your tour: <br /> <br /> Destinations:<br /> <select name="destList" size="10"> <option value="1">National Gallery of Art</option> <option value="2">National Archives & Records Administration</option> <option value="3">National Law Enforcement Officers Memorial</option> <option value="4">Kenilworth Aquatic Gardens</option> <option value="5">White House Park</option> <option value="6">Washington Photo Safari</option> <option value="7">Federal Bureau of Investigation</option> <option value="8">Franciscan Monastery - Commissariat of the Holy Land in America</option> <option value="9">National Portrait Gallery Special Events Department</option> <option value="10">Rock Creek Park</option> <option value="11">Anacostia Community Museum</option> <option value="12">National Shrine of the Immaculate Conception </option> <option value="13">U.S. National Arboretum</option> <option value="14">Union Station</option> <option value="23">Tommy J</option> </select> <br /> <br /> <br /> <input type="submit" name="submitted" value="Select Destination" /> <input type="submit" name="reset" value="Reset" /> <input type="submit" name="linkgen" value="Get Link" /> </form> Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006251 Share on other sites More sharing options...
aeroswat Posted February 3, 2010 Share Posted February 3, 2010 $High_column_rank++; ++ those extra pluses shouldn't be there also have you checked to see if it's the logic that's giving you a problem? Is High_column_rank > the current column rank? also if this is from a submit button the ==true is redundant if($_POST['submitted'] == true) Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006254 Share on other sites More sharing options...
gwolgamott Posted February 3, 2010 Share Posted February 3, 2010 $High_column_rank++; ++ those extra pluses shouldn't be there That line should be outside the loop not in it(run it imediatly after for loop is done before u update it), but still needs to be incremented since at the end of the loop it is equal to highest number so when updating you want it to be one higher then highest number. Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006255 Share on other sites More sharing options...
aeroswat Posted February 3, 2010 Share Posted February 3, 2010 Where is $destChose defined? Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006258 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 $High_column_rank++; ++ those extra pluses shouldn't be there also have you checked to see if it's the logic that's giving you a problem? Is High_column_rank > the current column rank? Yeah my bad on the pluses I meant to put *'s there to show I changed the line. And I think you're right about it being a logic problem, however I am unsure how to fix this. Most of this is code someone helped me create, my original code is here: if($_POST['submitted'] == true) { $destChose = $_POST['destList']; if($destChose >= 1) { mysql_query("update destinations set selected=1 where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE selected = '1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } }else{ mysql_query("update destinations set selected=1 where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE selected = '1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } echo "<br />"; echo "<br />"; echo "Please select a destination."; } } if($_POST['reset'] == true) { mysql_query("update destinations set selected=0 where selected='1'"); } if($_POST['linkgen'] == true) { $result = mysql_query("SELECT dest_addr FROM destinations WHERE selected = '1'"); $counter = mysql_num_rows($result); echo "<a href=\""; while ($row = mysql_fetch_array($result)) { $address[] = $row["dest_addr"]; } switch($counter) { case 1: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; break; case 2: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; break; case 3: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; break; case "4": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; break; case "5": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; break; case "6": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; break; case "7": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; break; case "8": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; break; case "9": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; break; case "10": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; break; case "11": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; break; case "12": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; break; case "13": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; break; case "14": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; echo "+to:"; echo $address[13]; break; default: break; } echo "&pw=2"; echo "\">" . "Directions" . "</a>"; } ?> <html> <head> <title>Create a Tour</title> </head> <body> <br /> <br /> <form name="tourCreation" action="createTour_workingfinal.php" method="post"> Please complete this form to create your tour: <br /> <br /> Destinations:<br /> <select name="destList" size="10"> <option value="1">National Gallery of Art</option> <option value="2">National Archives & Records Administration</option> <option value="3">National Law Enforcement Officers Memorial</option> <option value="4">Kenilworth Aquatic Gardens</option> <option value="5">White House Park</option> <option value="6">Washington Photo Safari</option> <option value="7">Federal Bureau of Investigation</option> <option value="8">Franciscan Monastery - Commissariat of the Holy Land in America</option> <option value="9">National Portrait Gallery Special Events Department</option> <option value="10">Rock Creek Park</option> <option value="11">Anacostia Community Museum</option> <option value="12">National Shrine of the Immaculate Conception </option> <option value="13">U.S. National Arboretum</option> <option value="14">Union Station</option> </select> <br /> <br /> <br /> <input type="submit" name="submitted" value="Select Destination" /> <input type="submit" name="reset" value="Reset" /> <input type="submit" name="linkgen" value="Get Link" /> </form> <br /> <br /> </body> </html> The problem with this code is that I can't get the items chosen from my drop-down list to display in the order they were selected, so I was mixing my code with my helper's to try to update the "in_order" column in the database for each item selected. This "in_order" column is supposed to be updated with a counter however I am having trouble getting the code to work, and I don't understand a lot of the new code that was added. Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006259 Share on other sites More sharing options...
aeroswat Posted February 3, 2010 Share Posted February 3, 2010 Where is $destChose defined? This... it looks like you removed it in your new code because you have it in your old code Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006261 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 That line should be outside the loop not in it(run it imediatly after for loop is done before u update it), but still needs to be incremented since at the end of the loop it is equal to highest number so when updating you want it to be one higher then highest number. Thanks, I moved it, does this look better? if($_POST['submitted'] == true) { $Col_result = mysql_query("SELECT in_order FROM destinations"); $column_array = mysql_fetch_array($Col_result); $High_column_rank = 0; for($i = 0; $i<14;$i++) { $column_current_rank = $column_array[$i]; if ($column_current_rank > $High_column_rank) {$High_column_rank = $column_current_rank;} } $High_column_rank++; ** mysql_query("update destinations set in_order= $High_column_rank where id= $destChose"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } }else{ mysql_query("update destinations set in_order= $High_column_rank where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } echo "<br />"; echo "<br />"; echo "Please select a destination."; } Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006263 Share on other sites More sharing options...
gwolgamott Posted February 3, 2010 Share Posted February 3, 2010 Yep. Else your rank will always be 14 or higher no matter what if that was inside the loop. Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006268 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 Where is $destChose defined? This... it looks like you removed it in your new code because you have it in your old code Nice! Good catch. I re-defined it in my new code and now I am able to update the in_order column of my database, however some of them change to 1s and others change to 2s when they are selected from the list. I want them to change to incrementing numbers (1,2,3,4,ect) Any ideas on how to fix this? Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006269 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 Yep. Else your rank will always be 14 or higher no matter what if that was inside the loop. Yes I've been having a lot of logic problems, I am still somewhat new to php and MySQL but thank you I think this helped to get me a step closer. Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006270 Share on other sites More sharing options...
aeroswat Posted February 3, 2010 Share Posted February 3, 2010 Where is $destChose defined? This... it looks like you removed it in your new code because you have it in your old code Nice! Good catch. I re-defined it in my new code and now I am able to update the in_order column of my database, however some of them change to 1s and others change to 2s when they are selected from the list. I want them to change to incrementing numbers (1,2,3,4,ect) Any ideas on how to fix this? Hold on a sec. Let me get this right. The only thing you wanted to do is set destChose1=1, destChose2=2, destChose3=3 etc? Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006277 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 Hold on a sec. Let me get this right. The only thing you wanted to do is set destChose1=1, destChose2=2, destChose3=3 etc? Yes, I believe so. As long as destChose1 is not necessarily the first item in my database, but rather the first item selected by the user. (Meaning they could select the 5th item in the list and that would be destChose1). Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006280 Share on other sites More sharing options...
aeroswat Posted February 3, 2010 Share Posted February 3, 2010 Hold on a sec. Let me get this right. The only thing you wanted to do is set destChose1=1, destChose2=2, destChose3=3 etc? Yes, I believe so. As long as destChose1 is not necessarily the first item in my database, but rather the first item selected by the user. (Meaning they could select the 5th item in the list and that would be destChose1). so destChose#=1,2,3,4 etc? I gotta go for now but if you still need help when i get back i'll be glad to help. Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006283 Share on other sites More sharing options...
gwolgamott Posted February 3, 2010 Share Posted February 3, 2010 Hold on a sec. Let me get this right. The only thing you wanted to do is set destChose1=1, destChose2=2, destChose3=3 etc? Yes, I believe so. Not really. I think I got them lost. Each call to this program is supposed to add a ranking to the table... A form submits to this program. Then this program takes the table and gives that destination a ranking. To do that you have to see what the other rankings are... the reason for the loop. And incrementing and updating the one field. So later he can call the table and display a list of destinations listed in order that they were selected. Lot of error checking to be involved in this yet too, but to get the basics of it working I tried to give code, but I'm so rusty at MY_SQL I think I lost em more then help. But hopefully that explains it to aeroswat and confirming what you are trying to do? Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006285 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 so destChose#=1,2,3,4 etc? I gotta go for now but if you still need help when i get back i'll be glad to help. Alright I'll probably still need your help haha but don't worry about it. Basically what I am dealing with is a database with 6 columns: "ID"(primary key auto increment), "Selected" (numeric value I would like to place an incrementing number in to list them in ascending order), "dest_name"(Contains the name of the destination to be chosen), "dest_addr"(Contains the address of the chosen destination that will be used in generating a link to google maps), "dest_date"(The date the destination was established - unimportant here but this is an informative website so it is necessary for organization), and the last column is "dest_description"(Contains a description of the destination - also irrelevant). So the outline of the table looks like this: ID Selected in_order dest_name dest_addr dest_date dest_description 1 0 (# depending on order selected) National Gallery of Art 401+Constitution+Ave N/A N/A On my web page is a drop-down list of the destinations in my database, with it's value in the list being equal to it's ID in the database. (ex. "<option value="5">White House Park</option>" is the 5th item stored in my database, having an ID of "5". Each item in the drop-down list is selected one at a time using a submit button. Then, a list of all the destinations chosen is displayed. This was done in my old code by changing the value of the selected destination's "Selected" column in the database from default "0" to "1" then everything with a value of "1" was pulled from the database and displayed in a list. The problem is that I want the list to be in the order they were selected, not in the order they are listed in my database. Any help on figuring out how to do this would be greatly appreciated. Here's my old code using the "selected" column containing either 0's or 1's to create the list (This code works fine, just not in the right order): if($_POST['submitted'] == true) { $destChose = $_POST['destList']; if($destChose >= 1) { mysql_query("update destinations set selected=1 where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE selected = '1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } }else{ mysql_query("update destinations set selected=1 where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE selected = '1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } echo "<br />"; echo "<br />"; echo "Please select a destination."; } } if($_POST['reset'] == true) { mysql_query("update destinations set selected=0 where selected='1'"); } if($_POST['linkgen'] == true) { $result = mysql_query("SELECT dest_addr FROM destinations WHERE selected = '1'"); $counter = mysql_num_rows($result); echo "<a href=\""; while ($row = mysql_fetch_array($result)) { $address[] = $row["dest_addr"]; } switch($counter) { case 1: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; break; case 2: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; break; case 3: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; break; case "4": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; break; case "5": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; break; case "6": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; break; case "7": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; break; case "8": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; break; case "9": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; break; case "10": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; break; case "11": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; break; case "12": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; break; case "13": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; break; case "14": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; echo "+to:"; echo $address[13]; break; default: break; } echo "&pw=2"; echo "\">" . "Directions" . "</a>"; } ?> <html> <head> <title>Create a Tour</title> </head> <body> <br /> <br /> <form name="tourCreation" action="createTour_workingfinal.php" method="post"> Please complete this form to create your tour: <br /> <br /> Destinations:<br /> <select name="destList" size="10"> <option value="1">National Gallery of Art</option> <option value="2">National Archives & Records Administration</option> <option value="3">National Law Enforcement Officers Memorial</option> <option value="4">Kenilworth Aquatic Gardens</option> <option value="5">White House Park</option> <option value="6">Washington Photo Safari</option> <option value="7">Federal Bureau of Investigation</option> <option value="8">Franciscan Monastery - Commissariat of the Holy Land in America</option> <option value="9">National Portrait Gallery Special Events Department</option> <option value="10">Rock Creek Park</option> <option value="11">Anacostia Community Museum</option> <option value="12">National Shrine of the Immaculate Conception </option> <option value="13">U.S. National Arboretum</option> <option value="14">Union Station</option> </select> <br /> <br /> <br /> <input type="submit" name="submitted" value="Select Destination" /> <input type="submit" name="reset" value="Reset" /> <input type="submit" name="linkgen" value="Get Link" /> </form> <br /> <br /> </body> </html> Here's my new code trying to use a counter to update the "in_order" column of my database with ascending numeric values: if($_POST['submitted'] == true) { $destChose = $_POST['destList']; $Col_result = mysql_query("SELECT in_order FROM destinations"); $column_array = mysql_fetch_array($Col_result); $High_column_rank = 0; for($i = 0; $i<14;$i++) { $column_current_rank = $column_array[$i]; if ($column_current_rank > $High_column_rank) {$High_column_rank = $column_current_rank;} } $High_column_rank++; mysql_query("update destinations set in_order= $High_column_rank where id= $destChose"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } }else{ mysql_query("update destinations set in_order= $High_column_rank where id={$destChose}"); $result = mysql_query("SELECT dest_name, dest_addr FROM destinations WHERE in_order >='1'"); while ($row = mysql_fetch_array($result)) { echo "<li>"; echo $row["dest_name"]; echo "</li>"; } echo "<br />"; echo "<br />"; echo "Please select a destination."; } if($_POST['reset'] == true) { mysql_query("update destinations set selected=0 where selected='1'"); } if($_POST['linkgen'] == true) { $result = mysql_query("SELECT dest_addr FROM destinations WHERE selected = '1'"); $counter = mysql_num_rows($result); echo "<a href=\""; while ($row = mysql_fetch_array($result)) { $address[] = $row["dest_addr"]; } switch($counter) { case 1: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; break; case 2: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; break; case 3: echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; break; case "4": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; break; case "5": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; break; case "6": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; break; case "7": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; break; case "8": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; break; case "9": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; break; case "10": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; break; case "11": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; break; case "12": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; break; case "13": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; break; case "14": echo "http://maps.google.com/maps?f=d&source=s_d"; echo "&saddr="; echo $address[0]; echo "&daddr="; echo $address[1]; echo "+to:"; echo $address[2]; echo "+to:"; echo $address[3]; echo "+to:"; echo $address[4]; echo "+to:"; echo $address[5]; echo "+to:"; echo $address[6]; echo "+to:"; echo $address[7]; echo "+to:"; echo $address[8]; echo "+to:"; echo $address[9]; echo "+to:"; echo $address[10]; echo "+to:"; echo $address[11]; echo "+to:"; echo $address[12]; echo "+to:"; echo $address[13]; break; default: break; } echo "&pw=2"; echo "\">" . "Directions" . "</a>"; } ?> <html> <head> <title>Create a Tour</title> </head> <body> <br /> <br /> <form name="tourCreation" action="createTour_inorderRedone.php" method="post"> Please complete this form to create your tour: <br /> <br /> Destinations:<br /> <select name="destList" size="10"> <option value="1">National Gallery of Art</option> <option value="2">National Archives & Records Administration</option> <option value="3">National Law Enforcement Officers Memorial</option> <option value="4">Kenilworth Aquatic Gardens</option> <option value="5">White House Park</option> <option value="6">Washington Photo Safari</option> <option value="7">Federal Bureau of Investigation</option> <option value="8">Franciscan Monastery - Commissariat of the Holy Land in America</option> <option value="9">National Portrait Gallery Special Events Department</option> <option value="10">Rock Creek Park</option> <option value="11">Anacostia Community Museum</option> <option value="12">National Shrine of the Immaculate Conception </option> <option value="13">U.S. National Arboretum</option> <option value="14">Union Station</option> <option value="23">Tommy J</option> </select> <br /> <br /> <br /> <input type="submit" name="submitted" value="Select Destination" /> <input type="submit" name="reset" value="Reset" /> <input type="submit" name="linkgen" value="Get Link" /> </form> <br /> <br /> </body> </html> tl;dr - That is an overview of how my database is set up / my goals / two sets of my code. If you need anymore details feel free to ask. Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006292 Share on other sites More sharing options...
TeamCIT Posted February 3, 2010 Author Share Posted February 3, 2010 Not really. I think I got them lost. Each call to this program is supposed to add a ranking to the table... A form submits to this program. Then this program takes the table and gives that destination a ranking. To do that you have to see what the other rankings are... the reason for the loop. And incrementing and updating the one field. So later he can call the table and display a list of destinations listed in order that they were selected. Lot of error checking to be involved in this yet too, but to get the basics of it working I tried to give code, but I'm so rusty at MY_SQL I think I lost em more then help. But hopefully that explains it to aeroswat and confirming what you are trying to do? Yeah, I have to admit some of your code is somewhat confusing to me haha. It did help get me on the right track I believe. Right now my new code using chunks of the code you gave me is working the same way my old one is, which displays the list in the order they appear in my database. But this is definatly a step in the right direction as before when I mixed our code it did not work at all. Oops - I realized I forgot to comment on your quote haha. I went into a good amount of detail in my previous post so hopefully it will be easy to understand what I am trying to do from that one Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006296 Share on other sites More sharing options...
TeamCIT Posted February 4, 2010 Author Share Posted February 4, 2010 Bumping my post from yesterday, can anyone help me solve this? Link to comment https://forums.phpfreaks.com/topic/190818-having-trouble-with-mysql-queries/#findComment-1006819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.