fife Posted December 22, 2010 Share Posted December 22, 2010 Hi. I am building an update table form. In this table there are only two fields, Header and Intro. Now I have the form and currently it displays whats already in the database. Now when the user edits these two fields and presses edit. Obviously I want it to update these fields. I have the code here but there is an issue with it. At the end of the update I believe I need a update fields WHERE....... which would be used if there was more than one entrance in the table but there is and only ever will be one entry. WHERE what? I dont have a where anything. Do I need this or can it be omitted somehow? <?php if(isset($_POST['edit'])){ //Process data for validation $header = trim($_POST['header']); $intro = trim($_POST['intro']); //Perform validations next //Prepare data for db insertion $header = mysql_real_escape_string($header); $intro = mysql_real_escape_string($intro); //insert $qUpdateDetails = "UPDATE index SET `header` = '".$header."', `intro` = '".$intro."', WHERE ???????='".?????????."'"; $rUpdateDetails = mysql_query($qUpdateDetails) or die(mysql_error()); //next page $page_edit = "Index page has been edited"; $url = "signed.php?edit='".$page_edit."'" or die(mysql_error()); header("Location: ".$url."") or die(mysql_error()); exit(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/222390-need-a-where-clause/ Share on other sites More sharing options...
trq Posted December 22, 2010 Share Posted December 22, 2010 If there is only ever going to be one row in that table then you don't need any WHERE clause. Quote Link to comment https://forums.phpfreaks.com/topic/222390-need-a-where-clause/#findComment-1150322 Share on other sites More sharing options...
fife Posted December 22, 2010 Author Share Posted December 22, 2010 cool thank you Quote Link to comment https://forums.phpfreaks.com/topic/222390-need-a-where-clause/#findComment-1150326 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.