Hiya all,

Stock standard, and from most of the examples I've seen, standard MySQL
lookups via PHP utlises a while look to retrieve the data.  All very nice
and well yes... But what if there is no data?

Here's a little example of what I want to do...

    // Check for inportaint notices for the contact.
    echo "<table width=\"100%\" class=\"td\">\n";
    echo "  <tr>\n";
    echo "    <td colspan=\"2\" valign=\"top\" class=\"subhead\">\n";
    echo "      <b><u>Important notes:</u></b><br>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    $SQL = mysql_query("SELECT MessageID, MessageTitle FROM contactmessages
WHERE ContactID='" . $_SESSION['ContactID'] . "' AND MessageRead='n';");
    while ($ContactMessageList = mysql_fetch_array($SQL)) {
      echo "  <tr>\n";
      echo "    <td align=\"left\" valign=\"top\"><a
href=\"/profile/readmsg.php?MessageID=" . $ContactMessageList['MessageID'] .
"\" alt=\"Read Message\" border=\"0\"><img src=\"/lib/images/arrow.gif\"
      echo "    <td align=\"left\" valign=\"top\">" .
$ContactMessageList['MessageTitle'] . "</td>\n";
      echo "  </tr>\n";
    echo "</table>\n";
    echo "<br>\n";

>From this example, this "block" would be printed evertime.  Whether the
contact has actual messages or not.  How would I go about in a instance like
this, to use a MySQL check and only print the block if $SQL will actually
return data ?

In this case, can I do something like...

if ($SQL = mysql_query("something") {
  print the block
  while (do the actualy mysql lookup) {
    print data

Spanks everyone :)


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to