Derleek Posted May 29, 2008 Share Posted May 29, 2008 Ok, so I'm quite confused about this issue. I set up a script to store 10 items that where selected by a user w/ drop down menu's. This script is supposed to take each of the 10 selected values along with several user oriented variables into a database called 'benchracers'. Everything seemed to be working fine, until i went to output the data stored. The only thing that has an output value is "ID". so can anyone figure out why the ONLY thing I am able to get an output value to is 'ID'. here is the code: if(isset($_POST)) { dbconnect('thethrgu_moto'); foreach ($choices as $n => $choice) { if ($choice == 'null') { error('you did not completely fill out your top ten!!!'); } } if (count(array_unique($choices)) != 10) { error('you had some duplicate riders, please make sure you do not enter a rider more than once!'); } else { $race_id = 3; $paid = 1; $pick_id=1; $sql = "SELECT COUNT(*) FROM benchRacers WHERE id = $id && race_id = $race_id"; $result = mysql_query($sql); if (!$result) { echo mysql_error(); } if (@mysql_result($result,0,0)>0) { echo "You have already entered your data for this race, would you like to re-do it?"; } else { for($i=0;$i<10;$i++) { $sql = "INSERT INTO benchracers (id, pick_id, racer_id, race_id, paid) VALUES ($id,$pick_id,$choices[$i],$race_id,$paid)"; echo $sql; mysql_query($sql) or die(mysql_error()); $pick_id++; } $query = "SELECT * FROM benchracers"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "id: ".$row['id']." - Race_id: ".$row['race_id']." - Racer_id: ".$row['racer_id']." - Pick_id: ".$row['pick_id']."<br>"; } } } } and the table create: $benchracers = "CREATE TABLE benchRacers( id INT, pick_ID INT, racer_ID INT, race_ID INT, paid INT)"; mysql_query($query) or die(mysql_error()); It is entirely possible (i suppose) that the way i am retrieving the data is not valid, and is getting all funked up. I don't know... please pick at my code if you so chose, i love figuring out new and better ways to get things done Quote Link to comment Share on other sites More sharing options...
Derleek Posted May 30, 2008 Author Share Posted May 30, 2008 oh, i forgot to say that when i echo "$sql" all of the variables that are to be stored are set how they should be Quote Link to comment Share on other sites More sharing options...
fenway Posted May 30, 2008 Share Posted May 30, 2008 oh, i forgot to say that when i echo "$sql" all of the variables that are to be stored are set how they should be Let's see it. Quote Link to comment 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.