troubleshooting Question

Query Issue

Avatar of Robert Granlund
Robert GranlundFlag for United States of America asked on
4 Comments1 Solution293 ViewsLast Modified:
I what the php to print this form and have the selections be in a specific order.  However, the following php prints the options in a random order.  The "Other" option, always seems to be printed as the second or third choice instead of the last choice.  Any ideas?

	$q = "SELECT exp_weblog_data.entry_id, exp_weblog_titles.entry_id, exp_weblog_data.field_id_308, exp_weblog_titles.entry_date, exp_weblog_data.field_id_195 FROM exp_weblog_data, exp_weblog_titles WHERE (exp_weblog_data.field_id_308 IS NOT NULL and length(exp_weblog_data.field_id_308) >= 3) AND exp_weblog_data.entry_id=exp_weblog_titles.entry_id AND exp_weblog_data.field_id_195='ARCHIVE' GROUP BY exp_weblog_data.field_id_308 ORDER BY
WHEN exp_weblog_data.field_id_308='red' THEN 1
WHEN exp_weblog_data.field_id_308='white' THEN 2
WHEN exp_weblog_data.field_id_308='bluer' THEN 3
WHEN exp_weblog_data.field_id_308='other' THEN 4 END";
	$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
	if (mysqli_num_rows($r)) {  //  MAIN IF  //

<form method="GET" action="MY ACTION/">
<h5>SEARCH BY COLOR</h5> <select name="guitar" style="width:100px;border:solid 1px #717171;background-color:#343333;color:#717171;">
		while ($row=mysqli_fetch_assoc($r)) { //  WHILE  
			$guitar = $row['field_id_308'];

				if($guitar=="red") { 
					echo "<option name=\"guitar\" value=\"red\">red</option>";
				if($guitar=="white") { 
					echo "<option name=\"guitar\" value=\"white\">white</option>";
				if($guitar=="blue") { 
					echo "<option name=\"guitar\" value=\"blue\">blue</option>";
				if($guitar=="Other") { 
				echo "<option name=\"guitar\" value=\"Other\">Other</option>";

			}  //  END WHILE
<br />
<input type="submit" name="submit" value="go" />

Open in new window

Francisco Igor
Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros