Re: bug in code - can't find it!

From: Date: Thu, 07 Aug 2003 02:02:48 +0000
Subject: Re: bug in code - can't find it!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-158591@lists.php.net to get a copy of this message
just a little point; u can replace <?echo $search_result2[a.retired_flag]?> by <?=$search_result2[a.retired_flag]?> which is better imho. ---- AciD On Wed, 6 Aug 2003 14:57:23 -0700, Jennifer Goodie <goodie@apollointeractive.com> wrote:
Ok, here is my query and the bit of code I can't figure out: $query = "SELECT * from apt_user_t a, apt_company_t b "; $query .= "WHERE a.user_cd = b.user_cd "; $query .= "ORDER BY a.username"; $search_results = mysql_query($query) or die("Select Failed!"); while ($search_result2 = mysql_fetch_array($search_results)) { <INPUT TYPE="checkbox" NAME="<? echo $search_result2['user_cd'];?>" SIZE="20" MAXLENGTH="50" VALUE="<?if ($search_result2[a.retired_flag] == 1){?>CHECKED<?}?>"> <?echo $search_result2[a.retired_flag]?> } Nothing shows up with the echo or the value. I only included this checkbox, but all of the other values show up fine. Can someone give me a hint?
Mysql does not prefix returned columns with table_name., so there's probably no "a.retired_flag" index in your array. A simple way to check this would be to print_r($search_result2). If you have a column named retired_flag in both table a and table b and you specifically want the one from table a in your result set you are going to have to alias it to a different name in your query, i.e. "SELECT *, a.retired_flag as r_flag"
-- www.cpm-fr.com

« previous php.general (#158591) next »