Code Question- Populating A List |
||
Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.
In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.
Zymic Webmaster Forums Web Design & Development Server Side Scripting PHP |
||
![]() |
Code Question- Populating A List |
||
Sep 4 2009, 12:46 AM
Post
#1
|
|
![]() Member ![]() ![]() Group: Members Posts: 90 Joined: 29-May 09 Member No.: 97,073 |
i found some code and tinkered with it to get it to do what i need, namely to populate a dropdown list with db entries.
my problem is i would like to omit DB entries with the value of Null or simply nothing in them. here is my code. any suggestions on how i would do that. CODE echo "<select name='$learnedJInfo[$v]' id='$learnedInfo[$v]'>"; foreach($learnedInfo as $v) { if ($learnedInfo == $v) { echo "<option value='$v' selected='selected'>$v</option>"; } else { if($learnedInfo[$v]=="null") { } else { echo "<option value='$v'>$v</option>"; } } } echo "</select>"; |
|
|
Sep 4 2009, 12:56 AM
Post
#2
|
|
![]() Outrageously Uber Ninja ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Administrators Posts: 2,831 Joined: 11-March 07 From: UK Member No.: 9 |
Add in a clause to move to the next iteration in the loop:
CODE foreach($learnedInfo as $v)
{ $v = trim($v); if(empty($v)) continue; .... rest of loop |
|
|
![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users) |
||
| 0 Members: | ||
Forum Jump |
||
| Lo-Fi Version | Time is now: 22nd May 2013 - 05:26 PM |