Jump to content


Updating mysql record, please help


1 reply to this topic

#1 Macintosh

    Young Padawan

  • Members
  • Pip
  • 28 posts

Posted 20 January 2009 - 02:24 PM

I want to update mysql records with basic form by using OOP PHP.

Im doing in following way but i want to do by a function, so that i dont. please anybody help me, how can that.

Thanks everybody.

<?
if($_POST[submit]){
		$title = $_POST['title'];
		$body = $_POST['body'];
			$result = mysql_query("UPDATE blog SET title='$title', body='$body' WHERE id='$postid' ") or die (mysql_error());
		echo "<b>Thank you! News UPDATED Successfully!<br>";
		  
			}
			
			?>


<?
$result = mysql_query("SELECT * FROM blog WHERE id='$postid' ") or die (mysql_error());
			while($myrow = mysql_fetch_assoc($result))
			{
				$title = $myrow["title"];
				$body = $myrow["body"];
				?>
<br>
<h3>::Edit News</h3>
<form method="post">
Title: <input name="title" size="40" maxlength="255" value="<? echo $title; ?>"><br>
Text1: <textarea name="body"  rows="7" cols="30"><? echo $body; ?></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 20 January 2009 - 07:24 PM

I don't understand your question. Why would you want to change what you have? Currently, you are using the simplest possible method to update a database, why complicate it with OOP?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users