I have a page that shows information from my database. Each array has an edit link that has a unic id (.html?id=4).
The problem:
The form I created to query the database based on the id results in no information being displayed?
Any idea what I need to do to accomplish this?
<?php
// Connect to the database
require 'include/episodelist.db.php';
// Ask the database for the information from the table based on .html?id=#
$query="SELECT * FROM `season` WHERE `id` = $id";
//The above query is the problem.
$result = mysql_query("SELECT * FROM 'season'");
mysql_close();
?>
<form action="include/epslist.edit.php" method="POST">
<table>
<tr>
<td>Season Number: </td><td><input type="text" name="season_sum" size="50" value="<?php echo "$season_num";?>"></td>
</tr>
<tr>
<td>Episode Number: </td><td><input type="text" name="eps_num" size="50" value="<?php echo "$eps_num";?>"></td>
</tr>
<tr>
<td>Temp Episode Number: </td><td><input type="text" name="temp_eps_num" size="50" value="<?php echo "$temp_eps_num";?>"></td>
</tr>
<tr>
<td>Title: </td><td><input type="text" name="title" size="50" value="<?php echo "$title";?>"></td>
</tr>
<tr>
<td>Description: </td><td><textarea type="text" name="descrip" cols="50" rows="7" value="<?php echo "$descrip";?>"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="Submit" value="Update">
</td>
</tr>
</table></form>
You need to check if the form has the $id passed as a variable, if so, get the $id and populate the fields with data from the database. If not, show a blank form.
Of course, use of mysql this way lends to security concerns and is headed in the direction of deprecation. PDO (PHP Data Objects) is the way to go for handling database operations. Usage of PDO allows prepared statements/parameterized queries and looks something like this: