Hmmmm..... There's no way to do it *without* having to submit two queries to the database? I'm thinking load wise here..... The query (or block), would be displayed on every single page in my app - sort of like a shared border type thing...
Now, when I have say, 20 pages in the site, 250 concurrent users (or active sessions) on the site - which, can happy very quickly - the load on the database is going to be -very- high.... So I'm kind of looking for a way how I can do this, with as few queries as possible, to put as little stress on the database as I can... But yes, if there is no otherway to do it, then I guess this would have to do.... Kind Regards, Chris Knipe MegaLAN Corporate InterNetworking Services Tel: +27 21 854 7064 Cell: +27 72 434 7582 ----- Original Message ----- From: "Nathan" <[EMAIL PROTECTED]> To: "Chris Knipe" <[EMAIL PROTECTED]> Sent: Monday, May 13, 2002 7:12 PM Subject: Re: [PHP] How *not* to assume MySQL will return data? > if (mysql_num_rows($query) > 0) { > print crud > } > else { > echo "Query succeeded, but produced no results"; > } > > Is that what you mean? > > > ----- Original Message ----- > From: "Chris Knipe" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, May 13, 2002 8:46 AM > Subject: [PHP] How *not* to assume MySQL will return data? > > > 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\" > border=\"0\"></td>\n"; > 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 :) > > -- > me > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php