budimir Posted August 4, 2008 Share Posted August 4, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/ Share on other sites More sharing options...
lemmin Posted August 4, 2008 Share Posted August 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-607884 Share on other sites More sharing options...
ainoy31 Posted August 4, 2008 Share Posted August 4, 2008 where is variabels $ime and $prezime coming from? Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-607886 Share on other sites More sharing options...
php_dave Posted August 4, 2008 Share Posted August 4, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-607973 Share on other sites More sharing options...
ohdang888 Posted August 4, 2008 Share Posted August 4, 2008 <?php $upit = mysql_query("SELECT * FROM korisnici"); while ($row = mysql_fetch_array($upit)){ $ime = $row['NAME']; echo "<option value='".$ime." id=".$prezime."'>".$ime." ".$prezime."</option>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-608002 Share on other sites More sharing options...
budimir Posted August 5, 2008 Author Share Posted August 5, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-608528 Share on other sites More sharing options...
ohdang888 Posted August 5, 2008 Share Posted August 5, 2008 just do it how it makes sense to you... for example, i'd use: <option value="ALL">Everyone</option> and on the form handler, put something like if($_POST['select name here'] == "ALL"){ get all the records from the DB } Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-608615 Share on other sites More sharing options...
budimir Posted August 5, 2008 Author Share Posted August 5, 2008 OK, thanks, I got an idea! Quote Link to comment https://forums.phpfreaks.com/topic/118146-solved-select-box-displaying-everything/#findComment-608727 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.