php - how to skip entries that are NULL in MySQL -


i'm having trouble 2 things on news feed.

i'm trying news feed show database entries, don't have date because sort of sticked news feeds aren't date related. problem still pushes enter/empty line those. how can make feed skip date column if there no date entry in id, still show news?

and second question, how can add span class date returning feed?

this code loading database:

<?php                    // grab data our people table                  $sql = "select * news order id desc";                 $result = mysql_query($sql) or die ("could not access db: " . mysql_error());                  while ($row = mysql_fetch_assoc($result))                 {                     echo "<div class=\"newsstory\">";                     echo "<p>";                     echo $row['date'] . " " . "<br />";                     echo $row['news'];                     echo "</p>";                     echo "</div>";                 }               ?> 

thanks guys!

edit: might upload script uploads empty space when nothing entered, added upload script sure:

<?php  // call our connection file require("includes/conn.php");  $date=$_post['date']; $news=$_post['news'];  $query="insert news (date, news) values ('$date', '$news')";    mysql_query($query) or die ('error updating database');    echo "database updated '$date', '$news'"; ?> 

just replace

echo $row['date'] . " " . "<br />"; 

with

echo !empty($row['date']) ? ("<span>". $row['date'] . " </span><br />") : ''; 

this way you'll still display news, date line displayed news having not null date.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -