Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-07-2008, 10:40 AM   PM User | #1
jdimino
New Coder

 
Join Date: Dec 2005
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
jdimino is an unknown quantity at this point
list only what is false

Hi

Can someone tell me how to list only what is false for field "Bloom_Name" instead of all.
Thanks


<?PHP
mysql_connect("localhost", "ixxx_xxx", "jxxx") or die(mysql_error());
mysql_select_db("ixxxx_rxxx") or die(mysql_error());
$sql = "SELECT * FROM `ihsreg` ORDER BY `Bloom_Name` ASC";
if (!(@ $result = mysql_query($sql))) {
print "There was an error running your query:<p>\n". $sql . "<p>\n";
}

print '<select name="Bloom_Name"
onchange="Search_box.value=this.options[this.selectedIndex].text"><br>\n';
print '<option value="#"> Choose One ';


while ($row = mysql_fetch_row($result)) {
$id = $row[0];
$Bloom_Name = $row[3];

print "<option value=\"$id\"";
if ($_REQUEST["Bloom_Name"] == $id) { print " selected"; }

print "> $Bloom_Name <br>\n";
}
print '</select>';

?>
jdimino is offline   Reply With Quote
Old 08-07-2008, 11:04 AM   PM User | #2
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
Use the "where" clause in the MySQL e.g. "SELECT * FROM `ihsreg` WHERE Bloom_Name!='false' ORDER BY `Bloom_Name` ASC" now if it's 0 and 1 you'll have to change it.. or something like that probably wrong tho

Last edited by Iszak; 08-07-2008 at 11:10 AM..
Iszak is offline   Reply With Quote
Old 08-07-2008, 02:45 PM   PM User | #3
jdimino
New Coder

 
Join Date: Dec 2005
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
jdimino is an unknown quantity at this point
I've tried, but it continues to list all values.

<?PHP
mysql_connect("localhost", "xxxx_xxxx", "xxxx") or die(mysql_error());
mysql_select_db("xxxx_xxxx") or die(mysql_error());
$sql = "SELECT * FROM `ihsreg` WHERE Bloom_Name!='false' ORDER BY `Bloom_Name` ASC";
if (!(@ $result = mysql_query($sql))) {
print "There was an error running your query:<p>\n". $sql . "<p>\n";
}

print '<select name="Bloom_Name"
onchange="Search_box.value=this.options[this.selectedIndex].text"><br>\n';
print '<option value="#"> Choose One ';


while ($row = mysql_fetch_row($result)) {
$id = $row[1];
$Bloom_Name = $row[3];

print "<option value=\"$id\"";
if ($_REQUEST["Bloom_Name"] == $id) { print " selected"; }

print "> $Bloom_Name <br>\n";
}
print '</select>';

?>
jdimino is offline   Reply With Quote
Old 08-07-2008, 02:48 PM   PM User | #4
derzok
Regular Coder

 
Join Date: May 2008
Location: Ohio
Posts: 231
Thanks: 3
Thanked 21 Times in 21 Posts
derzok is an unknown quantity at this point
Are the values in that column that you're avoiding equal to the string 'false'? Or do you mean "false" as in "it's not set" or "it's null" - because there's a big difference. If you have phpmyadmin, browse the table and find whether it's NULL, an empty string, or a string "false" (or something else).
__________________
zok@zoklet:~$ whereis zok
zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com
derzok is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:49 AM.


Advertisement
Log in to turn off these ads.