0

my html form ->

<form action="where.php" method="post">
    <h2 align="center" style="color: white;"> Search Challan </h2>
    <table border="1"  bgcolor="grey" align="center">   
        <tr>
            <td align="center"> Search a Challan Details . Enter the Challan no below :</td>
        </tr>
        <tr>
            <td align="center">
        </tr>
        <tr>
            <td align="center"><input type="submit" name="submit" value="Search"align="middle" ></td> 
        <tr>
            <td>
                <select name="squery" style="width:142px;" >
                    <option value="challan_no">Challan no </option>
                    <option value="product_name">Product Name</option>
                    <option value="Buyer">buyer</option>
                    <option value="Employee Responsible">Employee</option>
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" name="search" >
            </td>       
        </tr>      
    </tr>
</form>

where.php ->

<?php
    $dbhost='localhost';
    $dbusername='root';
    $dbuserpass='';
    $dbname='inventory';

    //connect to the mysql database server.
    $con = mysql_connect ($dbhost, $dbusername, $dbuserpass);

    if (!$con ) die ("unable to connect : ". mysql_error());

    mysql_selectdb("$dbname",$con ) ; 

    $user_req = $_REQUEST['squery'] ;     //colomn name
    $req_id = $_REQUEST['search'] ;       // 

    $query = "SELECT * FROM challan WHERE '$user_req' = $req_id  ";
    $result = mysql_query($query);  
    if (!$result) die ("DAtabase acces faild bc : ". mysql_error());       

    $rows = mysql_numrows($result);   

    for ($j=0 ; $j < $rows ; ++$j)
    {
        $row = mysql_fetch_row($result);

        echo "<TABLE border=1 bgcolor=grey align=center width=500px float=left>"   ;
        echo "<tr>";
        echo "<td align=center>Challan no :  </td>";
        echo " <td> $row[0]  </td>";
        echo " </tr>";
        echo "<tr>";    
        echo "<td align=center>Challan Date : </td>"; 
        echo " <td> $row[1]  </td>";
        echo "<tr>";    
        echo "<td align=center>Product Name :   </td> ";
        echo " <td> $row[2]  </td>";
        echo "<tr>";    
        echo "<td align=center>Product qty :  </td> " ;
        echo " <td> $row[3]  </td>";
        echo "<tr>";    
        echo "<td align=center> Buyer : </td> " ;
        echo " <td> $row[4]  </td>";
        echo "<tr>";    
        echo "<td align=center>Employee Responsible :  </td> " ;
        echo " <td> $row[5]  </td>";
        echo "</tr>"; 
    }
?>

Its output is just blank. I'm unable to identify where I am going wrong.

5
  • 2
    please cleanup your code a bit before you post it here... Commented Mar 28, 2012 at 19:37
  • 2
    A blank page usually means there was a fatal error in PHP and you don't have error reporting turned on. Try putting this at the beginning of your script: ini_set("display_errors", 1); followed by error_reporting(E_ALL); Commented Mar 28, 2012 at 19:39
  • 2
    In the query SELECT * FROM challan WHERE '$user_req' = $req_id you used apostrophes for the column name. Use this: SELECT * FROM challan WHERE $user_req = '$req_id' Commented Mar 28, 2012 at 19:40
  • Have you got set error_reporting = E_ALL and display_errors = on in your php.ini? (php.net/manual/en/function.error-reporting.php). Also use echo and var_dump() at intervals in your code to see what is being evaluated. Commented Mar 28, 2012 at 19:43
  • Your HTML is missing a bunch of closing tags. Commented Mar 28, 2012 at 19:43

1 Answer 1

1

blank screen indicates that has occurred a fatal error and php was unable to continue script execution, you can run this in the top of your scripts to errors should be printed to the screen as part of the output.

<?php
ini_set('display_errors', 1);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.