Jump to content

[SOLVED] database storing issue... =(


Derleek

Recommended Posts

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

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.