Jump to content

[SOLVED] Select box displaying everything???


budimir

Recommended Posts

Hey guys,

 

I need small help

 

How can I make select box to show all the records from the db, not only what is selected???

 

Here is my code!!

 

<select name="korisnik" id="korisnik">
<option value="">Svi</option>
<?php 
  $upit = mysql_query("SELECT * FROM korisnici");
while ($row = mysql_fetch_array($upit)){

while(list($key,$val) = each($row)){
	if (is_int($key)) continue;
	$GLOBALS[$key] = $val;
	}
         echo "<option value='".$ime." ".$prezime."'>".$ime." ".$prezime."</option>";
}
?>
</select>

Link to comment
https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/
Share on other sites

The loop in the middle doesn't make any sense; I would think that would be an endless loop. each($row) is going to return the same thing every time that loops.

 

Where do $ime and $prezime come from? If you use $row['field'] it will be from your query you just made.

If you mean you want a mulitple select box rather than a single combo box then add size=>1.. for example

 

<SELECT name='korisnik' id='korisnik' size='20'><options....></SELECT>

 

Obviously size can be altered to but just needs to be more than 1 to make it select box rather than a combo box.

 

This should really of been posted in the HTML section!

Hey guys,

 

Don't worry about the loop it's working perfectly. But my question is: How can I display all the records from DB if I select everyone???

 

For example:

 

Everyone //This is displaying the records for all the persons

John Doe //This is displaying only the records for John Doe

Jane Doe //This is displaying only the records for Jane Doe

 

<option value="What do I need to put here???">Everyone</option>

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.