I have several select statements that look like this. I need to pass the php variable into my database.
<select name="gamestart" >
<?php for($gamestart=1; $gamestart<=24; $gamestart++)
echo "<option value='$gamestart'>$gamestart:00</option>";
?>
</select>
Here is my insert statement into my database with other similar variables where I have the same issue.
<?php
$mysql_query = "INSERT INTO soccer_games (gamestart, gameend)
VALUES ('$gamestart', '$gameend')";
$this->db->query($mysql_query);
?>
As of now, values are being put into the database but the value that is INSERT'ed into the database is the number 25 (not even an option in my loop as you can see) regardless of what value I select in the form.
===============
EDIT 1: The problem would probably be that I haven't used a form (Me in my infinite wisdom didn't realize I needed a form for this).
I am assuming I will need something of this nature...
public function insertstatements(){
<?php
$mysql_query = "INSERT INTO soccer_games (gamestart, gameend)
VALUES ('$gamestart', '$gameend')";
$this->db->query($mysql_query);
?>
}
<form method="post" action="<?php insertstatements(); ?>">
<select name="gamestart" >
<?php for($gamestart=1; $gamestart<=24; $gamestart++)
echo "<option value='$gamestart'>$gamestart:00</option>";
?>
</select>
</form>
gamestartfrom the HTTP request$gamestartand$gameendbefore the query? I have a feeling you're running the insert code before the form has been submitted... (that's whygamestartis 25, the value it would have once your loop has finished)$gamestarton your query, and all the operations you are doing with it. Upd: Yay three same questions hitting youPascal, try to chew that... :P