aznjay Posted September 23, 2008 Share Posted September 23, 2008 <? include "database.php"; ?> <form method="post"> <select name="base"> <option value="ps">Photoshop</option> <option value="phptut">Php Tutorial</option> </select> <input type="submit" name="table" value="submit"> </form> <? if(isset($_POST['base'])) { $tabs = $_POST["base"]; //display all the news $result = mysql_query("select * from $tabs order by id"); //run the while loop that grabs all the news scripts while($r = mysql_fetch_array($result)) { //grab the title and the ID of the news $title=$r["title"];//take out the title $id=$r["id"];//take out the id $rob=$r["id"];//take out the id //make the title a link echo "<a href='editlinks.php?cmd=edit&id=$id&base=$tabs'>$title - Edit</a> | "; echo "<a href='editlinks.php?cmd=delete&id=$rob&base=$tabs'>DELETE</a>"; echo "<br>"; } } elseif(isset($_REQUEST["cmd"]) && $_REQUEST["cmd"] == "edit") { if (!isset($_POST["submit"])) { $ids = $_GET["id"]; $tabsl = $_GET["base"]; $sql = "SELECT * FROM $tabsl WHERE id=$ids"; $result = mysql_query($sql) or die('MySQL Error: ' .mysql_error()); $myrow = mysql_fetch_array($result); ?> <form method="post"> <input type=hidden name="idd" value="<?php echo $myrow["id"]; ?>"> Title:<INPUT TYPE="TEXT" NAME="right" VALUE="<?php echo $myrow["title"]; ?>" SIZE=30><br> Description:<INPUT TYPE="TEXT" NAME="left" VALUE="<?php echo $myrow["desp"]; ?>" SIZE=30><br> Time:<INPUT TYPE="TEXT" NAME="up" VALUE="<? echo date("g:i a"); ?>" SIZE=30><br> Date:<INPUT TYPE="TEXT" NAME="down" VALUE="<? echo date("M.j.y"); ?>" SIZE=30><br> Article:<br><TEXTAREA NAME="side" ROWS=15 COLS=40><? echo $myrow["article"] ?></TEXTAREA><br> <input type="submit" name="edit_update" value="submit"> </form> <?php } elseif(isset($_REQUEST["cmd"]) && $_REQUEST["cmd"] == "edit") { // perform the following when the form below is submitted if(isset($_POST['edit_update'])) { $id = $_POST["id"]; $title = $_POST["title"]; $time = $_POST["time"]; $date = $_POST["date"]; $message = $_POST["message"]; $tabs = $_POST["base"]; $sql = "UPDATE $tabs SET title='$title',time='$time',date='$date',article='$message', WHERE id=$id"; $result = mysql_query($sql) or die(mysql_error()); echo 'Table `'.$tabs.'` updated!'; } // form hasn't been submitted yet, display edit form else { $id = $_GET["id"]; $tabs = $_GET["base"]; $sql = "SELECT * FROM $tabs WHERE id=$id"; $result = mysql_query($sql) or die('MySQL Error: ' .mysql_error());; $myrow = mysql_fetch_array($result); ?> <form method="post"> <input type=hidden name="id" value="<?php echo $myrow["id"] ?>"> Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["head"] ?>" SIZE=30><br> Name:<INPUT TYPE="TEXT" NAME="name" VALUE="<?php echo $myrow["name"] ?>" SIZE=30><br> Time:<INPUT TYPE="TEXT" NAME="time" VALUE="<?php echo date("g:i a"); ?>" SIZE=30><br> Date:<INPUT TYPE="TEXT" NAME="date" VALUE="<?php echo date("M.j.y"); ?>" SIZE=30><br> Message:<br><TEXTAREA NAME="message" ROWS=15 COLS=40><?php echo $myrow["msg"] ?></TEXTAREA><br> <input type="hidden" name="cmd" value="edit"> <input type="hidden" name="base" value="<?php echo $base; ?>"> <input type="submit" name="edit_update" value="submit"> </form> <?php } } elseif(isset($_REQUEST["cmd"]) && $_REQUEST["cmd"] == "delete") { echo 'Perform delete action here'; } else { echo '<pre>' . print_r($_POST, true) . '</pre>'; } } ?> The code UPDATe doesn't work at all.. Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/ Share on other sites More sharing options...
F1Fan Posted September 23, 2008 Share Posted September 23, 2008 Any errors or anything? It helps to be as specific as possible. Please give us more than just it's not working. Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/#findComment-648379 Share on other sites More sharing options...
aznjay Posted September 23, 2008 Author Share Posted September 23, 2008 Any errors or anything? It helps to be as specific as possible. Please give us more than just it's not working. Well when ever I submit the edit form..it's not UPDATING the information in the database. Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/#findComment-648402 Share on other sites More sharing options...
.josh Posted September 23, 2008 Share Posted September 23, 2008 so are you saying you aren't getting any errors from your die(mysql_error) ? Did you echo the $sql to see if the query is what you are expecting; all the values there, etc..? Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/#findComment-648406 Share on other sites More sharing options...
aznjay Posted September 23, 2008 Author Share Posted September 23, 2008 Sorrie guys it's a TYPO .... Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/#findComment-648419 Share on other sites More sharing options...
.josh Posted September 23, 2008 Share Posted September 23, 2008 Sorrie guys it's a TYPO .... So I will assume it's solved then. Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/#findComment-648582 Share on other sites More sharing options...
aznjay Posted September 23, 2008 Author Share Posted September 23, 2008 Sorrie guys it's a TYPO .... So I will assume it's solved then. yeah it's solved just check the error out...a lot of people checked the code, but it's just a comma problem. HAHHAH Quote Link to comment https://forums.phpfreaks.com/topic/125405-solved-update-does-not-occur/#findComment-649009 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.