Jump to content

help needed with mysql syntax...


tomasd

Recommended Posts

Hi all,

I have table tuples which contain date and decimal values. i.e.

2008-09-01 25

2008-09-07 14

2008-09-10 17

Is there any way of doing select so it outputs following;

2008-09-01 25

2008-09-02 25

2008-09-03 25

2008-09-04 25

2008-09-05 25

2008-09-06 25

2008-09-07 14

2008-09-08 14

2008-09-09 14

2008-09-10 17

 

thanks for your help!!!

 

Link to comment
https://forums.phpfreaks.com/topic/126324-help-needed-with-mysql-syntax/
Share on other sites

try

<?php
$sql  = "SELECT tupledate, num
        FROM tuple
        ORDER BY tupledate";
$res = mysql_query($sql);
$prevd=$prevn='';
while (list($d, $n)=mysql_fetch_row($res))
{
    if ($prevd != $d)
    {
        if ($prevd != '')
        {
            $date = $prevd;
            while ($date < $d)
            {
                echo "$date $prevn<br/>";
                $date = date('Y-m-d', strtotime ("$date +1 days"));
            }
        }
        $prevd = $d;
        $prevn = $n;
    }
}
echo "$prevd $prevn<br/>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.