hello,
i need your help
i have problem with my code php. i want to call and display data from database but this coding cannot working.
this's my code php.

searchform.php

   <?php mysql_connect('localhost','root','') or die("Connection Failed");
                mysql_select_db("profil")or die("Connection Failed"); 
                $query = "SELECT * FROM tblreport"; 
                $result = mysql_query($query); ?> <select name="searchtype"> <?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
                 { ?> <option value="<?php echo $line['Name'];?>"> <?php echo $line['Name'];?> </option> <?php } ?> </select> </center> <tr> <td><center>
                enter search term
              </center></td> </tr> <tr> <td><label for="search"></label> <center> <p> <input  type="text" name="searchterm" id="search"> </p> <p> <input type="submit" name="search" id="submit" value="search">



            ** proc_search.php**


 <?php

$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];
$searchterm= trim($searchterm);

if ( !$searchtype || !$searchterm)
{
    echo "<center> data not found </center>";
    exit;
}

@ $db = mysql_pconnect('localhost','root','');
if (!$db)
{
    echo'Error: no connection databases.';
    exit;
}

mysql_select_db('profil');


$query = "select * from asset_ict where" .$searchtype." like ".$searchterm." ";
$result = mysql_query($query);

searchform.php

<form method="POST" action="proc_search.php">
     //your code
</form>

proc_search.php

use % as below

 $query = "select * from asset_ict where " .$searchtype." like %".$searchterm."% "

i'm try use % but still cannot display the data from database .
thanks give me answer

Is there code missing in your post? Line 37 executes your query, but there is no code outputting any results. You need a similar while loop as on line 4 and 5.

i'm done create loop similar line 4 and 5..before this my code are working but after i'm change on searchform.php with "select option from database" like below and than my code are not working.. so this's one of the problem or not?

 $query = "SELECT * FROM tblreport"; 
                $result = mysql_query($query); ?> <select name="searchtype"> <?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
                 { ?> <option value="<?php echo $line['Name'];?>"> <?php echo $line['Name'];?> </option> <?php } ?> </select>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.