Jump to content

[SOLVED] confused...


Derleek

Recommended Posts

Ok, so i posted this in the MySQL help section but i'm not sure if i should post it here or there.

 

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:

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:

Code:

 

$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
https://forums.phpfreaks.com/topic/107902-solved-confused/
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.