Re: exclude - mysql query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 29 Nov 2004 10:58, Brad Ciszewski wrote:

> i have several tables with data, and they all have a server column. there
> are a few tables which i need to exclude a particular server from that
> table. i am currently running an array to extract the data, and was
> wondering if i could either use PHP code or a mysql-query exclude function
> or something so these servers are available. below is the php script i
> currently have... which needs the excluding script/query.
> 
>         <select name="s1" id="s1">
>           <?PHP
> // List servers from game \\
> $get_servers = mysql_query("SELECT * FROM game_$game ORDER BY server
> ASC"); while($gs=mysql_fetch_array($get_servers)){
> extract($gs);
> echo ?>
>           <option value="<?PHP echo($server); ?>"><?PHP echo($server);
> ?></option>
>           <?PHP } ?>
>         </select>
> 
> any ideas at all?

Seems to me there are at least two ways to do it. For the php solution, test
the value of $server in the above while loop and if the value matches a
list of exclusions, don't echo the value.

For mysql, in the select use WHERE NOT IN('a','b'...) for a comma separated
list of exclude values, or simply WHERE server <> 'badname' for one server.

You may find this a useful reference:

http://dev.mysql.com/doc/mysql/en/Tutorial.html

-- 
David Robley

Do vegetarians eat animal crackers?

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux