MySQL Forums
Forum List  »  PHP

Insert into database
Posted by: Gordon White
Date: November 18, 2015 11:32AM

I am new to PHP and MySQL, everything I have here is what I could find in tutorials.

I have the following code to select playersid and name:

<form action="process.php" method="post" />
<div>
<label for="list">Select Player: </label>
<select name="list">
<option value=''>-----SELECT-----</option>
<?php
$conn = mysqli_connect('localhost', 'gw32', 'buggy1', 'fripoker');
$result = mysqli_query($conn, 'SELECT playersid, name FROM players');
while ($row = mysqli_fetch_assoc($result)) {
echo "<option value='$row[playersid]'>$row[name]</option>";
}
?>
</select>

Then I have a separate program to insert into table:

<?php
include 'config.php';

$player = $_POST['list'];
$name = $_POST['name'];
$players = $_POST['number'];
$date = $_POST['week'];
$attend = $_POST['attend'];
$points = $_POST['points'];
$payout = $_POST['payout'];
$high_hand = $_POST['high_hand'];
$fifty_fifty = $_POST['fifty_fifty'];

$sql = "INSERT INTO data (playersid, name, players, dateid, attend, points, payout, high_hand, fifty_fifty) VALUES ('$player', '$name', '$players', '$date', '$attend', '$points', '$payout', '$high_hand', '$fifty_fifty')";

if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}

/* Redirect browser */
header("Location: http://dev.earringcloset.com/poker/index.php";);

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Problem is twofold 1) it will not insert name into table and 2) I can not get it to return to the first program to insert more data.

Thanks in advance.

Options: ReplyQuote


Subject
Written By
Posted
Insert into database
November 18, 2015 11:32AM
December 08, 2015 09:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.