Help - Search - Members - Calendar
Full Version: Code Question- Populating A List
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
The Seventh Hokage
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>";
Ed
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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.