php - help with table
Posted: Tue Oct 14, 2008 5:29 am
Hi all,
I am writing a program that will contain a table.
the table contains days of the week as columns and hours (starting 8 AM until 8 PM) as rows.
What I am trying to do is: When clicking a cell, a new page opens and gives us information regarding the specific day and hour.
My problem is that I can't seem to transfer day and time variables correctly.
I use SESSION and it always transfer the last day and time, no meter which cell I click.
My code:
<div align = 'center'>
<table border = 1 width = '100%' bgcolor = '#DCDCDC' >
<caption><EM><h3>מערכת השעות הסמסטריאלית</h3></EM></caption>
<tr>
<td></td>
<th scope="col">Sun</th>
<th scope="col">Mon</th>
<th scope="col">tue</th>
<th scope="col">wed</th>
<th scope="col">th</th>
</tr>
<tr>
<th scope="row">9:30 - 8:30</th>
<td onclick="<?php move(1,8) ?>" style="cursor:hand"><?PHP setCell(1,8,$courses) ?></td>
<td onclick="<?php move(2,8) ?>" style="cursor:hand"><?PHP setCell(2,8,$courses) ?> </td>
<td onclick="<?php move(3,8) ?>" style="cursor:hand"><?PHP setCell(3,8,$courses) ?> </td>
<td onclick="<?php move(4,8) ?>" style="cursor:hand"><?PHP setCell(4,8,$courses) ?></td>
<td onclick="<?php move(5,8) ?>" style="cursor:hand"><?PHP setCell(5,8,$courses) ?></td>
</tr>
<tr>
etc....
where the function move is:
function move($day,$hour)
{
$_SESSION['day'] = $day;
$_SESSION['hour'] = $hour;
?>kishur('http://localhost/css/workspace/tablecell.php')<?php
}
?>
wherer kishur is in java script:
<script language="javascript">
function kishur(the)
{tab=window.open(the,'tab','width=810, height=490 scrollbars=yes toolbar=no,location=yes,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,align=center')
tab.focus()}
</script>
when on page 'tablecell.php' I do: echo "day = ". $_SESSION['day'];echo "hour = ". $_SESSION['hour'];
I always get:
day = 5
hour = 19
Where 5 is the last Day and 19 is the last hour on the table
Please help me make it work!!!!!
I am writing a program that will contain a table.
the table contains days of the week as columns and hours (starting 8 AM until 8 PM) as rows.
What I am trying to do is: When clicking a cell, a new page opens and gives us information regarding the specific day and hour.
My problem is that I can't seem to transfer day and time variables correctly.
I use SESSION and it always transfer the last day and time, no meter which cell I click.
My code:
<div align = 'center'>
<table border = 1 width = '100%' bgcolor = '#DCDCDC' >
<caption><EM><h3>מערכת השעות הסמסטריאלית</h3></EM></caption>
<tr>
<td></td>
<th scope="col">Sun</th>
<th scope="col">Mon</th>
<th scope="col">tue</th>
<th scope="col">wed</th>
<th scope="col">th</th>
</tr>
<tr>
<th scope="row">9:30 - 8:30</th>
<td onclick="<?php move(1,8) ?>" style="cursor:hand"><?PHP setCell(1,8,$courses) ?></td>
<td onclick="<?php move(2,8) ?>" style="cursor:hand"><?PHP setCell(2,8,$courses) ?> </td>
<td onclick="<?php move(3,8) ?>" style="cursor:hand"><?PHP setCell(3,8,$courses) ?> </td>
<td onclick="<?php move(4,8) ?>" style="cursor:hand"><?PHP setCell(4,8,$courses) ?></td>
<td onclick="<?php move(5,8) ?>" style="cursor:hand"><?PHP setCell(5,8,$courses) ?></td>
</tr>
<tr>
etc....
where the function move is:
function move($day,$hour)
{
$_SESSION['day'] = $day;
$_SESSION['hour'] = $hour;
?>kishur('http://localhost/css/workspace/tablecell.php')<?php
}
?>
wherer kishur is in java script:
<script language="javascript">
function kishur(the)
{tab=window.open(the,'tab','width=810, height=490 scrollbars=yes toolbar=no,location=yes,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,align=center')
tab.focus()}
</script>
when on page 'tablecell.php' I do: echo "day = ". $_SESSION['day'];echo "hour = ". $_SESSION['hour'];
I always get:
day = 5
hour = 19
Where 5 is the last Day and 19 is the last hour on the table
Please help me make it work!!!!!