rugzo Posted May 1, 2009 Share Posted May 1, 2009 Hi all, i have a query in my select option, it queries the x column in the database and builds the select list. But my problem is that it is also showing empty columns. How can i modify my query so it only shows the columns with values and skipps the empty ones? Thanks... <select class="input" name="project" > <option value=""><?=$row->project?></option> <?php $ara = "SELECT * FROM listings ORDER BY project" ; $cak = mysql_query($ara); while ($don = mysql_fetch_array($cak)) { ?> <option value="<?php echo $don[project] ; ?>" ><?php echo $don[project] ; ?>"</option> <?php } ?> </select> Link to comment https://forums.phpfreaks.com/topic/156403-solved-skipping-empty-values/ Share on other sites More sharing options...
Prismatic Posted May 1, 2009 Share Posted May 1, 2009 Without knowing your table structure, this should work. <select class="input" name="project" > <option value=""><?=$row->project?></option> <?php $ara = "SELECT * FROM listings ORDER BY project" ; $cak = mysql_query($ara); while ($don = mysql_fetch_array($cak)) { if($don['project']) echo "<option value=\"". $don['project'] ."\"> ". $don['project'] ."</option>"; } ?> </select> Also this <select class="input" name="project" > <option value=""><?=$row->project?></option> <?php $ara = "SELECT * FROM listings WHERE project != "" ORDER BY project" ; $cak = mysql_query($ara); while ($don = mysql_fetch_array($cak)) { echo "<option value=\"". $don['project'] ."\"> ". $don['project'] ."</option>"; } ?> </select> Link to comment https://forums.phpfreaks.com/topic/156403-solved-skipping-empty-values/#findComment-823417 Share on other sites More sharing options...
rugzo Posted May 1, 2009 Author Share Posted May 1, 2009 Thanks, the first one solved it Link to comment https://forums.phpfreaks.com/topic/156403-solved-skipping-empty-values/#findComment-823493 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.