Jump to content

[SOLVED] echo echo? data base array


karyoker

Recommended Posts

Another little bug  driving me up the wall... With  this code it doesnt echo hardware.. Im putting in another drop down "category"and it doesnt print "category" but it does do the drop down..

 

Also if I put in a submit button what would the if code be to redirect in a tree fashion according to the selection?

<?PHP

print " Department: 
	  <select name=\"deptID\" size=\"1\">";
$query  = "SELECT id, name FROM _departments";
				   $result = mysql_query($query);

while(list($id, $name)= mysql_fetch_row($result))
{
   echo '<option value=\" . $id . \" selected="selected">' . $name . '</option><br>' . chr(10);

}
echo "hardware";

?>

Link to comment
https://forums.phpfreaks.com/topic/45195-solved-echo-echo-data-base-array/
Share on other sites

<?php

echo "Department: <select name=\"deptID\" size=\"1\">";

$result = mysql_query("SELECT id, name FROM _departments");

while(list($id, $name)= mysql_fetch_row($result)) {

   echo '<option value="'. $id . '" selected="selected">' . $name . '</option>' . chr(10);
   
}

echo "</select>";

echo " hardware";

?>

 

Result:

 

Department: <select name="deptID" size="1"><option value="1" selected="selected">Test 1</option>
<option value="2" selected="selected">Test 2</option>
</select> hardware

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.