invisible items..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

invisible items..

Post by apek »

i have problems with my combobox...
heres the snippet:

Code: Select all

$query2 = "Select left(idMinor,1) from ".$DBprefix." tPartMinor where left(idMinor,1)='$minor' group by idMinor";
	$result2 = mysql_query($query2);
			while ($dbq2 = mysql_fetch_array($result2)) {
			echo("<option value=$dbq2&#1111;idMinor]selected>$dbq2&#1111;idMinor]</option>\n");
			&#125;
when i view in browser,all the items seems invisible from users...
it canbe selected but i can't see what is that...
why do this happen??
is there any wrong with my code?
how to fix this???
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

Hm first of all you should test what you have received from that sql and only then make fetch.
It is probably a mysql query problem
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Sidenote, you also need to work on how to close the values in the form, as example below:

Code: Select all

$dbq2['idMinor'] = "FOO"; // setting it temp. to demonstrate...
// your way...
echo("<option value=$dbq2[idMinor]selected>$dbq2[idMinor]</option>\n");
/*
 Returns: <option value=FOOselected>FOO</option>
*/

// better...
echo("<option value="$dbq2[idMinor]" selected>$dbq2[idMinor]</option>");
// or
echo('<option value="'.$dbq2['idMinor'].'" selected>'.$dbq2['idMinor'].'</option>');
/*
 Returns: <option value="FOO" selected>FOO</option>
*/
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

........

Post by apek »

i tried both of them Jam...
but still the same...
but when i replace the SQL statement with the simple one like

Code: Select all

Select idMinor from tPartMinor;
theres no problem with it...

but when i replace with the SQL statement with some operation like in my previous post,then the invisible thing happens...

Code: Select all

"Select LEFT(idMinor,1) from ".$DBprefix." tPartMinor where LEFT(idMinor,1)='$minor' group by idMinor";

maybe its the mysql things,but i dunno what...

FYI,the $minor variable comes from the submit form before...(POST operation)...

so pls help me with this...
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

............

Post by apek »

ahaa!!!
i fixed that...
its mysql problem..
i replace the sql statement

Code: Select all

$query2 = "Select LEFT(idMinor,1) from ".$DBprefix." tPartMinor where LEFT(idMinor,1)='$minor' group by idMinor";
with

Code: Select all

$query2 = "Select idMinor from ".$DBprefix." tPartMinor where LEFT(idMinor,1)='$minor' group by idMinor";
then its ok...

but now another problem rise...
the parameter passed from the submit form is wronged and now my combobox only show the same item all time...in fact it should give output chose by user...
you can view my problem details here:
viewtopic.php?t=16536
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Read up on my post again (about how to quote values). I wrote sidenote as it was not about your original problem, but this particular one.
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

....

Post by apek »

jam..for my wrong passed parameter problem........
i tried both of them...

Code: Select all

// better...
echo("<option value="$dbq2[idMinor]" selected>$dbq2[idMinor]</option>");
// or
echo('<option value="'.$dbq2['idMinor'].'" selected>'.$dbq2['idMinor'].'</option>');
/*
Returns: <option value="FOO" selected>FOO</option
but still the same...
the parameter passing is still wrong...
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

You get $minor from a form?
If so, are you using $_POST['minor'] or simply $minor whereever it is used?
User avatar
apek
Forum Commoner
Posts: 96
Joined: Tue Jan 06, 2004 11:19 pm
Location: Holiday Plaza Johor Bahru

............

Post by apek »

FYI...
i did this at the bottom of the second page...

Code: Select all

$minor = $HTTP_POST_VARS["front"];
hope this will clarify u...
Post Reply