paulredeye
12-06-2006, 09:36 AM
I seem to be having an issue with an edit page. The view page loads fine and shows links to each tournament with the edit button determining the id number of each all correctly.
If I click the edit link, it loads the next page cleanly and with the correct information in it. I can then type in the box and alter the entry. However when I hit SUBMIT, I get a blank page come up and nothing is changed or entered any differently in the actual SQL database.
Any ideas on where Ive gone wrong? Its taken me 3 coffee's so far and I just cant see it (wood for tree's perhaps :p).
Oh and the Delete function doesnt work either (same issues perhaps), but I do get the confirmation that it has been deleted! (it hasnt from the SQL).
<?php
if(!isset($cmd))//if the variable $cmd is not set, do this
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") //if the link for the edit cmd was selected, do this
{
if (!isset($_POST["submit"])) //if submit has not yet been pressed, do this
{
$tournament_id = $_GET["tournament_id"]; //get the id of the news article being edited. This is provided in the link to edit it.
$sql = "SELECT * FROM tournament WHERE tournament_id=$tournament_id"; //select all columns from mynews with this id
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
}
}
?>
<?php
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") //if the link for the edit cmd was selected, do this
{
if (!isset($_POST["submit"])) //if submit has not yet been pressed, do this
{
$id = $_GET["id"]; //get the id of the news article being edited. This is provided in the link to edit it.
$sql = "SELECT * FROM tournament WHERE tournament_id=$tournament_id"; //select all columns from mynews with this id
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="edit_event.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["tournament_id"] ?>">
Title*:
<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["tournament_name"] ?>" SIZE=30>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</form>
<? } ?>
<?php
if ($_POST["$submit"]) //if submit was pressed, do this
{
$tournament_id = $_GET["tournament_id"]; //get the id of the news article being edited. This is provided in the link to edit it.
$tournament_name = $_POST["tournament_name"];
$sql = "UPDATE tournament SET tournament_name='$tournament_name' WHERE tournament_id=$tournament_id']."; //UPDATE the columns in your table with the new content provided in the text areas in the form
$result = mysql_query($sql); //run this query
echo "Information updated. <a href=main.php>Return</a>"; //provide an easy link back to edit.php
}
}
?>
<?php
if($_GET["cmd"]=="delete")
{
$sql = "DELETE FROM country WHERE country_id=$country_id"; //DELETE the row that contains the $id of the post selected
$result = mysql_query($sql); //run this query
echo "Country Deleted!<a href=main.php>Return to Edit</a>"; //easy link back to editnews.php
}
?>
If I click the edit link, it loads the next page cleanly and with the correct information in it. I can then type in the box and alter the entry. However when I hit SUBMIT, I get a blank page come up and nothing is changed or entered any differently in the actual SQL database.
Any ideas on where Ive gone wrong? Its taken me 3 coffee's so far and I just cant see it (wood for tree's perhaps :p).
Oh and the Delete function doesnt work either (same issues perhaps), but I do get the confirmation that it has been deleted! (it hasnt from the SQL).
<?php
if(!isset($cmd))//if the variable $cmd is not set, do this
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") //if the link for the edit cmd was selected, do this
{
if (!isset($_POST["submit"])) //if submit has not yet been pressed, do this
{
$tournament_id = $_GET["tournament_id"]; //get the id of the news article being edited. This is provided in the link to edit it.
$sql = "SELECT * FROM tournament WHERE tournament_id=$tournament_id"; //select all columns from mynews with this id
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
}
}
?>
<?php
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") //if the link for the edit cmd was selected, do this
{
if (!isset($_POST["submit"])) //if submit has not yet been pressed, do this
{
$id = $_GET["id"]; //get the id of the news article being edited. This is provided in the link to edit it.
$sql = "SELECT * FROM tournament WHERE tournament_id=$tournament_id"; //select all columns from mynews with this id
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="edit_event.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["tournament_id"] ?>">
Title*:
<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["tournament_name"] ?>" SIZE=30>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</form>
<? } ?>
<?php
if ($_POST["$submit"]) //if submit was pressed, do this
{
$tournament_id = $_GET["tournament_id"]; //get the id of the news article being edited. This is provided in the link to edit it.
$tournament_name = $_POST["tournament_name"];
$sql = "UPDATE tournament SET tournament_name='$tournament_name' WHERE tournament_id=$tournament_id']."; //UPDATE the columns in your table with the new content provided in the text areas in the form
$result = mysql_query($sql); //run this query
echo "Information updated. <a href=main.php>Return</a>"; //provide an easy link back to edit.php
}
}
?>
<?php
if($_GET["cmd"]=="delete")
{
$sql = "DELETE FROM country WHERE country_id=$country_id"; //DELETE the row that contains the $id of the post selected
$result = mysql_query($sql); //run this query
echo "Country Deleted!<a href=main.php>Return to Edit</a>"; //easy link back to editnews.php
}
?>