Jump to content

Archived

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

eric07

HELP ME!

Recommended Posts

Hi I am really srtuggling with how to create a update SQL statement for a table in MySQL. I know I need a SQL statement but I am struggling in implementing it. Is there any examples of code that I can look at that will explain this.

The new values that will be assigned to these table are done through $_POST function. So do I also have to assign these to normal php variables embedded in the page and then map these to fields in the table?

Share this post


Link to post
Share on other sites
[code]<?php
$var_1 = $_POST['textfield_name'];
$sql = mysql_query("INSERT INTO table_name VALUES ('$var_1')"); // the same would apply to UPDATE statements

// or

$sql = mysql_query("INSERT INTO table_name VALUES ('" . $_POST['textfield_name'] . "')");
?>[/code]

edited my errors.

Share this post


Link to post
Share on other sites
Both those examples are incorrect.
[code]
INSERT INTO tbl (fld1,fld2) VALUES ('val1','val2');
[/code]
Or to update...
[code]
UPDATE tbl SET fld1='val1',fld2='val2';
[/code]

Share this post


Link to post
Share on other sites

×

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.