Solved

mysql_num_row expects parameter 1

Posted on 2014-10-10
12
119 Views
Last Modified: 2014-10-12
Hay experts i am getting mysql_num_row expects parameter 1
on lines 87,   130,     173 can you help find the issue thanks

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Absent Teachers</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../styles.css" />
<script type="text/javascript">var start = new Date();start = Date.parse(start)/1000;var seconds = 15;function CountDown(){    var now = new Date();    now = Date.parse(now)/1000;    var counter = parseInt(seconds-(now-start),10);    document.getElementById('countdown').innerHTML = counter;    if(counter > 0){        timerID = setTimeout("CountDown()", 100)    }else{        location.href = "http://localhost/w1/mon/tables2of5.php"    }}window.setTimeout('CountDown()',100);</script>
</head>

<body>

<div id="container">
<div id="header"><img name="Logo" src="../../images/logo.png" width="233" height="76" alt=""></div>
</DIV>

  <?php 

/* 
This is an example showing how to list records as hyperlink 
and associated key data/variables. 
*/ 

// Connect to server 
// Replace username and password by your details 

$db = @mysql_connect("localhost","xxxxxx","xxxxxxxx"); 
if (!$db) 
{ 
        do_error("Could not connect to the server"); 
} 

// Connect to the database 
// Note that your database will be called username 

@mysql_select_db("test",$db)or do_error("Could not connect to the database"); 

// Run the search query 

$result = mysql_query("SELECT * FROM  w1monsick1 ORDER BY period",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period=1; $period < 10; $period++) {
	$sickteacher[$period] = null;
	$subject[$period] = null;
	$class[$period] = null;
	$room[$period] = null;
	$coverteacher[$period] = null;
	
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher[$myrow['period']] = $myrow['sickteacher'];
	$subject[$myrow['period']] = $myrow['subject'];
	$class[$myrow['period']] = $myrow['class'];
	$room[$myrow['period']] = $myrow['room'];
	$coverteacher[$myrow['period']] = $myrow['coverteacher'];
	
}
?>


