You are here: Re: Multiple Categories « PHP SQL « IT news, forums, messages
Re: Multiple Categories

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация