Jump to content

Need a WHERE clause???


fife

Recommended Posts

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();
}     
}
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.