我想在表格中显示数组中的值,我尝试搜索,但都不起作用,这是代码段
$host="localhost";
$username="root";
$password="";
$db_name="sampledb";
$tbl_name="tblsched";
$cd1 = date("Y-m-d");
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "SELECT * FROM tblteacher WHERE teacherName='$uname'";
$result=mysql_query($sql);
$row = mysql_fetch_assoc($result);
$teacherid = $row['teacherID'];
function mymainfunc()
{
global $uname;
global $teacherid;
$bgcolor="#ADDFFF";
$tdali="center";
dateto();
datefrom();
$arrayto[] = array();
$arrayfrom[] = array();
$arrayto[] = dateto();
$arrayfrom[] = datefrom();
$x=0;
while($x<count($arrayto[]))
{
echo "<tr>";
echo "<td align=$tdali bgcolor=$bgcolor>$arrayfrom[$x] - $arrayto[$x]</td>";
echo "<td align=$tdali> </td>";
echo "<td align=$tdali> </td>";
echo "<td align=$tdali> </td>";
echo "<td align=$tdali> </td>";
echo "<td align=$tdali> </td>";
echo "<td align=$tdali> </td>";
echo "<td align=$tdali> </td>";
echo "</tr>";
$x++;
}
}
function dateto()
{
global $uname;
global $cd1;
global $teacherid;
$sql="SELECT SchedTimeTo FROM tblsched WHERE SchedTeacherID=$teacherid and SchedDateFrom<='$cd1' and SchedDateTo>='$cd1' ";
$result=mysql_query($sql);
if($result === FALSE) {
die(mysql_error());
}
$count=mysql_num_rows($result);
$row = mysql_fetch_array($result);
$STF = array();
while($row=mysql_fetch_array($result))
{
$STF[] = $row;
}
return $STF;
}
function datefrom()
{
global $uname;
global $cd1;
global $teacherid;
$sql="SELECT SchedTimeFrom FROM tblsched WHERE SchedTeacherID=$teacherid and SchedDateFrom<='$cd1' and SchedDateTo>='$cd1' ";
$result=mysql_query($sql);
if($result === FALSE) {
die(mysql_error());
}
$row = mysql_fetch_array($result);
$STF = array();
while($row=mysql_fetch_array($result))
{
$STF[] = $row;
}
return $STF;
}
关于如何在不同的单元格中显示每个数组值的任何建议,每个单元格将包含来自数组的不同值