how to display the count of the records associated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geraldjr30
    New Member
    • Jan 2009
    • 60

    #1

    how to display the count of the records associated

    hi,

    i have the following, which lists days of the week, and records associated with each of them from an MS Access table. i would like to know how to display the count of the records associated with each day instead of the separate associated records.

    [code=php]
    <?php
    $test = array('sunday count','monday count','tuesday count','wednesd ay count','thursda y count','friday count', 'saturday count');
    $day=date('w'); //Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
    $key=each($test );
    while ($key['key']!=$day)
    $key=each($test );
    prev($test);
    prev($test);
    for ($i=0;$i<7;$i++ )
    {
    $count = (next($test)) ? current($test) : reset($test);


    ############### ############### ############### ####
    #DETAIL SECTION
    ############### ############### ############### ####
    print "details: <br>";
    $conn=odbc_conn ect('TEST','',' ');
    if (!$conn)
    {exit("Connecti on Failed: " . $conn);}
    $sql="SELECT * FROM tbl_news WHERE dayname ='".$count."' ";
    $rs=odbc_exec($ conn,$sql);
    if (!$rs)
    {exit("Error in SQL");}

    while (odbc_fetch_row ($rs))
    {
    $news=odbc_resu lt($rs,"infosec tion");
    echo "$news";

    }

    ############### ############### ############### ####
    # END OF DETAIL SECTION
    ############### ############### ############### ####

    echo $count.'<br />';
    }
    ?>
    [/code]

    thanks in advance,
    geebee
    Last edited by Atli; Jan 9 '09, 04:49 PM. Reason: Added [code] tags
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, geebee.

    PHP: odbc_num_rows - Manual

    Comment

    • geraldjr30
      New Member
      • Jan 2009
      • 60

      #3
      count

      hi,

      i have the following.. and i have odbc connection to MS Access database.

      Code:
      <html>
      <body><?php
      $conn=odbc_connect('TEST','','');
      if (!$conn)
        {exit("Connection Failed: " . $conn);}
      $sql="SELECT distinct dayname, shift, infosection  FROM tbl_news WHERE dayname = 'sunday' ORDER BY shift";
      $rs=odbc_exec($conn,$sql);
      #$TT = odbc_fetch_into($rs, $count, 1);
      
      if (!$rs)
        {exit("Error in SQL");}
      echo "<table><tr>";
      echo "<th>dayname</th>";
      echo "<th>shift</th>";
      echo "<th>COUNT</th></tr>";
      while (odbc_fetch_row($rs))
      {
        $DYNAME=odbc_result($rs,"dayname");
        $SFT=odbc_result($rs,"shift");
        $N4SC=odbc_result($rs,"infosection");
       
        echo "<tr><td>$DYNAME</td>";
        echo "<td>$SFT</td></tr>";
        #echo "<td>$SFT</td><td>$TT</td></tr>";
      
      }
      odbc_close($conn);
      echo "</table>";
      ?></body>
      </html>

      i would like to know how i can display a count listing how many records are for each shift and day.

      thanks in advance,
      geebee
      Last edited by Markus; Jan 13 '09, 03:02 PM. Reason: Added [code] tags.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        geraldjr30,

        Please read your Personal Messages.

        Comment

        Working...