|
Posted by David Robinson on 03/20/05 01:43
"R.Lange" <cl1mh4224rd@gmail.com> wrote in message
news:E_ydnWTOuZg9EqHfRVn-iQ@comcast.com...
> David Robinson wrote:
>> "Tex John" <john@logontexas.com> wrote in message
>> news:qaF_d.2230$ot.1745@tornado.texas.rr.com...
>>
>>>$query = "INSERT INTO database SET ";
>>>for ($x = 0; $x < count($test); $x++) {
>>> $query .= "column = '".$test[$x]."'";
>>> if($x < (count($test) + 1)) $query .= ", ";
>>>}
>>>$query .= "WHERE foo = 'bar'";
>>>
>>>You mean like that?
>>>
>>>John
>>>
>>
>>
>> Don't forget to add a space between columns:
>>
>> ....
>> $query .= "column = '".$test[$x]." '";
>> ...
>
> This will put a space at the end of the string being inserted into the
> database. I doubt that's the desired effect. From his setup, I'd say the
> space would be better off in front of the WHERE keyword, like so:
>
> $query .= " WHERE foo = 'bar'";
You're quite right, my space was in the wrong place. What I was getting at
is that the query would output columns like this:
.... column_a = 'foo'column_b='bar' ...
The space should appear after each column, since the for() suggests the
possible use of multiple update fields:
$query .= "column = '".$test[$x]."' ";
Navigation:
[Reply to this message]
|