【发布时间】:2012-12-05 22:32:52
【问题描述】:
我想回显行数(假设行数= 3)。如果用户单击数字(我从 while 循环中传递 1 个参数),则会提醒数据 但问题是
- 如果我在 while 循环中回显 numrows,则所有行(相关的 3 行数据)都会在 onclick 事件中收到警报,但 numrows 会显示 3 次,如 333。
- 如果我在 while 循环之外回显,则显示 num 行,但只有一个结果传递给函数。
我也使用了count(col),但是这样只检索到一个结果。
任何一次显示行数但将$uid(在while循环中)的所有结果传递给onclick函数的解决方案?.请帮助。
$sql=mysqli_query($this->db->connection,"SELECT * from user_data where scid='$scid'");
$num=mysqli_num_rows($sql);
while($row=mysqli_fetch_array($sql)){
$uid=$row['uid'];
?>
<span onclick=o4_sameby_scid(<?php echo $uid; ?>)><?php echo $num ?></span>
<script type="text/javascript">
function o4_sameby_scid(o4_id) {
alert(o4_id);
}
</script>
<?php
}
【问题讨论】:
-
@itachi 循环中 $uid 的结果
-
这个问题很模糊。解释
Any solution to show the num rows one time but passing all the results to onclick function?这部分。可以举个例子。 -
@itachi.plz 查看问题。我已更新上述行
-
什么格式?如
1,2,3,....或其他?
标签: php jquery mysql-num-rows