Jump to content

update a lot of colums at once


koolaidman52

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/14784-update-a-lot-of-colums-at-once/
Share on other sites

The SQL Syntax is:
[b]UPDATE table SET row_name='value' WHERE condition='value'[/b]

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

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.