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
https://forums.phpfreaks.com/topic/222390-need-a-where-clause/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.