You are here: Re: Query Question « PHP Language « IT news, forums, messages
Re: Query Question

Posted by Kimmo Laine on 05/28/05 00:05

"jedihawk" <jedihawk@gmail.com> kirjoitti
viestiss�:1117217889.720396.47310@g47g2000cwa.googlegroups.com...
>I don't see anything wrong with that code. Because you're appending to
> the $query var, it's just one single SQL query.
>
> BTW, I think your code would be slightly more efficient if you used
> this syntax:
>
> if( $name != '' ) $query .= "and name = '$name'";
>

Forgetting spaces here...

Something more like
if( $name != '' )
$query .= " and name = '$name' "; // padding string with some spaces

So the final query won't be
"select * from table where 1 = 1 and name = '$name'and month = '$month'and
year = '$year'";

but rather
"select * from table where 1 = 1 and name = '$name' and month = '$month'
and year = '$year' ";



--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

eternal.erectionN0@5P4Mgmail.com

 

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

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