Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正在尝试拉入此查询中的第二条记录_Php_Mysql_Sql - Fatal编程技术网

Php 正在尝试拉入此查询中的第二条记录

Php 正在尝试拉入此查询中的第二条记录,php,mysql,sql,Php,Mysql,Sql,我使用以下查询将数据拉入html页面。url类似于example.com/sss.php?eventid=1111。因此,查询所做的是调用事件id和1记录>而不是事件id。我如何调用1记录>而不是事件id,以便将其用于下一个按钮 $eventid = _GET['eventid'] $resultnext = mysql_query("SELECT tblimage.*, events.* FROM events LEFT JOIN tblimage ON events.id_user =

我使用以下查询将数据拉入html页面。url类似于example.com/sss.php?eventid=1111。因此,查询所做的是调用事件id和1记录>而不是事件id。我如何调用1记录>而不是事件id,以便将其用于下一个按钮

$eventid = _GET['eventid']

$resultnext = mysql_query("SELECT tblimage.*, events.* 
FROM events LEFT JOIN tblimage ON events.id_user = tblimage.userid 
WHERE event_id >= '$eventid' 
Order By event_id DESC 
LIMIT 2")

将限制2更改为以下内容:

LIMIT 2, 1
$eventid = _GET['eventid']

$resultnext = mysql_query("SELECT events.*, tblimage.*
                           FROM events LEFT JOIN tblimage 
                             ON events.id_user = tblimage.userid 
                           WHERE event_id > '$eventid' 
                           Order By event_id 
                           LIMIT 1");

$nResults = mysql_num_rows($resultnext);
if ($nResults > 0) {
  $row = mysql_fetch_row($resultnext);

  echo $row[0]; // 1112   would be what is returned if event id was the first field
  echo $row[1]; // would be what ever the second field is

  <a class="ui-pagination-next" 
            id="next" 
            data-ajax="true" 
            href="eventviewtester.php?eventid=<?php echo $row[0];?>"               
            style="display:none;"
  ></a> 
} else {
   //No Records were returned
}

将限制2更改为以下内容:

LIMIT 2, 1
$eventid = _GET['eventid']

$resultnext = mysql_query("SELECT events.*, tblimage.*
                           FROM events LEFT JOIN tblimage 
                             ON events.id_user = tblimage.userid 
                           WHERE event_id > '$eventid' 
                           Order By event_id 
                           LIMIT 1");

$nResults = mysql_num_rows($resultnext);
if ($nResults > 0) {
  $row = mysql_fetch_row($resultnext);

  echo $row[0]; // 1112   would be what is returned if event id was the first field
  echo $row[1]; // would be what ever the second field is

  <a class="ui-pagination-next" 
            id="next" 
            data-ajax="true" 
            href="eventviewtester.php?eventid=<?php echo $row[0];?>"               
            style="display:none;"
  ></a> 
} else {
   //No Records were returned
}

如果您有以下事件ID,那么您现在拥有它的方式是:111111111211311141115116117。您的查询将返回1116和1117。因此,我认为您可能需要做的就是将
DESC
更改为
ASC
。这样做会产生1111和1112

编辑,如果您只需要按钮的下一条记录,请使用
LIMIT 1
和类似以下内容:

LIMIT 2, 1
$eventid = _GET['eventid']

$resultnext = mysql_query("SELECT events.*, tblimage.*
                           FROM events LEFT JOIN tblimage 
                             ON events.id_user = tblimage.userid 
                           WHERE event_id > '$eventid' 
                           Order By event_id 
                           LIMIT 1");

$nResults = mysql_num_rows($resultnext);
if ($nResults > 0) {
  $row = mysql_fetch_row($resultnext);

  echo $row[0]; // 1112   would be what is returned if event id was the first field
  echo $row[1]; // would be what ever the second field is

  <a class="ui-pagination-next" 
            id="next" 
            data-ajax="true" 
            href="eventviewtester.php?eventid=<?php echo $row[0];?>"               
            style="display:none;"
  ></a> 
} else {
   //No Records were returned
}
$eventid=\u GET['eventid']
$resultnext=mysql\u查询(“选择事件。*,tblimage*
从左侧事件加入tblimage
在events.id_user=tblimage.userid上
其中event_id>“$eventid”
按事件\u id排序
限额1”);
$nResults=mysql\u num\u行($resultnext);
如果($nResults>0){
$row=mysql\u fetch\u row($resultnext);
echo$row[0];//如果事件id是第一个字段,则返回1112
echo$row[1];//将是第二个字段
}否则{
//没有返回任何记录
}

我不是PHP专家。我只是在搜索的基础上整理了这些代码。
echo$行[0]
显示了如何获取各个数据段。将其与按钮代码一起使用。

如果您有以下事件ID,则使用现在的方式:1111111112112113111411516117。您的查询将返回1116和1117。因此,我认为您可能需要做的就是将
DESC
更改为
ASC
。这样做会产生1111和1112

编辑,如果您只需要按钮的下一条记录,请使用
LIMIT 1
和类似以下内容:

LIMIT 2, 1
$eventid = _GET['eventid']

$resultnext = mysql_query("SELECT events.*, tblimage.*
                           FROM events LEFT JOIN tblimage 
                             ON events.id_user = tblimage.userid 
                           WHERE event_id > '$eventid' 
                           Order By event_id 
                           LIMIT 1");

$nResults = mysql_num_rows($resultnext);
if ($nResults > 0) {
  $row = mysql_fetch_row($resultnext);

  echo $row[0]; // 1112   would be what is returned if event id was the first field
  echo $row[1]; // would be what ever the second field is

  <a class="ui-pagination-next" 
            id="next" 
            data-ajax="true" 
            href="eventviewtester.php?eventid=<?php echo $row[0];?>"               
            style="display:none;"
  ></a> 
} else {
   //No Records were returned
}
$eventid=\u GET['eventid']
$resultnext=mysql\u查询(“选择事件。*,tblimage*
从左侧事件加入tblimage
在events.id_user=tblimage.userid上
其中event_id>“$eventid”
按事件\u id排序
限额1”);
$nResults=mysql\u num\u行($resultnext);
如果($nResults>0){
$row=mysql\u fetch\u row($resultnext);
echo$row[0];//如果事件id是第一个字段,则返回1112
echo$row[1];//将是第二个字段
}否则{
//没有返回任何记录
}

我不是PHP专家。我只是在搜索的基础上整理了这些代码。
echo$行[0]
显示了如何获取各个数据段。将其与按钮代码结合使用。

好的,但是如果我在1111记录中使用1112,我该如何呼叫1112以用于下一个按钮?@Steven,我不确定我是否明白你的意思。你的意思是你更愿意把1112作为结果中的第一条记录吗?请看我的编辑,了解我认为您需要的内容。不,让我试着更好地解释。好的,所以url中有1111,所以页面上的数据需要有该记录的表详细信息。但我想有一个下一个按钮,然后在1112拉。我如何设置下一个按钮来阅读1112?让我告诉你我是如何拥有下一个按钮的@Steven,我更新了我的答案来显示如何通过php获取下一个事件id。好的,但是如果我记录了1111,我如何调用1112来使用下一个按钮?@Steven,我不确定我是否明白你的意思。你的意思是你更愿意把1112作为结果中的第一条记录吗?请看我的编辑,了解我认为您需要的内容。不,让我试着更好地解释。好的,所以url中有1111,所以页面上的数据需要有该记录的表详细信息。但我想有一个下一个按钮,然后在1112拉。我如何设置下一个按钮来阅读1112?让我告诉你我是如何拥有下一个按钮的@Steven,我更新了我的答案,以显示如何通过php获取下一个事件id。