I am a little lost being new to databases. I am trying to create a page/form that, from a link only the admin can see, pulls in that $id’s information from the database, displays it so that each field can be updated and saves it back to the database. I also added a form at the bottom of the page to input a new field into the database. For simplicity sake I put them on one page but I can separate them out if needed. My code does not work yet and any help would be greatly appreciated.
echo "<a href=\"test.html?p=ID{$row["id"]}\">Edit</a><br>";
spits out a link to test.html?p=ID(#)
The link part is working perfectly.
Admin page
<div><h1 class="pageTitle">Episode List UPDATE</h1></div>
<?php
// Connect to the database
require 'include/episodelist.db.php';
// Ask the database for the information from the season table BUT how to only get info for the ID?
$query="SELECT * FROM `season` WHERE `id` = $id";
$result = mysql_query("SELECT * FROM season");
$num=mysql_numrows($result);
mysql_close();
?>
<form action="include/epslist.update.php" method="POST">
<table>
<tr>
<td>Season Number: </td><td><input type="text" name="season_sum" size="50" value="<? echo "$season_num";?>"></td>
</tr>
<tr>
<td>Episode Number: </td><td><input type="text" name="eps_num" size="50" value="<? echo "$eps_num";?>"></td>
</tr>
<tr>
<td>Temp Episode Number: </td><td><input type="text" name="temp_eps_num" size="50" value="<? echo "$temp_eps_num";?>"></td>
</tr>
<tr>
<td>Title: </td><td><input type="text" name="title" size="50" value="<? echo "$title";?>"></td>
</tr>
<tr>
<td>Description: </td><td><textarea type="text" name="descrip" cols="50" rows="7" value="<? echo "$descrip";?>"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="Submit" value="Update">
</td>
</tr>
</table></form>
<div class="Down10px"></div>
<div><h1 class="pageTitle">Episode List NEW</h1></div>
<form action="include/epslist.new.php" method="POST">
<table>
<tr>
<td>Season Number: </td><td><input type="text" name="season_sum" size="50" value="<? echo "$season_num";?>"></td>
</tr>
<tr>
<td>Episode Number: </td><td><input type="text" name="eps_num" size="50" value="<? echo "$eps_num";?>"></td>
</tr>
<tr>
<td>Temp Episode Number: </td><td><input type="text" name="temp_eps_num" size="50"></td>
</tr>
<tr>
<td>Title: </td><td><input type="text" name="title" size="50"></td>
</tr>
<tr>
<td>Description: </td><td><textarea type="text" name="descrip" cols="50" rows="7"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="Submit" value="New Item">
</td>
</tr>
</table></form>
epslist.update.php
<?php
require "episodelist.db.php";
//Test for user inout
if (!empty($_GET[season_sum])&&
!empty($_GET[eps_num])&&
!empty($_GET[temp_eps_num])&&
!empty($_GET[title])&&
!empty($_GET[descrip]))
{
// Im at a lost how to pull in the data just for test.html&=edit(#), check if a user changed it, then if so update that value in the database
// Trying to redirect the user back to the list once the update is finished
header("Location:");
?>
epslist.new.php UPDATED
<?php
require "episodelist.db.php";
//Test for user inout
if (!empty($_POST[season_sum])&&
!empty($_POST[eps_num])&&
!empty($_POST[temp_eps_num])&&
!empty($_POST[title])&&
!empty($_POST[descrip]))
{
$season_sum = mysqlclean($_POST,"season_sum",$link);
$eps_num = mysqlclean($_POST,"eps_num",$link);
$temp_eps_num = mysqlclean($_POST,"temp_eps_num",$link);
$title = mysqlclean($_POST,"title",$link);
//This is a text area cols 50 rows 7
$descrip = mysqlclean($_POST,"descrip",$link);
$ID = mysqlclean($_POST,"id",$link);
}
if ( ! empty($_POST['ID']))
$id = (int)$_POST['ID'];
else $id = 'NULL';
//Insert new entry
$query = "INSERT INTO `season` (`ID`, `season_num`, `temp_eps_num`, `esp_num`, `title`, `descrip`) VALUES ({$id}, '{$season_sum}', '{$eps_num}', '{$temp_eps_num}', '{$title}', '{$descrip}')";
// Trying to rederect the user back to the list once the update is successfully finished
header("Location: episodelist_superadmin.html");
?>
I don’t quite understand your question, but I think what you’re asking for is some edit to
which should be something like