<table width="99%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid; ">
	
	<tr style="color: #190707; background-color: #FFFF00"><th>Absent Teacher_1</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr bgcolor="#DCDCDC"><th>Absent Teacher</th><?php foreach ($sickteacher as $period => $teacher) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject as $period => $subject) { printf("<td>%s</td>",$subject); } ?></FONT></tr>
	<tr bgcolor="#DCDCDC"><th>Class</th><?php foreach ($class as $period => $class) { printf("<td><b>%s</b></td>",$class); } ?></tr>
	<tr><th>Room</th><?php foreach ($room as $period => $room) { printf("<td><b>%s</b></td>",$room); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Cover Teacher</th><?php foreach ($coverteacher as $period => $teacher) { printf("<td><stong><b><font SIZE=3>%s</font></b></stong></td>",
	$teacher); } ?>
    </tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_1</p>
<?php   header('Refresh: 02; URL=http://localhost/w1/mon/tables2of5.php'); // New URL ?>

<?php endif; ?> 
<?php
$result = mysql_query("SELECT * FROM  w1monsick2 ORDER BY period2",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period2=1; $period2 < 10; $period2++) {
	$sickteacher2[$period2] = null;
	$subject2[$period2] = null;
	$class2[$period2] = null;
	$room2[$period2] = null;
	$coverteacher2[$period2] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher2[$myrow['period2']] = $myrow['sickteacher2'];
	$subject2[$myrow['period2']] = $myrow['subject2'];
	$class2[$myrow['period2']] = $myrow['class2'];
	$room2[$myrow['period2']] = $myrow['room2'];
	$coverteacher2[$myrow['period2']] = $myrow['coverteacher2'];
}
?>


<table width="99%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <tr style="color: #190707; background-color: #0080FF"><th>Absent Teacher_2</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr bgcolor="#DCDCDC"><th>Absent Teacher</th><?php foreach ($sickteacher2 as $period2 => $teacher2) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher2); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject2 as $period2 => $subject2) { printf("<td><b>%s</b></td>",$subject2); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Class</th><?php foreach ($class2 as $period2 => $class2) { printf("<td><b>%s</b></td>",$class2); } ?></tr>
	<tr><th>Room</th><?php foreach ($room2 as $period2 => $room2) { printf("<td><b>%s</b></td>",$room2); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Cover Teacher</th><b><?php foreach ($coverteacher2 as $period2 => $teacher2) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher2); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_2</p>

<?php endif; ?>  
<?php
$result = mysql_query("SELECT * FROM  w1monsick3 ORDER BY period3",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period3=1; $period3 < 10; $period3++) {
	$sickteacher3[$period3] = null;
	$subject3[$period3] = null;
	$class3[$period3] = null;
	$room3[$period3] = null;
	$coverteacher3[$period3] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher3[$myrow['period3']] = $myrow['sickteacher3'];
	$subject3[$myrow['period3']] = $myrow['subject3'];
	$class3[$myrow['period3']] = $myrow['class3'];
	$room3[$myrow['period3']] = $myrow['room3'];
	$coverteacher3[$myrow['period3']] = $myrow['coverteacher3'];
}
?>


<table width="99%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <tr style="color: #190707; background-color: #FF0000"><th>Absent Teacher_3</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr bgcolor="#DCDCDC"><th>Absent Teacher</th><?php foreach ($sickteacher3 as $period3 => $teacher3) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher3); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject3 as $period3 => $subject3) { printf("<td><b>%s</b></td>",$subject3); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Class</th><?php foreach ($class3 as $period3 => $class3) { printf("<td><b>%s</b></td>",$class3); } ?></tr>
	<tr><th>Room</th><?php foreach ($room3 as $period3 => $room3) { printf("<td><b>%s</b></td>",$room3); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Cover Teacher</th><b><?php foreach ($coverteacher3 as $period3 => $teacher3) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher3); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_3</p>

<?php endif; ?> 
<?php
$result = mysql_query("SELECT * FROM  w1monsick4 ORDER BY period4",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period4=1; $period4 < 10; $period4++) {
	$sickteacher4[$period4] = null;
	$subject4[$period4] = null;
	$class4[$period4] = null;
	$room4[$period4] = null;
	$coverteacher4[$period4] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher4[$myrow['period4']] = $myrow['sickteacher4'];
	$subject4[$myrow['period4']] = $myrow['subject4'];
	$class4[$myrow['period4']] = $myrow['class4'];
	$room4[$myrow['period4']] = $myrow['room4'];
	$coverteacher4[$myrow['period4']] = $myrow['coverteacher4'];
}
?>


<table width="99%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <tr style="color: #190707; background-color: #BF00FF"><th>Absent Teacher_4</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr bgcolor="#DCDCDC"><th>Absent Teacher</th><?php foreach ($sickteacher4 as $period4 => $teacher4) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher4); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject4 as $period4 => $subject4) { printf("<td><b>%s</b></td>",$subject4); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Class</th><?php foreach ($class4 as $period4 => $class4) { printf("<td><b>%s</b></td>",$class4); } ?></tr>
	<tr><th>Room</th><?php foreach ($room4 as $period4 => $room4) { printf("<td><b>%s</b></td>",$room4); } ?></tr>
	<tr bgcolor="#DCDCDC"><th>Cover Teacher</th><b><?php foreach ($coverteacher4 as $period4 => $teacher4) { printf("<td><font SIZE=3><b>%s</b></font></td>",$teacher4); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_4</p>

<?php endif; ?>
<?php // RAY_temp_paddy086.php
error_reporting(E_ALL);

// CONNECTION AND SELECTION VARIABLES FOR THE DATABASE
$db_host = "localhost"; // PROBABLY THIS IS OK
$db_name = "test";        // GET THESE FROM YOUR HOSTING COMPANY
$db_user = "xxxxxxxx";
$db_word = "xxxxxxxx";

// OPEN A CONNECTION TO THE DATA BASE SERVER
// MAN PAGE: http://php.net/manual/en/function.mysql-connect.php
if (!$db_connection = mysql_connect("$db_host", "$db_user", "$db_word"))
{
    $errmsg = mysql_errno() . ' ' . mysql_error();
    echo "<br/>NO DB CONNECTION: ";
    echo "<br/> $errmsg <br/>";
}

// SELECT THE MYSQL DATA BASE
// MAN PAGE: http://php.net/manual/en/function.mysql-select-db.php
if (!$db_sel = mysql_select_db($db_name, $db_connection))
{
    $errmsg = mysql_errno() . ' ' . mysql_error();
    echo "<br/>NO DB SELECTION: ";
    echo "<br/> $errmsg <br/>";
    die('NO DATA BASE');
}
// IF WE GOT THIS FAR WE CAN DO QUERIES

// GET THE LIST OF TABLES
$sql = "SHOW TABLES";
$res = mysql_query($sql) or die("FAIL: $sql <br/>" . mysql_error() );

// CREATE AN ARRAY OF TABLE NAMES
$tables = array();
while ($row = mysql_fetch_array($res))
{
    $tables[] = $row[0];
}

// GET THE COUNT OF TABLES
$total = count($tables);

// TEST EACH TABLE FOR ROWS OF DATA
$used = 0;
foreach ($tables as $table) 
{ 
     if ($table!="class" && $table!="room" && $table!="student" && $table!="subject" && $table!="teacher" && $table!="users") { 
         $sql = "SELECT * FROM $table LIMIT 1"; 
         $res = mysql_query($sql) or die("FAIL: $sql <br/>" . mysql_error() ); 
         $num = mysql_num_rows($res); 
         if ($num) $used++; 
     } 
}  

// SHOW THE WORK PRODUCT
echo "$used Absent";
?> 


<p>You will be redirected in <center><strong id="countdown">15</strong> seconds.</center></p>
    <p><center>
      <img src="images/ajax-loader.gif" width="16" height="11"></center></p>
</body> 
  <div id="wrapper"></div>
  <div id="footer">
    <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
      </div>
</div>
</body>
</html>

Open in new window


And also on Lines 130 and 175 on this code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Absent Teachers</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../styles.css" />
<script type="text/javascript">var start = new Date();start = Date.parse(start)/1000;var seconds = 15;function CountDown(){    var now = new Date();    now = Date.parse(now)/1000;    var counter = parseInt(seconds-(now-start),10);    document.getElementById('countdown').innerHTML = counter;    if(counter > 0){        timerID = setTimeout("CountDown()", 100)    }else{        location.href = "http://localhost/w1/mon/tables3of5.php"    }}window.setTimeout('CountDown()',100);</script>
</head>

<body>
<div id="container">
<div id="header"> <img name="Logo" src="../../images/logo.png" width="233" height="76" alt=""></div>
</DIV>
<div id="navigation1">
    <p>&nbsp;</p>
    <p>You will be redirected in <center><strong id="countdown">15</strong> seconds.</center></p>
    <p><center>
      <img src="images/ajax-loader.gif" width="16" height="11"></center></p>
       <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p> <?php 
error_reporting(E_ALL);

// CONNECTION AND SELECTION VARIABLES FOR THE DATABASE
$db_host = "localhost"; // PROBABLY THIS IS OK
$db_name = "test";        // GET THESE FROM YOUR HOSTING COMPANY
$db_user = "xxxxxxx";
$db_word = "xxxxxxxxxxxxxx";

// OPEN A CONNECTION TO THE DATA BASE SERVER
// MAN PAGE: http://php.net/manual/en/function.mysql-connect.php
if (!$db_connection = mysql_connect("$db_host", "$db_user", "$db_word"))
{
    $errmsg = mysql_errno() . ' ' . mysql_error();
    echo "<br/>NO DB CONNECTION: ";
    echo "<br/> $errmsg <br/>";
}

// SELECT THE MYSQL DATA BASE
// MAN PAGE: http://php.net/manual/en/function.mysql-select-db.php
if (!$db_sel = mysql_select_db($db_name, $db_connection))
{
    $errmsg = mysql_errno() . ' ' . mysql_error();
    echo "<br/>NO DB SELECTION: ";
    echo "<br/> $errmsg <br/>";
    die('NO DATA BASE');
}
// IF WE GOT THIS FAR WE CAN DO QUERIES

// GET THE LIST OF TABLES
$sql = "SHOW TABLES";
$res = mysql_query($sql) or die("FAIL: $sql <br/>" . mysql_error() );

// CREATE AN ARRAY OF TABLE NAMES
$tables = array();
while ($row = mysql_fetch_array($res))
{
    $tables[] = $row[0];
}

// GET THE COUNT OF TABLES
$total = count($tables);

// TEST EACH TABLE FOR ROWS OF DATA
$used = 0;
foreach ($tables as $table) 
{ 
     if ($table!="class" && $table!="room" && $table!="student" && $table!="subject" && $table!="teacher" && $table!="users") { 
         $sql = "SELECT * FROM $table LIMIT 1"; 
         $res = mysql_query($sql) or die("FAIL: $sql <br/>" . mysql_error() ); 
         $num = mysql_num_rows($res); 
         if ($num) $used++; 
     } 
}  

// SHOW THE WORK PRODUCT
echo "$used Absent";
?> </p>
<p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
  
  </div>
  <?php 

/* 
This is an example showing how to list records as hyperlink 
and associated key data/variables. 
*/ 

// Connect to server 
// Replace username and password by your details 

$db = @mysql_connect("localhost","xxxxxxxxxx","xxxxxxxxxxxxx"); 
if (!$db) 
{ 
        do_error("Could not connect to the server"); 
} 

// Connect to the database 
// Note that your database will be called username 

@mysql_select_db("test",$db)or do_error("Could not connect to the database"); 

// Run the search query 


$result = mysql_query("SELECT * FROM  w1monsick5 ORDER BY period5",$db); 
if(mysql_num_rows($result)) :


//create an empty array for each row - ready to take 8 values.
for ($period5=1; $period5 < 10; $period5++) {
	$sickteacher5[$period5] = null;
	$subject5[$period5] = null;
	$class5[$period5] = null;
	$room5[$period5] = null;
	$coverteacher5[$period5] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher5[$myrow['period5']] = $myrow['sickteacher5'];
	$subject5[$myrow['period5']] = $myrow['subject5'];
	$class5[$myrow['period5']] = $myrow['class5'];
	$room5[$myrow['period5']] = $myrow['room5'];
	$coverteacher5[$myrow['period5']] = $myrow['coverteacher5'];
}
?>


<table width="90%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <th>Absent Teacher_5</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr><th>Absent Teacher</th><?php foreach ($sickteacher5 as $period5 => $teacher5) { printf("<td>%s</td>",$teacher5); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject5 as $period5 => $subject5) { printf("<td>%s</td>",$subject5); } ?></tr>
    <tr><th>Class</th><?php foreach ($class5 as $period5 => $class5) { printf("<td>%s</td>",$class5); } ?></tr>
	<tr><th>Room</th><?php foreach ($room5 as $period5 => $room5) { printf("<td>%s</td>",$room5); } ?></tr>
	<tr><th>Cover Teacher</th><b><?php foreach ($coverteacher5 as $period5 => $teacher5) { printf("<td>%s</td>",$teacher5); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_5</p>
<?php   header('Refresh: 00; URL=http://localhost/w1/mon/tables3of5.php'); // New URL ?>

<?php endif; ?> 
<?php
$result = mysql_query("SELECT * FROM  w1monsick6 ORDER BY period6",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period6=1; $period6 < 10; $period6++) {
	$sickteacher6[$period6] = null;
	$subject6[$period6] = null;
	$class6[$period6] = null;
	$room6[$period6] = null;
	$coverteacher6[$period6] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher6[$myrow['period6']] = $myrow['sickteacher6'];
	$subject6[$myrow['period6']] = $myrow['subject6'];
	$class6[$myrow['period6']] = $myrow['class6'];
	$room6[$myrow['period6']] = $myrow['room6'];
	$coverteacher6[$myrow['period6']] = $myrow['coverteacher6'];
}
?>


<table width="90%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <th>Absent Teacher_6</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr><th>Absent Teacher</th><?php foreach ($sickteacher6 as $period5 => $teacher6) { printf("<td>%s</td>",$teacher6); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject6 as $period6 => $subject6) { printf("<td>%s</td>",$subject6); } ?></tr>
	<tr><th>Class</th><?php foreach ($class6 as $period6 => $class6) { printf("<td>%s</td>",$class6); } ?></tr>
	<tr><th>Room</th><?php foreach ($room6 as $period6 => $room6) { printf("<td>%s</td>",$room6); } ?></tr>
	<tr><th>Cover Teacher</th><b><?php foreach ($coverteacher6 as $period6 => $teacher6) { printf("<td>%s</td>",$teacher6); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_6</p>

<?php endif; ?>
<?php
$result = mysql_query("SELECT * FROM  w1monsick7 ORDER BY period7",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period7=1; $period7 < 10; $period7++) {
	$sickteacher7[$period7] = null;
	$subject7[$period7] = null;
	$class7[$period7] = null;
	$room7[$period7] = null;
	$coverteacher7[$period7] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher7[$myrow['period7']] = $myrow['sickteacher7'];
	$subject7[$myrow['period7']] = $myrow['subject7'];
	$class7[$myrow['period7']] = $myrow['class7'];
	$room7[$myrow['period7']] = $myrow['room7'];
	$coverteacher7[$myrow['period7']] = $myrow['coverteacher7'];
}
?>


<table width="90%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <th>Absent Teacher_7</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr><th>Absent Teacher</th><?php foreach ($sickteacher7 as $period7 => $teacher7) { printf("<td>%s</td>",$teacher7); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject7 as $period7 => $subject7) { printf("<td>%s</td>",$subject7); } ?></tr>
	<tr><th>Class</th><?php foreach ($class7 as $period7 => $class7) { printf("<td>%s</td>",$class7); } ?></tr>
	<tr><th>Room</th><?php foreach ($room7 as $period7 => $room7) { printf("<td>%s</td>",$room7); } ?></tr>
	<tr><th>Cover Teacher</th><b><?php foreach ($coverteacher7 as $period7 => $teacher7) { printf("<td>%s</td>",$teacher7); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_7</p>

<?php endif; ?> 
<?php
$result = mysql_query("SELECT * FROM  w1monsick8 ORDER BY period8",$db); 
if(mysql_num_rows($result)) :

//create an empty array for each row - ready to take 8 values.
for ($period8=1; $period8 < 10; $period8++) {
	$sickteacher8[$period8] = null;
	$subject8[$period8] = null;
	$class8[$period8] = null;
	$room8[$period8] = null;
	$coverteacher8[$period8] = null;
}

//loop through the data result and build the row data.
while ($myrow = mysql_fetch_array($result)) {  
	$sickteacher8[$myrow['period8']] = $myrow['sickteacher8'];
	$subject8[$myrow['period8']] = $myrow['subject8'];
	$class8[$myrow['period8']] = $myrow['class8'];
	$room8[$myrow['period8']] = $myrow['room8'];
	$coverteacher8[$myrow['period8']] = $myrow['coverteacher8'];
}
?>


<table width="90%" table border="3" style="border-width: 1px; border-color:#000000;
>>> border-style: solid;">
	
	<tr>
	  <th>Absent Teacher_8</th><th>Period1</th><th>Period2</th><th>Period3</th><th>Period4</th><th>Period5</th><th>Period6</th><th>Period7</th><th>Period8</th><th>Period9</th></tr>
	<tr><th>Absent Teacher</th><?php foreach ($sickteacher8 as $period8 => $teacher8) { printf("<td>%s</td>",$teacher8); } ?></tr>
	<tr><th>Subject</th><?php foreach ($subject8 as $period8 => $subject8) { printf("<td>%s</td>",$subject8); } ?></tr>
	<tr><th>Class</th><?php foreach ($class8 as $period8 => $class8) { printf("<td>%s</td>",$class8); } ?></tr>
	<tr><th>Room</th><?php foreach ($room8 as $period8 => $room8) { printf("<td>%s</td>",$room8); } ?></tr>
	<tr><th>Cover Teacher</th><b><?php foreach ($coverteacher8 as $period8 => $teacher8) { printf("<td>%s</td>",$teacher8); } ?></b></tr>
</table>

<br><center>  </center><br>

 <?php else: ?>

<p>No Records Found Of Absent Teacher_8</p>

<?php endif; ?>

</body> 
  <div id="wrapper"></div>
  <div id="footer">
    <p>xxxxxxxxxxxxxxxxxxxx</p>
  </div>
</div>
</body>
</html>

Open in new window

0
Comment
Question by:paddy086
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 40374069
If your query failed, you would not have a resultset.

Try putting

echo mysql_error();

immediately after the mysql_query line and see if there is an error.
0
 

Author Comment

by:paddy086
ID: 40374081
Hi yodercm

I put echo mysql_error();
after line 86 and got an error of

Unknown column 'period2' in 'order clause'
0
 
LVL 58

Expert Comment

by:Gary
ID: 40374090
Change it to

if(mysql_num_rows($result)>0) :
0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

Author Comment

by:paddy086
ID: 40374104
hi gary still get same error

its wearied  cos line 34 doesn't give any errors
and on the second code line 174 and 260 don't give any error message
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40374113
This message is the signature of a query failure.  To learn how to run MySQL queries, detect failures and visualize the reasons, please see the examples in this article.  It's a little different depending on the choice of MySQL extensions, but there are examples for all the major MySQL extensions in the code snippets.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0
 
LVL 27

Assisted Solution

by:Cornelia Yoder
Cornelia Yoder earned 500 total points
ID: 40374120
is period2 the name of a column in your table?
0
 
LVL 27

Accepted Solution

by:
Cornelia Yoder earned 500 total points
ID: 40374123
When you do something like this:

"SELECT * FROM  w1monsick5 ORDER BY period5"

the ORDER BY field needs to be the name of a field in your table.
0
 

Author Comment

by:paddy086
ID: 40374132
I have found the issue it was to do with my database I made a backup awhile ago and only recently import it back in but not all the info went into each table correctly for some reason not sure why but its fixed now

Here what my database looked like

w1monsick1
id, period, sickteacher, subject, class, room, coverteacher

w1monsick2
id, period, sickteacher, subject, class, room, coverteacher            

w1monsick
id, period, sickteacher, subject, class, room, coverteacher

And this is what it should have been
w1monsick1
id, period, sickteacher, subject, class, room, coverteacher

w1monsick2
id2, period2, sickteacher2, subject2, class2, room2, coverteacher2            

w1monsick3
id3, period3, sickteacher3, subject3, class3, room3, coverteacher3
0
 

Author Comment

by:paddy086
ID: 40375908
I've requested that this question be closed as follows:

Accepted answer: 0 points for paddy086's comment #a40374132
Assisted answer: 100 points for yodercm's comment #a40374069
Assisted answer: 100 points for Gary's comment #a40374090
Assisted answer: 100 points for Ray Paseur's comment #a40374113
Assisted answer: 100 points for yodercm's comment #a40374120
Assisted answer: 100 points for yodercm's comment #a40374123

for the following reason:

All do the info the Experts was giving to me at the time was correct my issue ended up being with my own Database back up not importing correctly...
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40374235
For anyone coming upon this question in the future, these lines from the first code snippet appear about line number 39:
$result = mysql_query("SELECT * FROM  w1monsick1 ORDER BY period",$db); 
if(mysql_num_rows($result)) 

Open in new window

But that's not the right way to run a query, because it assumes that the query always works correctly.  Your script cannot make that assumption; MySQL is not a black box.  It can and will fail for reasons that are sometimes out of your control, therefore it's necessary to test for query failure and visualize the issues and error messages.  If you don't make these tests in your script, the script is likely to fail in confusing ways, as we have seen here.  

The right way (or at least one better way) is actually part of the same script file near line 243!
// GET THE LIST OF TABLES
$sql = "SHOW TABLES";
$res = mysql_query($sql) or die("FAIL: $sql <br/>" . mysql_error() );

Open in new window

In this latter example, the SQL statement is created in a separate PHP variable.  This means the variable can be displayed if needed.  The code tests for success or failure of the query with the "or" directive.  If the query fails, the "or" clause in this instruction will be executed, and the script will print out the failure message, showing the query that failed and the contents of the mysql_error() function.

Today, a better approach than die() is trigger_error() which can create an error condition that can be used in conjunction with an error handler.
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 40374250
So in fact, it WAS the name of the field in your table that was the problem.

Don't you think that my answer clearly led you to exactly what was wrong?
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 40374253
I believe my answer was correct, and that the mistake the asker had made with his table caused exactly the problem I said was the cause.
0

Featured Post

Webinar: Security & Encryption in the MySQL world

Join Percona’s Solutions Engineer, Dimitri Vanoverbeke as he presents “Security and Encryption in the MySQL world” on Thursday, July 6, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question