Re: php-db Query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Peppe

Don't search by month at all - use a start and stop date then order by date.

Now you have one result set with all the dates in it and you can use your
PHP code to figure out where to close one table and open a net one:

 $result = mysql_query($sql);

 echo "<TABLE>";
  $thisMonth = $result[3];  // I'm assuming this is a month year combo
                            // you'll have to do more work here.

 while (!$result ->EOF)
    {
        if ($thisMonth != $result[3]) {
               
            $thisMonth = $result[3];
            echo '</TABLE><TABLE>';
        }
        echo '<TR>' . $result[0] . '</TD><TD> ' . $result[1] . '</TD></TR>';

        $result->MoveNext(); // Moves to the next row

    } // end while
 echo "</TABLE>";


> 
>       $rowArray = mysql_fetch_array($result);
>       $datum        = $rowArray["datum"];
>       $title           =    $rowArray["title"];
>       $datum        = date("d-m-Y", strtotime($datum));
> $datum is 20-02-2004

On 2/24/04 8:20 AM, "php-db-digest-help@xxxxxxxxxxxxx"
<php-db-digest-help@xxxxxxxxxxxxx> wrote:

> 
> From: "peppe" <peppe1001@xxxxxxxxxxx>
> Reply-To: "peppe" <peppe1001@xxxxxxxxxxx>
> Date: Tue, 24 Feb 2004 17:20:19 +0100
> To: php-db@xxxxxxxxxxxxx
> Subject: Query
> 
> Hi I have this query
> $sql = "SELECT * FROM events WHERE ( YEAR(datum) = '" . $year . "') ORDER BY
> datum ASC";
> $result = mysql_query($sql);
> $numRows  = mysql_num_rows($result);
> for ($row = 1; $row <= $numRows; $row++) {
> 
>       $rowArray = mysql_fetch_array($result);
>       $datum        = $rowArray["datum"];
>       $title           =    $rowArray["title"];
>       $datum        = date("d-m-Y", strtotime($datum));
> $datum is 20-02-2004
> ?>
> I want to show here the events by month for example table with events of
> 02(February) then if there are events from 03(March) another table and so
> one
> How can I make this work do I need to make another query
> Any idea
> 


-- 
Frank Flynn
Poet, Artist & Mystic

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux