dsovc00684 2013-07-03 11:08
浏览 17

按剂量按钮从mysql表中获取数据

My database holds a table with the names of 30 users. I have the following html form which is a search form:

<form method="POST" name="go" action="search_form_all.php"  >
  <input name="value" type="text" id="search_form_1" size="65"  />
  <input type="submit" value="" name="submit" />
</form> 

Then usign the following php script, the form as a result displays all names from my database:

if(isset($_POST['value'])== true && empty($_POST['value']) == false){

$value = mysql_real_escape_string($_POST['value']);

$name_and_surname = explode(" ", "$value ");

$name = $name_and_surname[0];
$surname = $name_and_surname[1]; 

$query = mysql_query(" SELECT `name`, `surname`, `email`, `user_id` FROM users WHERE (surname LIKE '$name%' AND name LIKE '$surname%') OR (surname LIKE '$surname%' AND name LIKE '$name%') LIMIT 10  ");

while($run = mysql_fetch_array($query)){
  $name = $run['name'];
  echo" $name  "; 
}

by executing the above code, I get the first 10 names (because in my sql query have limit 10). All I want is to have a button that when the user press it to extract the rest 10 names and then the rest 10 until all 30 names extracted. How can I do this?

  • 写回答

3条回答 默认 最新

  • dongyun8138 2013-07-03 11:13
    关注

    the sql LIMIT function can handle more than just one number, for example LIMIT 10, 20 will output the 10th to 20th result.

    I'm sure you can figure out something with your form and posting to use that to your advantage

    More info about the SQL LIMIT here: http://php.about.com/od/mysqlcommands/g/Limit_sql.htm

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看