0

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);
3
Contributors
4
Replies
28
Views
1 Year
Discussion Span
Last Post by dizy
0

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."% "
0

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

0

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.

0

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>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.