Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retrieve html elements value via .click jQuery function with data retrieved from MySQL?
    primarykey
    data
    text
    <p>I have a question to ask.</p> <p>I have a search result that is based on data retrieved from MySQL database. And based on the data retrieved, I have embedded and echo a div and <code>&lt;a&gt;</code> tag to know which <code>&lt;a&gt;</code> is been clicked so that I can use searchresult_details.php to retrieve more details using ajax jQuery.</p> <pre><code>&lt;?php //include database connection file to call the class include('dbconn.php'); //db global connection $db = new DBConfig(); $db -&gt; config(); $db -&gt; conn(); //retrieve the keyword entered in the form in search.php $keyword = $_POST['keyword']; //call searchKeyValue method to retrieve the names whether client or staff searchKeyValue($keyword); function searchKeyValue($keyword) { $result = mysql_query("SELECT result_key, result_value FROM keyvalue WHERE result_value LIKE '%$keyword%'"); while($row = mysql_fetch_array($result)){ //echo $row['result_value']; //echo "&lt;br /&gt;"; echo '&lt;div style="background-color:#ffa; padding:20px"&gt;&lt;a class="record" value="' . $row['result_value'] . '"&gt;' . $row['result_value'] . '&lt;/a&gt;' . '&lt;/div&gt;'; echo '&lt;input class="tablename" type="hidden" name="tablename" value="' . $row['result_key'] . '" /&gt;'; } } ?&gt; </code></pre> <p>However, the <code>&lt;a&gt;</code> will have multiple rows been echoed. I need to retrieve the <code>&lt;a&gt;</code> that is clicked and the value that it is stored in that particular <code>&lt;a&gt;</code> element. I can't be using id in <code>&lt;a&gt;</code> because I think it would be tedious. I was thinking to use class so that in javascript I can use document.getElementsByClassName but I know such function in IE has errors.</p> <p>Any recommendations?</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.
    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