I have a question to ask.

我有一个问题要问。

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 <a> tag to know which <a> is been clicked so that I can use searchresult_details.php to retrieve more details using ajax jQuery.

我有一个基于从MySQL数据库检索的数据的搜索结果。并根据检索到的数据,我嵌入并回显了div和标签,以了解哪些被点击,以便我可以使用searchresult_details.php使用ajax jQuery检索更多细节。

<?php

//include database connection file to call the class
include('dbconn.php');

//db global connection
$db = new DBConfig();
$db -> config();
$db -> 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 "<br />";
            echo '<div style="background-color:#ffa; padding:20px"><a class="record" value="' . $row['result_value'] . '">' . $row['result_value'] . '</a>' . '</div>';
            echo '<input class="tablename" type="hidden" name="tablename" value="' . $row['result_key'] . '" />';
        }
}
?>

However, the <a> will have multiple rows been echoed. I need to retrieve the <a> that is clicked and the value that it is stored in that particular <a> element. I can't be using id in <a> 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.

但是,将有多行被回显。我需要检索单击的以及它存储在该特定元素中的值。我不能在中使用id,因为我觉得它会很乏味。我正在考虑使用类,以便在javascript中我可以使用document.getElementsByClassName,但我知道IE中的此类函数有错误。

Any recommendations?

有什么建议?

2 个解决方案

#1


1

please check jQuery class selector

请检查jQuery类选择器

http://api.jquery.com/class-selector/

http://api.jquery.com/class-selector/

更多相关文章

  1. 使用PHP和MySQL开发“测试”Web应用程序的数据库设计
  2. 数据库布局更新是否仍在Magento中使用?
  3. mysqli类使用预处理语句不返回任何数据
  4. 使用/发送POST数据时的libcurl C问题(不是c++)
  5. PHP:在类中使用数据库
  6. 纯真ip数据库查询的php实现(补充分组查询)
  7. 添加到数据库后,保持在同一页面而不刷新它
  8. PHP 导出 万级别数据 时间测试
  9. 数据库是存储我的Web应用程序数据的最佳选择吗?

随机推荐

  1. Android 在某一页禁止home键返回
  2. Android(安卓)RecycerView 中根据图片大
  3. 动画 anim
  4. Appium API
  5. Error--->android工程导入找不到R文件
  6. saaaaaaaaa
  7. Android studio 导入github工程
  8. android -布局控件禁用多点触控
  9. android_lesson_2
  10. [置顶] android Properties的使用