条件的条件只是指可变$year
和$sem
似乎所述第一条件是刚刚被读 如果$year='4th'
和$sem='1st'
所述一个显示所述一个的值是输出第一个条件是$year='1st'
和$sem='1st'
我在哪里有错?请帮忙提前 感谢这里是我的代码PHP条件没有被读取并没有被读
<?php
session_start();
$username=$_SESSION['username'];
echo $username ;
$year=$_SESSION['year'];
echo $year;
$sem=$_SESSION['sem'];
echo $sem;
$course=$_SESSION['course'];
$con=mysql_connect('server','username','password');
mysql_select_db($course);
echo $course;
if($year='1st' and $sem='1st')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 1st_year_1st_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 1st_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 1st_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='1st' and $sem='2nd')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 1st_year_2nd_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 1st_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 1st_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='2nd' and $sem='1st')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 2nd_year_1st_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 2nd_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 2nd_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='2nd' and $sem='2nd')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 2nd_year_2nd_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 2nd_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 2nd_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='3rd' and $sem='1st')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 3rd_year_1st_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 3rd_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 3rd_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='3rd' and $sem='2nd')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 3rd_year_2nd_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 3rd_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 3rd_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='4th' and $sem='1st')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 4th_year_1st_sem WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 4th_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 4th_year_1st_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
elseif($year='4th' and $sem='2nd')
{
echo('
<center>
<table border=1>
<tr>
<th bgcolor=pink>STUDENT NAME</th>
');
$a=mysql_query("SHOW FIELDS FROM 4th_year_2nd_sem like WHERE Field NOT IN ('USERNAME', 'STUDENTNUMBER', 'STUDENTNAME', 'SUBJECTS', 'UNITS')") OR DIE(MYSQL_ERROR());
while($b=mysql_fetch_array($a))
{
echo ('<th bgcolor=pink>'.$b[0].'</th>');
}
echo('</tr>');
$aaa=mysql_query("select STUDENTNAME FROM 4th_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bbb=mysql_fetch_array($aaa))
{
echo ('<td width=200 bgcolor=orange><input type=text value="'.$bbb[0].'" style="width:100%" readonly></td>');
}
$aa=mysql_query("SELECT * FROM 4th_year_2nd_sem WHERE USERNAME='$username'") OR DIE(MYSQL_ERROR());
while($bb=mysql_fetch_array($aa, MYSQL_NUM))
{
for ($count=5; $count < count($bb); $count++)
{
echo ('<td align=center width=80 bgcolor=lightblue><input type=text value="'.$bb[$count].'" style="width:100%; text-align:center" readonly></td>');
}
}
}
?>
如果像这样if(condetioion == value)不是单个的那么使用双等于 – 2014-10-03 08:08:44
@ Arif_suhail_123说了什么,如果你不这样做,你没有得到一个值,而是你以某种方式设置一个一个if语句。 – Azrael 2014-10-03 08:09:31
@ Arif_suhail_123我会后,作为一个答案 – 2014-10-03 08:09:36