Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
header.php file this code is for search operaitions

PHP
<?php
@session_start();
// drop down list
<select name="select">
<option value="empty">none</option>
<option value="fiction">fiction</option>
<option value="journals">journals</option>
<option value="acadamic">acadamic</option>
</select>


            <form action="" method="POST">
  // search box
           <input type="text" value="Enter a keyword here..." name="q" size="10" id="searchfield" title="searchfield" onFocus="clearText(this)" onBlur="clearText(this)" />
                    <input type="submit" name="Search" value="" alt="Search" id="searchbutton" title="Search" />
<br/>
if (isset($_GET['q']) && isset ($_GET['q']) != "")
{
if($_GET['select'] == "fiction"){

   
   $sqlcommand= "SELECT title,author FROM ".USRBOOKS." WHERE category = 'fiction'";
   
}else if($_GET['select'] == "journals"){

	$sqlcommand= "SELECT title,author FROM ".USRBOOKS." WHERE category = 'journals'";

}

else if($_GET['select'] == "acadamic"){

$sqlcommand= "SELECT title,author FROM ".USRBOOKS." WHERE category = 'acadamic'";
}
 


$query = mysql_query($sqlcommand) or die($sqlcommand);
$count = mysql_num_rows($query);

if ($count>0)
{
global $searchoutput; // using global variable to print value in other php file
$searchoutput = " $count results ";
// after successufl search I am trying to print the result in new php file using  below command
echo '<META http-equiv="refresh" content="0;URL='.INDEX_URL.'result.php">';
}
}

else {

 $searchoutput="0 result";

}

?>




result.php



PHP
        <?php 

echo $searchoutput; // problem is control is again shifting to header.php file and printing always "0 result" from else block

?>


problem is control is again shifting to header.php file and printing always "0 result" from else block

please anyone solve my problem
Posted

1 solution

The code does not make sense at all. It seems that you have gotten too far and too fast without a proper foundation and understanding of the web development using HTML, PHP, and MySQL.
Start learning HTML5, then PHP, and then put them together to make a form. When you succeed, then bring in the database part.
Refer:
1. http://www.codeproject.com/Learn/html/[^]
2. PHP 5[^]
3. PHP 5 Form Handling[^]
4. MySQL Database[^]
Remember - "Rome was not built in one day". Happy learning.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900