Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

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.

left Zymic Webmaster ForumsWeb Design & DevelopmentServer Side ScriptingPHP right
  Closed Topic Start new topic
left right
The Seventh Hoka...
post 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>";
Go to the top of the page 
 
  + Quote Post
Ed
post 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
Go to the top of the page 
 
  + Quote Post
 Closed Topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 22nd May 2013 - 05:26 PM