SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    844
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    mySQL Workbench gives different results than my webpage

    All emails that my website sends out are stored in the notifications table. Every half hour up to 500 at a time will be emailed out. Here is the query I'm using:

    select priority, type, count(*) as total from notifications where sent is null group by type order by priority;

    The results indicate there are 37 "Matched from Search" type emails AND 2 "Stop Alerts" type emails waiting to be sent out. Here is my php code that I'm using on my Admin Tools webpage so I can easily see what is waiting to go out from the notifications table:

    PHP Code:
    $emailsWaiting "select priority, type, count(*) as total from notifications where sent is null group by type order by priority";

    $results mysql_query ($emailsWaiting) OR die(mysql_error());
    $row mysql_fetch_assoc($results);

    if (
    $row mysql_fetch_array($results)) {

    print (
    "<br><br>");

    print (
    "<TABLE align='center' cellpadding='3' cellspacing='3' WIDTH='50%' border='1'>");

    print (
    "<TR>");
    print (
    "<TH>Priority</TH>");
    print (
    "<TH>Type</TH>");
    print (
    "<TH>Waiting</TH>");
    print (
    "</TR>");


    do {

    $priority  $row["priority"];
    $type         $row["type"];
    $total      $row["total"];


    $totalCount $totalCount $total;

    print (
    "<TR>");
    print (
    "<TD align='center'>$priority</TD>");
    print (
    "<TD align='center'>$type</TD>");
    print (
    "<TD align='center'>$total</TD>");
    print (
    "</TR>");

    } while (
    $row mysql_fetch_array($results));

    print (
    "<TR>");
    print (
    "<TD colspan='3' align='center'>Total Emails: $totalCount</TD>");
    print(
    "</TR>");

    print (
    "</Table>");
    print (
    "</form>");

    } else {

    print (
    "<br><p>There are no emails waiting to go out.</p>");

    When I view this webpage it indicates that there are 2 "Stop Alerts" emails waiting to go out, BUT that is all. Why aren't the 37 "Matched from Search" type emails showing up? So in summary, I'm confused why running the query in mySQL WorkBench shows one set of results, while my webpage is showing something different.

    Thank you.
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    You might want to just switch to a regular while and do the if check on mysql_num_rows ... but that shouldnt really have an effect on the output so far as i can see...

    is mySQL Workbench connecting to the database you're running this query on, or a local copy?

  3. #3
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    844
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What do you mean a "regular while" ? Do you have any other thoughts?
    Convert your dollars into silver coins. www.convert2silver.com


Bookmarks

Posting Permissions

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