Message for 0 Records Found

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: Message for 0 Records Found

    if ($data = mysql_fetch_array($result)) {
    echo "<table>\n"
    do {
    echo "<tr>";
    echo "<td>".$data['dataset1']."</td>\n";
    echo "<td>".$data['dataset2']."</td>\n"; /* Add more datasets if
    needed */
    echo "</tr>\n";
    } while ($data = mysql_fetch_array($result));
    echo "</table>\n";
    } else {
    echo "No Records Found\n";
    };


    --
    Your GP or your HP!
    Warren Butt

    "entoone" <entoone@pacbell.net> wrote in message
    news:8izXa.705$cV.58022018@newssvr21.news.prodigy. com...
    > This code works so far to return values if there are records that match
    the
    > query, but how can I have a message displayed to the user, should there be
    > no records found? Thanks in advance.
    >
    > <?
    > include("searchbyst.php");
    > ?>
    >
    > <?php
    >
    > /* This script gets results from db, and then formats a table with
    title
    > headers and rows of data */
    >
    > /* Returns name, phone and record id number and sorts by name -
    > searchable for name and phone
    >
    > /* Connecting, selecting database */
    >
    > $link = mysql_connect("localhost", "lister", "2332400")
    >
    > or die("Could not connect");
    >
    > mysql_select_db("nlisting") or die("Could not select database");
    >
    >
    > /* Performing SQL query */
    >
    > $query = "SELECT * FROM contacts23 where state='$searchstate' order by
    > hcounty";
    >
    > $result = mysql_query($query) or die("Query failed");
    >
    >
    >
    > /* Printing results in HTML */
    >
    > print "<center>\n";
    >
    > print "<table border=1 cellpadding=2 cellspacing=5>\n";
    >
    > print "\t<tr bgcolor=#000000>\n";
    >
    > {
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >First</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >Last</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >County</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >State</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >Phone</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >Mobile</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >Fax</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#ffffff face=Tahoma
    > size=2 >Profile</td>\n";
    >
    > }
    >
    > print "\t</tr>\n";
    >
    > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    >
    >
    > print "\t<tr>\n";
    >
    > {
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[first] </td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[last]</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[hcounty]</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[state]</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[phone]</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[mobile]</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 >$line[fax]</td>\n";
    >
    > print "\t\t<td><bgcolor=#000000><font color=#000000 font
    > color=#000000 face=Tahoma size=2 ><A
    href='show.php?searchid=$line[id]'>More
    > Info</td>\n";
    >
    >
    >
    >
    >
    > }
    >
    > print "\t</tr>\n";
    >
    > }
    >
    > print "</table>\n";
    >
    >
    >
    > /* Free resultset */
    >
    > mysql_free_result($result);
    >
    >
    >
    > /* Closing connection */
    >
    > mysql_close($link);
    > ?>
    >
    > <p>&nbsp;</p>
    >
    > <div align="center">
    >
    > <center>
    >
    > <p></p>
    >
    > </center>
    >
    > </div>
    >
    >

    DjDrakk Guest

  2. Similar Questions and Discussions

    1. CF: change File not found message
      We have a server with Cold Fusion MX 7, IIS6 and Windows 2003 Web Edition. One of our clients was running their Cold Fusion based ecommerce...
    2. No records found for MySQL Table
      Hello, We have a MySQL table that we had been using PHP to query, but now we want to query the table using CF 5.0 on a windows 2000 server. The...
    3. Found Records
      is there a function that allows you to distinguish between found and omitted records? For example, a certain field = 0 for omitted, 1 for in the...
    4. [PHP] Form variables lost when duplicate records are found !
      --- Pushpinder Singh Garcha <pgarcha@adelphia.net> wrote: Of course. However, I don't understand what you need help with. There are many...
    5. [PHP] Form variables lost when duplicate records are found!
      then the forms variables are stored and NOT LOST ?? Have you looked into sessions? http://www.php.net/manual/en/ref.session.php
  3. #2

    Default Re: Message for 0 Records Found

    I got it.. durr.. I'm tired.. is there a way to center the response? I know
    I'm asking alot, but just having a little trouble in a few areas. Thansk
    again MeerKat!

    "MeerKat" <liquidlaughter2000@blueyonder.co.uk> wrote in message
    news:xwzXa.41$Hm4.15@news-binary.blueyonder.co.uk...
    > entoone wrote:
    > > This code works so far to return values if there are records that match
    the
    > > query, but how can I have a message displayed to the user, should there
    be
    > > no records found? Thanks in advance.
    > [snip]
    > >
    > > $query = "SELECT * FROM contacts23 where state='$searchstate' order
    by
    > > hcounty";
    > >
    > > $result = mysql_query($query) or die("Query failed");
    > >
    > if (mysql_num_rows($result) > 0) {
    > // print your table;
    > } else {
    > print "Sorry, no results";
    > }
    >
    >
    > --
    > MeerKat
    >

    entoone Guest

  4. #3

    Default Re: Message for 0 Records Found

    entoone wrote:
    > I got it.. durr.. I'm tired.. is there a way to center the response? I know
    ....
    print "<center>Sorry, no results</center>";
    ....

    (obviously stylesheets would be better but given you've used <center>
    before then what the heck... :) )
    > I'm asking alot, but just having a little trouble in a few areas. Thansk
    > again MeerKat!
    >
    > "MeerKat" <liquidlaughter2000@blueyonder.co.uk> wrote in message
    > news:xwzXa.41$Hm4.15@news-binary.blueyonder.co.uk...
    >
    >>entoone wrote:
    >>
    >>>This code works so far to return values if there are records that match
    >
    > the
    >
    >>>query, but how can I have a message displayed to the user, should there
    >
    > be
    >
    >>>no records found? Thanks in advance.
    >>
    >>[snip]
    >>
    >>> $query = "SELECT * FROM contacts23 where state='$searchstate' order
    >
    > by
    >
    >>>hcounty";
    >>>
    >>> $result = mysql_query($query) or die("Query failed");
    >>>
    >>
    >>if (mysql_num_rows($result) > 0) {
    >>// print your table;
    >>} else {
    >>print "Sorry, no results";
    >>}
    >>
    >>
    >>--
    >>MeerKat
    >>
    >
    >
    >
    --
    MeerKat

    MeerKat Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139