动态生成的列表项打开动态页面 jQuery Mobile

发布于 2024-11-05 14:43:20 字数 1111 浏览 2 评论 0原文

我有一个用 PHP 生成的列表。

<ul data-role="listview" data-filter="true" data-inset="true">
<?
  $qry = "SELECT jobname, jobsurname, LEFT(jobsurname, 1) AS first_char FROM clients  WHERE UPPER(LEFT(jobsurname, 1)) BETWEEN 'A' AND 'Z' OR LEFT(jobsurname, 1) BETWEEN '0' AND '9' ORDER BY jobsurname";  
  $result = mysql_query($qry);
  $current_char = '';

while ($row = mysql_fetch_assoc($result)) {
  if ($row['first_char'] != $current_char) {
     $current_char = $row['first_char'];
     echo '<li data-role="list-divider">' . strtoupper($current_char) . '</li>';
  }
echo '<li><a href="#">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
}  

?>
</ul>

它按照预期列出了所有内容。但我希望每个列表项打开一个对话框,其中包含严格针对该客户的信息。那么,我是否稍后在页面中运行另一个 SQL 语句,创建更多带有与名称或其他内容匹配的 id 的

?或者有没有办法通过 ajax 调用每个信息,例如:

echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';

I have a list generated with PHP.

<ul data-role="listview" data-filter="true" data-inset="true">
<?
  $qry = "SELECT jobname, jobsurname, LEFT(jobsurname, 1) AS first_char FROM clients  WHERE UPPER(LEFT(jobsurname, 1)) BETWEEN 'A' AND 'Z' OR LEFT(jobsurname, 1) BETWEEN '0' AND '9' ORDER BY jobsurname";  
  $result = mysql_query($qry);
  $current_char = '';

while ($row = mysql_fetch_assoc($result)) {
  if ($row['first_char'] != $current_char) {
     $current_char = $row['first_char'];
     echo '<li data-role="list-divider">' . strtoupper($current_char) . '</li>';
  }
echo '<li><a href="#">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
}  

?>
</ul>

It lists everything like its supposed to. But I want each list item to open a dialog with the information strictly for that client. So do I run another SQL statement later on in my page creating more <div data-role="page"> with an id matching the name or something? Or is there a way to call each info via ajax like:

echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞美少年 2024-11-12 14:43:20

是的,你可以这样做:

<a href="foo.html" data-rel="dialog">Open dialog</a>

文档:

http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/../../docs/pages/docs-dialogs.html

所以你的代码应该工作:

echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';

Yep you can do it this way:

<a href="foo.html" data-rel="dialog">Open dialog</a>

The Docs:

http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/../../docs/pages/docs-dialogs.html

So your code should work:

echo '<li><a href="getInfo.php?id=' . $row['id'] . '" data-rel="dialog">' . $row['jobsurname'] . ', ' . $row['jobname'] . '</a></li>';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文