Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PHP MySQL Insert Syntax

1 view
Skip to first unread message

kvigor

unread,
Apr 1, 2008, 1:30:33 PM4/1/08
to php-g...@lists.php.net
/*I'm trying to insert values from an array into MySQL DB but the insert
begins at the last record in the table and not at first record in the table.
I have added the cellSuffixes column after I already populated 30 records in
other columns*/

Code:

foreach($list as $key=>$value)
{
$query = "INSERT INTO carriers (cellSuffixes) VALUES('$value')";
mysql_query($query,$connex) or die("Query failed: ".
mysql_error($connex));
}
echo "done";
mysql_close($connex);

//I don't know what the sytax s/b to get the data to be inserted in the
first row of the column.

ad...@buskirkgraphics.com

unread,
Apr 1, 2008, 1:54:36 PM4/1/08
to php-g...@lists.php.net, k3ch...@insightbb.com
Insert is for a new row

Alter or Update is for an exsisting row

Code:


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

kvigor

unread,
Apr 1, 2008, 2:05:29 PM4/1/08
to php-g...@lists.php.net
Thanks :-)


<ad...@buskirkgraphics.com> wrote in message
news:28422285.219271207072476641.JavaMail.servlet@perfora...

fwd...@gmail.com

unread,
Apr 1, 2008, 6:18:08 PM4/1/08
to
//
you can use this query to update all the records in the table:
//

$query = "update carriers set cellSuffixes='$value'";

//
Because you have already inserted 30 records and you are making
changes to your data I think you need to use WHERE clause like this.
//

$query = "update carriers set cellSuffixes='$value' where id=ROW ID
COMES HERE";

0 new messages