Search Engine

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pascale
Forum Newbie
Posts: 10
Joined: Wed May 16, 2012 1:40 am

Search Engine

Post by pascale »

Code: Select all

if(isset($_POST['grade']) && isset($_POST['subject']) && isset($_POST['type']) ){
	 $type = array();
	  
  foreach($_POST['type'] as $ftype=>$i) {
		 $type[$ftype] = $i;
	 // $_POST['type'] = unserialize($row['type']); 
	 $data0 = mysql_query("SELECT * FROM uploadedfiles WHERE grade='".$_POST['grade']."' AND typeOfContent= '".$i."' AND (subject1='".$_POST['subject']."' OR subject2='".$_POST['subject']."' OR subject3='".$_POST['subject']."') ");
	 while($result0 = mysql_num_rows($data0)){


 echo '<html><body><table><tr>'; 
 echo '<th>id</th>';
 echo '<th>File</th>';
 echo '<th>Name</th>';
 echo '<th>type</th>';
 echo '<th>size</th>';
 echo '<th>grade</th>';
 echo '<th>age range</th>';
 echo '<th>country</th>';
 echo '<th>type of content</th>';
 echo '<th>Duration</th>';
 echo '<th>IPR type</th>';
 echo '<th>Subject1</th>';
 echo '<th>subject2</th>';
 echo '<th>Subject3</th>';
 echo '<th>animation Title</th>';
 echo '<th>asset Type</th>';
 echo '<th>scheme Of Work</th>';
 echo '<th>Keywords</th>';
 echo '<th>learning goals</th>';
 echo '<th>summary</th>';
 echo '<th>audio</th>';

echo '</tr>'; 
 
while ($row0 = mysql_fetch_row($data0)) { 
echo '<tr>'; 
$count0 = count($row0); 
$y = 0; 
while ($y < $count0) { 
$c_row0 = current($row0); 

echo '<td>' . $c_row0. '</td>'; 
next($row0); $y = $y + 1; 
}
 echo '</tr>'; 
} 
echo '</table></body></html>'; 

mysql_free_result($data0); 

echo '<br/>';	


  }

}
if(empty($_POST['grade']) && empty($_POST['subject']) && !empty($_POST['type'])){
echo "Also select a subject and a grade.";
} elseif ( mysql_num_rows($data0) != 1 )
	{
		 echo "No results found.<br>";
		
	 }exit;


  }
i have this code where type is a form of checkboxes, grade and subject are dropdown lists.when clicking all types this code let me view all results found plus it displys "No results found" for types that dont exit..How can stop it form doing so.I dont want when clicking all types to give me no results found for types that arent found.i just want it to give me this if all the checked ckeckboxes dont have any result.
i am really new to php.Thank you
pascale
Forum Newbie
Posts: 10
Joined: Wed May 16, 2012 1:40 am

Re: Search Engine

Post by pascale »

[text]i dont want the code when checking all checkboxes to give me no results for checkboxes that ahve no result..if all query has no result then i want it to give me no results found..what is the problem with my code.plz anyone help[/text]
Post Reply