Re: PHP Program Schedule

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

 



That wasn't real PHP code, just kinda an outline. I made some changes below, 
try that. 

You made a lot of variable assignments for no reason that I could see, so I 
removed them. Also your for and while syntax is wrong, check out the php 
manual for details on how to do this. 

 <?
 $connection = mysql_connect("*************","******","*******") or
 die("Couldn't make connection.");
 $db = mysql_select_db("*****", $connection) or die("Couldn't select
 database.");
 $sql = "SELECT *, (DAYOFWEEK(enddate)-DAYOFWEEK(startdate)+1) as numdays
 from schedule group by airtime order by airtime asc";
 $sql_result = mysql_query($sql,$connection) or die("Couldn't execute
 query.");
 echo "<table>";
 for ($i = 0; $i <= 48; $i++) {
     echo "<TR>";
     $airtime = $row["airtime"];
     list ($hour,$min,$sec) = explode(":", eregi_replace("[' '|-]",":", 
$airtime));
     $unix_timestamp = strtotime($airtime);
     $formatted_time = date("g:i A",$unix_timestamp);
     $timeslot = array("$formatted_time");
     echo "<TD ALIGN=\"center\" VALIGN=\"top\"><FONT FACE=\"Arial,
 Helvetica\"><B>$timeslot[0]</B></TD>";

 while ($row = mysql_fetch_assoc($airtime)) {
        $numdays = $row["numdays"];
        echo "<TD ALIGN=\"center\" VALIGN=\"top\" COLSPAN=$numdays><FONT
 FACE=\"Arial, Helvetica\">";
        echo $row["airshow"];
        echo "</FONT></TD>";
     }

     echo "</TR>";
 }

 mysql_free_result($sql_result);
 mysql_close($connection);
 ?>

On Tuesday 08 April 2003 6:50 am, Jay Fitzgerald wrote:
> Actually, now I am really lost....I'm a newbie at mysql and php so I tried
> my best at what I thought Micah was pointing out, but I get all kinds of
> errors and warnings....can someone help please? I will owe you a 12-pack
> :-)
>
> Here is my code which produces these:
> http://www.kcla-tv.com/admin2/help2.php:
>
> <?
> $connection = mysql_connect("*************","******","*******") or
> die("Couldn't make connection.");
> $db = mysql_select_db("*****", $connection) or die("Couldn't select
> database.");
> $sql = "SELECT *, (DAYOFWEEK(enddate)-DAYOFWEEK(startdate)+1) as numdays
> from schedule group by airtime order by airtime asc";
> $sql_result = mysql_query($sql,$connection) or die("Couldn't execute
> query.");
>
> for ($i = 0; $i <= 48; $i++):
>     echo "<TR>";
>     $airtime = $row["airtime"];
>     list ($hour,$min,$sec) = explode(":", eregi_replace("[' '|-]",":",
> $airtime));
>     $unix_timestamp = strtotime($airtime);
>     $formatted_time = date("g:i A",$unix_timestamp);
>     $timeslot = array("$formatted_time");
>     echo "<TD ALIGN=\"center\" VALIGN=\"top\"><FONT FACE=\"Arial,
> Helvetica\"><B>$timeslot[0]</B></TD>";
>
>     while ($row = mysql_fetch_assoc($airtime)):
>        $airid = $row["airid"];
>        $startdate = $row["startdate"];
>        $enddate = $row["enddate"];
>        $airtime = $row["airtime"];
>        $airshow = $row["airshow"];
>        $airlength = $row["airlength"];
>        $numdays = $row["numdays"];
>        $program = array("$airshow");
>        echo "<TD ALIGN=\"center\" VALIGN=\"top\" COLSPAN=$numdays><FONT
> FACE=\"Arial, Helvetica\">";
>        echo $row["airshow"];
>        echo "</FONT></TD>";
>     endwhile;
>
>     echo "</TR>";
> endfor;
>
> mysql_free_result($sql_result);
> mysql_close($connection);
> ?>
>
> At 05:59 PM 4/7/2003 -0700, Micah Stevens wrote:
> >Yes.. Do this:
> >
> ><table>
> ><tr>
> ><td><? // loop through the column headers here?></td>
> ></tr>
> ><?
> >  for (each time slot) {
> >         echo "<tr>";
> >         $data = (get db data for that timeslot)
> >         while ($d = mysql_fetch_assoc($data)) {
> >                 echo "<td>";
> >                 echo $d['your data'];
> >                 echo "</td>";
> >         }
> >         echo "</tr>";
> >}
> >
> ></table>
> >
> >see what I'm getting at?
> >
> >On Monday 07 April 2003 2:59 pm, Jennifer Goodie wrote:
> > > It seems that your table structure is bad.  Maybe put a border=1 in the
> > > table tag so you can see what is going on.  In my experience using the
> > > <tr> and </tr> tag to define what goes in which row is the way to go.
> > >
> > > > -----Original Message-----
> > > > From: Jay Fitzgerald [mailto:jayfitz@bayou.com]
> > > > Sent: Monday, April 07, 2003 2:58 PM
> > > > To: php-db@lists.php.net
> > > > Subject:  PHP Program Schedule
> > > >
> > > >
> > > > I am lost on this one...
> > > >
> > > > Example 1: http://www.kcla-tv.com/admin2/test.php
> > > > this looks fine on the frontend, except when you look at Example 2
> > > >
> > > > Example 2: http://www.kcla-tv.com/admin2/test2.php
> > > >
> > > > These shows (Living the Life Gerbert How Can I Live GDM Ministries
> > > > See Mores) are supposed to be on the next table row for the time
> > > > 6:00; however,
> > > > I cannot for the life of me figure out why this isnt working...
> > > >
> > > > Does anyone have any clues?
> > > >
> > > >
> > > > Jay Fitzgerald, Design Director - CPW-A, CPWDS-A, CPWDV-A, CECM-A,
> > > > CWCSB-A Bayou Internet - http://www.bayou.com
> > > > Toll Free: 888.30.BAYOU (22968)
> > > > Vox: 318.338.2034 / Fax: 318.338.2506
> > > > E-Mail: jayfitz@bayou.com
> > > > ICQ: 38823829 / AIM: bayoujf / MSN: bayoujf / Yahoo: bayoujf
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
> Jay Fitzgerald, Design Director - CPW-A, CPWDS-A, CPWDV-A, CECM-A, CWCSB-A
> Bayou Internet - http://www.bayou.com
> Toll Free: 888.30.BAYOU (22968)
> Vox: 318.338.2034 / Fax: 318.338.2506
> E-Mail: jayfitz@bayou.com
> ICQ: 38823829 / AIM: bayoujf / MSN: bayoujf / Yahoo: bayoujf


-- 
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