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

Posted by Joseph Melnick on 05/27/05 18:56

Hello Cover,

$query = "select * from table where 1 = 1 ";
if($name != "") $query .= "and name = '".$name."'";
if($month != "") $query .= "and month = '".$month."'";
if($year != "") $query .= "and year = '".$year."'";

Joseph Melnick
JM Web Consultants
http://www.jphp.com





"cover" <coverland914 @ yahoo.com> wrote in message
news:1117203234.674c2d5cd748bf86b45f941e0b1cb1fb@teranews...
>I have a form with drop down menus to query for name, month, and year
> to capture activity accordingly by an individual for a given month and
> given year. But I'd like to also be able to query ALL individiduals
> for a given month and year OR an individual for the whole year for
> example.
>
> My question, is there any way to have blank (not filled in) fields of
> a query input ignored when left blank? I'm currently doing very
> successfully what I described in the para above but it's taking me 3
> queries (which I have on the same sheet for simplicity) to do it when
> it would look a lot neater to have a single query and leave any drop
> down menu items that I don't want to include on the query, blank and
> ignored. Any ideas? TIA

 

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

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