Hi,

please first you visit this site http://www.webdo.x10.mx/ this is my practice site.I just starting my php carrer.here i create a search option with button but its not working as my expectation.i think its code is OK".here the code..

<?php 
    $connect=mysql_connect('localhost','root','');
    $mysql_db=mysql_select_db('my_database',$connect) or die(mysql_error());     //db name:my_database

if (isset($_POST['search_name']))
{
 $search_name= $_POST['search_name'];
 if(!empty($search_name)){

    if(strlen($search_name)>=4){


  $query = "SELECT name FROM name_search WHERE name LIKE '%".mysql_real_escape_string($search_name)."%'"; 
  $query_run= mysql_query($query);             //table name:name_search colm name:name///

  $query_num_rows=mysql_num_rows($query_run);

 if($query_num_rows>=1)
 {
    echo $query_num_rows.' Result Found:<br/>';
 while ($query_row=mysql_fetch_assoc($query_run)){
    echo $query_row['name'].'<br/>';
 }
 }
 else
 {
    echo 'Not found';
   }
     }
     else {
        echo 'Please Character must be more then 5 keywords';
     }
     }
 }
?>


////--------FORM creation area----------------//////////



<div class="search"><p>I am looking for...</p>
<div class="search_input">
<form>
<input type="text" name="search_name" class="search_input" title="Trainer Name" value="<?php echo $_SESSION['search_name'];?>"> 
</form>
</div>
</div>
<div class="search_button">
<form action= "second_page.php" method="POST">
<input type="submit" name="search_name" class="search_button" title="Search" value="Find">
</form>
</div>

when i run it my local server its woking/search perfectly but unfortunatelly its not working here(live server/site).I am also cofused about FIND button.its OK? //I think its <from></form> area problem.
If you want i also provide you this site access panel login id/password.For solving.

please help me with details..

regards....

If the code works perfectly on your local server but not on the site, it seems like you may not have your database set up properly on the site. Have you created a database on the live site that is identical to the one on your local server? Also, are you getting any errors?

Hi,

code is ok i know and database also connected correctly.so,
can you plz tell me the <form> section is Ok or not?

are you sure you wrote the php statement? if so, then you would know about html. put the input tag into the form

see this below code and if i use above php code so,then may i use below input tag.here i used two <form>. one for search box and other for find button.
can you tell me its good way....???
or please visit link http://www.webdo.x10.mx/
and kindly correction them ....if you face any problem explain that..PLZ

<div class="search_input">
<form>
<input type="text" name="search_name" class="search_input" title="Trainer Name" value="<?php echo $_SESSION['search_name'];?>">
</form>
</div>
</div>
<div class="search_button">
<form action= "" method="POST">
<input type="submit" name="search_name" class="search_button" title="Search" value="Find">
</form>
</div>

here i use 2 <form> tag one for seach box and another for find button.
so,its good way?

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.