Page 1 of 1

probelems inserting more inputfields

Posted: Thu Jan 29, 2009 9:54 am
by mighty
Hi Im trying to set up a scoreboard and im adapting another piece of code

it is a table that displays jokes in a mysql table I want to add names school gender and score but it is only adding name.
joke text is the name field on the database
here is the link

http://www.igloo-design.org/php/example ... einfo2.php


this is the code

// Select the jokes database
if (!@mysql_select_db('igloodesi1')) {
exit('<p>Unable to locate the scores ' .
'database at this time.</p>');
}

// If a joke has been submitted,
// add it to the database.
if (isset($_POST['joketext'])) {
$joketext = $_POST['joketext'];


$sql = "INSERT INTO highScore SET
player='$joketext'";
if (@mysql_query($sql)) {
echo '<p>Your scores has been added.</p>';
} else {
echo '<p>Error adding submitted score: ' .
mysql_error() . '</p>';
}
}


echo '<p>Here are all the scores in our scoreboard:</p>';

// Request the text of all the jokes
$result = @mysql_query('SELECT * FROM highScore ORDER BY score DESC');
if (!$result) {
exit('<p>Error performing query: ' .
mysql_error() . '</p>');
}

echo "<table border='1'>";
echo "<tr> <th>PLAYER</th> <th>SCHOOL</th> <th>GENDER</th> <th>SCORE</th> </tr>";
// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)) {
echo "<tr><td>";
echo $row['player'];
echo "</td><td>";
echo $row['school'];
echo "</td><td>";
echo $row['gender'];
echo "</td><td>";
echo $row['score'];
echo "</td></tr>";
}

// When clicked, this link will load this page
// with the joke submission form displayed.
echo '<p><a href="' . $_SERVER['PHP_SELF'] .
'?addjoke=1">Add a Score!</a></p>';

endif;
?>

Re: probelems inserting more inputfields

Posted: Thu Jan 29, 2009 7:19 pm
by yacahuma
you only insert, just insert one thing.
Take a look at this link for how to insert in a table
http://www.w3schools.com/sql/sql_insert.asp

Re: probelems inserting more inputfields

Posted: Thu Jan 29, 2009 7:21 pm
by Benjamin
Use code tags please.