wooowooo Posted December 24, 2007 Share Posted December 24, 2007 Hi Anyone know where the error is in my code? I cannt find it The solution only displays " - Edit " it doesnt show the name and when you click it the information isnt displayed to update the record Thanks <?php //connect to database //If cmd has not been initialized if(!isset($cmd)) { //display the whole menu $result = mysql_query("select * from week10 order by name ASC"); //run the while loop that grabs all the news scripts while($r=mysql_fetch_array($result)) { //grab the name and the ID of the menu item $name=$r["name"];//take out the name $menuID=$r["menuID"];//take out the id //make the title a link echo "<a href='edit.php?cmd=edit&name=$name'>$title - Edit</a>"; echo "<br>"; } } ?> <?php if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $menuID = $_GET["menuID"]; $sql = "SELECT * FROM week10 WHERE name=$name"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <form action="wk10ex2.php" method="post"> <input type=hidden name="id" value="<?php echo $myrow["menuID"] ?>"> Name:<INPUT TYPE="TEXT" NAME="name" VALUE="<?php echo $myrow["name"] ?>" SIZE=30><br> Description:<TEXTAREA NAME="description" VALUE="<? echo $myrow["description"] ?>"</TEXTAREA><br> Price:<INPUT TYPE="TEXT" NAME="price" VALUE="<?php echo $myrow["price"] ?>" SIZE=30><br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </form> <?php } ?> <?php if ($_POST["$submit"]) { $name = $_POST["name"]; $description = $_POST["description"]; $price = $_POST["price"]; $sql = "UPDATE week10 SET name='$name',description='$description',price='$price' WHERE menuID=$menuID"; $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/ Share on other sites More sharing options...
redarrow Posted December 24, 2007 Share Posted December 24, 2007 '$menuID' <<< added ' ' Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/#findComment-422553 Share on other sites More sharing options...
corbin Posted December 24, 2007 Share Posted December 24, 2007 Of course all it says is ' - Edit'.... You never define $title. Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/#findComment-422554 Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 Where do you define $title? echo "<a href='edit.php?cmd=edit&name=$name'>$title - Edit</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/#findComment-422556 Share on other sites More sharing options...
redarrow Posted December 24, 2007 Share Posted December 24, 2007 if ($_POST["$submit"]) << what this >>$<< for Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/#findComment-422561 Share on other sites More sharing options...
wooowooo Posted December 24, 2007 Author Share Posted December 24, 2007 I edited the form using one I found in a tutorial, im basically trying to make it so a user can edit information in the database via the internet and php Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/#findComment-422563 Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 May want to learn how variables work first. Quote Link to comment https://forums.phpfreaks.com/topic/83067-edit-rows-in-database/#findComment-422569 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.