Jump to content


Photo

update a lot of colums at once


  • Please log in to reply
2 replies to this topic

#1 koolaidman52

koolaidman52
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 16 July 2006 - 07:14 PM

i want to update an entire row of data in a DB heres what I'm trying in a nutshell

$que = "UPDATE series SET (first_name, last_name, age) = ('$_POST[firstname]','$_POST[lastname]','$_POST[age]') WHERE name = '$name'";
mysql_query("$que", $connection) or die('Error, query failed');

It dies, is my syntax right?
Btcartoons.com --  coded entirely in Mom's basement.

#2 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 16 July 2006 - 07:35 PM

The SQL Syntax is:
UPDATE table SET row_name='value' WHERE condition='value'

Your query is:
$que = "UPDATE series SET first_name='{$_POST['firstname']}', last_name='{$_POST['lastname']}', age = $_POST['age'] WHERE name = '$name'";

<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#3 koolaidman52

koolaidman52
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 16 July 2006 - 07:53 PM

ok it worked thanks
Btcartoons.com --  coded entirely in Mom's basement.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users