Note that there are some explanatory texts on larger screens.

plurals
  1. POphp search won't clear when javascript onclick is clicked
    primarykey
    data
    text
    <p>So this is what I have - A javascript onclick event that will parse json from my MySQL database data and display it when someone clicks on a seat. </p> <pre><code> var jsonData = &lt;?php echo json_encode($array); ?&gt;; function displayInfoForDiv(i){ document.getElementById('fname').innerHTML = jsonData[i].first_name; document.getElementById('lname').innerHTML = jsonData[i].last_name; } </code></pre> <p>Output </p> <pre><code> &lt;?php while ($row = mysql_fetch_array($sql)){ ?&gt; &lt;p&gt;&lt;span id="fname"&gt;&lt;?php echo $row['first_name']; ?&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span id="lname"&gt;&lt;?php echo $row['last_name']; ?&gt;&lt;/span&gt;&lt;/p&gt; &lt;?php } ?&gt; </code></pre> <p>The PHP is for my search box when you try to look up a name - I'm using this</p> <pre><code> $sql = mysql_query("select * from people where first_name like '%$term%' OR last_name LIKE '%$term2%'"); </code></pre> <p>So the problem I'm having is when I conduct a search for Matt, more then one result will show up. Say:</p> <p>Matt Hasselbeck<br /> Matt Hew</p> <p>But if I use the onclick event and click on joe's seat, it will display like this:</p> <p>Joe Frill<br /> Matt Hew</p> <p>So the problem is that the search results will remain when I trigger the onClick event but the first one will change. </p> <p>My question is, is there a way when I click on a seat to clear the search results and only display the one but when I conduct a search to display the similar names.</p> <p>I'm using the PHP and JS to call the same data because, the JS only has a range of floor, while the php is grabbing everything from the database. </p> <p>Hopefully this is clear and thank you for any input. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload