by PaanMoody » Wed Oct 03, 2012 5:27 pm
hi, can you help me with my php coding. i think i stuck where my php cannot retrieve back the data from phpmyadmin.this is my coding. an error occur which is
Notice: Undefined index: channel in C:\Program Files (x86)\EasyPHP-12.0\www\Timetable\timetable.php on line 34
Notice: Undefined index: time in C:\Program Files (x86)\EasyPHP-12.0\www\Timetable\timetable.php on line 34
Notice: Undefined index: program in C:\Program Files (x86)\EasyPHP-12.0\www\Timetable\timetable.php on line 34
<?php
$con = mysql_connect("localhost","root","12345");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM test") or die(mysql_error());
/* declare a 2d array accessible by $arr["channel"]["time"].
all programs are initialised to nothing. */
$arr = array(
"Time" => array("7.30", "8.00", "8.30", "9.00", "9.30", "10.00", "10.30"),
"Ten" => array("7.30" => "", "8.00" => "", "8.30" => "", "9.00" => "", "9.30" => ""),
"Nine" => array("7.30" => "", "8.00" => "", "8.30" => "", "9.00" => "", "9.30" => ""),
"Prime" => array("7.30" => "", "8.00" => "", "8.30" => "", "9.00" => "", "9.30" => ""),
"SBS" => array("7.30" => "", "8.00" => "", "8.30" => "", "9.00" => "", "9.30" => ""),
"ABC" => array("7.30" => "", "8.00" => "", "8.30" => "", "9.00" => "", "9.30" => ""),
);
/* the programs would be loaded into the array from here. */
/* this step would be updating the database.
for now we will just set the element chosen in the html page. */
$arr[$_POST['channel']][$_POST['time']] = $_POST['program'];
echo "<table border=\"1\">\n";
/* loop through the channels */
foreach($arr as $channel => $value)
{
echo "<tr>";
echo "<td>" . $channel ."</td>";
/* and the times */
foreach($value as $time)
{
echo "<td>" . $time . "</td>";
}
echo "</tr>\n";
}
?>