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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.