Re: exclude - mysql query
| From: | David Robley | Date: | Mon, 29 Nov 2004 03:19:16 +0000 |
| Subject: | Re: exclude - mysql query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203046@lists.php.net to get a copy of this message | ||
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?