Jump to content

Array Issue


tobimichigan

Recommended Posts

Hi  fellowcode comrades,

 

Please I am stuck with this array...output, everything works but on the output it only displays the "A" Grade. But I want to display other grades as well..but its not

 

<?php
						$grade=array("A","B","C","D","E","F");
						$adno=$_GET['adno'];
	 $select=mysql_query("select * from acadinfo where adno='$adno'");
			  $num=mysql_num_rows($select);
			  $a=1;
			  if(!@select) {
			  	die('<p>Error Retrieving<br/>'.
				'Error: ' .mysql_error() . '</p>');}
				while ($datalist=mysql_fetch_array($select)){
					$adno=htmlspecialchars($datalist["adno"]);
					$math=htmlspecialchars($datalist["math"]);
					$eng=htmlspecialchars($datalist["eng"]);
					$physics=htmlspecialchars($datalist["physics"]);
					$chem=htmlspecialchars($datalist["chem"]);
					$biology=htmlspecialchars($datalist["biology"]);
					$economics=htmlspecialchars($datalist["economics"]);
					$yoruba=htmlspecialchars($datalist["yoruba"]);

echo ("<table width='548' border='1'>");
echo("<tr>
    <th width='26' scope='col'>ADMISSION NO.</th>
    <th width='26' scope='col'>MATHEMATICS</th>
    <th width='26' scope='col'>ENGLISH</th>
    <th width='26' scope='col'>PHYSICS</th>
    <th width='26' scope='col'>CHEMISTRY</th>
    <th width='365' scope='col'>BIOLOGY</th>
    <th width='365' scope='col'>ECONOMICS</th>
    <th width='365' scope='col'>YORUBA</th>

  </tr>");
  echo("<tr>
    <th scope='row'>$adno</th>");
if ($datalist >=80) {
    echo("<td>$grade[0]</td>");}
elseif ($datalist >=70) {
echo("<td>$grade[1]</td>");}
elseif ($datalist >=60) {
echo("<td>$grade[2]</td>");}
elseif ($datalist >=50) {
echo("<td>$grade[3]</td>");}
elseif ($datalist >=40) {
echo("<td>$grade[4]</td>");}
elseif ($datalist <=39) {
echo("<td>$grade[5]</td>");}
echo("</tr>");
echo("</table>");
$a++;
}

?>

 

Please can sm1 tell me what I'm doing wrong here?

Link to comment
https://forums.phpfreaks.com/topic/198575-array-issue/
Share on other sites

Wait men, r u saying that I have to repeat:

<?php
echo ("<table width='548' border='1'>");
echo("<tr>
    <th width='26' scope='col'>ADMISSION NO.</th>
    <th width='26' scope='col'>MATHEMATICS</th>
    <th width='26' scope='col'>ENGLISH</th>
    <th width='26' scope='col'>PHYSICS</th>
    <th width='26' scope='col'>CHEMISTRY</th>
    <th width='365' scope='col'>BIOLOGY</th>
    <th width='365' scope='col'>ECONOMICS</th>
    <th width='365' scope='col'>YORUBA</th>

  </tr>");
  echo("<tr>
    <th scope='row'>$adno</th>");
if ($datalist >=80) {
    echo("<td>$grade[0]</td>");}
elseif ($datalist >=70) {
echo("<td>$grade[1]</td>");}
elseif ($datalist >=60) {
echo("<td>$grade[2]</td>");}
elseif ($datalist >=50) {
echo("<td>$grade[3]</td>");}
elseif ($datalist >=40) {
echo("<td>$grade[4]</td>");}
elseif ($datalist <=39) {
echo("<td>$grade[5]</td>");}
echo("</tr>");
echo("</table>");
$a++;
}

?>

All these codes to display the other grades on the other table?

Link to comment
https://forums.phpfreaks.com/topic/198575-array-issue/#findComment-1042059
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.