10 Replies - 347 Views - Last Post: 23 January 2014 - 12:51 AM

#1 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

[SOLVED]on click search button twice, results disappear

Posted 22 January 2014 - 10:52 PM

when i Click on search button when results are displayed, but when i click again, the results disappear, i dont no why, i know it a small thing but cant figure it out

<form action="test.php" method="get">
    Search Engine: <input type="text" name="search" placeholder="Enter keywords..." />
    <input type="submit" name="search_product" value="Search now"/>
</form>

<?php

mysql_connect("localhost", "root", "");
mysql_select_db("tutorial");


if(empty($_GET['search'])){
    echo "No Search results";
}else{  

if (isset($_GET['search_product']) && empty($_GET['search_product']))
    $var = $_GET['search'];
    echo '</br>';
    $search_value = $_GET['search'];
    $query = "SELECT * FROM `blob` WHERE keyword LIKE '%$search_value%'";
    $run = mysql_query($query);
    while($row = mysql_fetch_array($run)){
        $name = $row['name'];
        $categorie = $row['categorie'];
        $lieu = $row['lieu'];
        $image = $row['image'];
        echo ("<div style='text-align:center;' style=width:300px; align='center';><h2><p>Nom du Produit: $name</h2> <strong>Categorie:</strong> $categorie <p><strong>Lieu:</strong> $lieu </p></p></div>");    
        echo "<div style='margin-left:630px;'>";?><?php echo"<img src=$image <height='150' width='150'>"?> <?php echo "</div>";
        echo "<hr/>";         
    }
}
mysql_close($connect);
?>



This post has been edited by VB ASRAAF007: 23 January 2014 - 12:55 AM


Is This A Good Question/Topic? 0
  • +

Replies To: [SOLVED]on click search button twice, results disappear

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: [SOLVED]on click search button twice, results disappear

Posted 22 January 2014 - 11:31 PM

I would suspect that before clicking again you didn’t insert any search terms.
Was This Post Helpful? 0
  • +
  • -

#3 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

Re: [SOLVED]on click search button twice, results disappear

Posted 22 January 2014 - 11:34 PM

exactly..i didnt insert any items after clicking again...

This post has been edited by VB ASRAAF007: 22 January 2014 - 11:35 PM

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: [SOLVED]on click search button twice, results disappear

Posted 22 January 2014 - 11:37 PM

then your script works as expected.
Was This Post Helpful? 0
  • +
  • -

#5 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

Re: [SOLVED]on click search button twice, results disappear

Posted 22 January 2014 - 11:55 PM

yes it works as expected but when i click again despite the results being searched, everything disappear, i dont want it to disappear, i want it remain until next search... :helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: [SOLVED]on click search button twice, results disappear

Posted 22 January 2014 - 11:58 PM

I don’t follow you. maybe you should describe stepwise what you do and what happens (for each step).
Was This Post Helpful? 0
  • +
  • -

#7 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

Re: [SOLVED]on click search button twice, results disappear

Posted 23 January 2014 - 12:03 AM

Ok..so..

i have a database, and i have a search engine.

when i input something in the search textbox and click search, it works perfectly fine..

HOWEVER, when the results are being displayed, and i click again on search, the results which were displayed, disappear and i dont want it to disappear before the next search...

u follow me ?
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: [SOLVED]on click search button twice, results disappear

Posted 23 January 2014 - 12:08 AM

well, when you click again that means you make a new search, and since you didn’t say anything about new search terms you put in, you obviously make a search without terms to search for, which—obviously—results in no search results, which means the old results disappear (are replaced by nothing).
Was This Post Helpful? 0
  • +
  • -

#9 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

Re: [SOLVED]on click search button twice, results disappear

Posted 23 January 2014 - 12:13 AM

exactlyyyyyyyyy now you got me... this is why i want the results which have already been displayed upon first search, continue to be displayed even though the button search is click again (but with no search value in it obviously).

u got me?
Was This Post Helpful? 0
  • +
  • -

#10 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: [SOLVED]on click search button twice, results disappear

Posted 23 January 2014 - 12:22 AM

quick’n’dirty fix: use Java­Script to check that the search term field is filled before you submit the form (making the text field required is also good, but does not work in all browsers)


rock solid fix: if it’s just that, you only have to move from a reload based form submit to an AJAX based page update. if the search gets no result, just don’t update the page.
Was This Post Helpful? 0
  • +
  • -

#11 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

Re: [SOLVED]on click search button twice, results disappear

Posted 23 January 2014 - 12:51 AM

oh damn yes...i've prefered to put a javascript..and it works fine...thanks a lot Dormilich

This post has been edited by VB ASRAAF007: 23 January 2014 - 12:52 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1