Php 分页未定义索引:id
大家好,最近我在php上做了一些简单的分页,我有一些页面需要在哪里设置从数据库查询的“id”条件。它正在发挥作用 但当我使用分页时,我需要url中的一些id,代码不会读取id,这是我的代码Php 分页未定义索引:id,php,mysql,pagination,Php,Mysql,Pagination,大家好,最近我在php上做了一些简单的分页,我有一些页面需要在哪里设置从数据库查询的“id”条件。它正在发挥作用 但当我使用分页时,我需要url中的一些id,代码不会读取id,这是我的代码 $page=1;//Default page $limit=1;//Records per page buat nampilin banyak nya $start=0;//starts displaying records from 0 if(isset($_GET['page']) &&
$page=1;//Default page
$limit=1;//Records per page buat nampilin banyak nya
$start=0;//starts displaying records from 0
if(isset($_GET['page']) && $_GET['page']!=''){
$page=$_GET['page'];
}
$start=($page-1)*$limit;
$sql=mysql_query("select id_jualan from jualan where kategori='$_GET[id]'");
$rows=mysql_num_rows($sql);
$sql = mysql_query("select * from jualan where kategori='$_GET[id]' order by id_jualan ASC LIMIT $start, $limit");
$no=1;
这是调用页面的代码
<?php echo pagination($limit,$page,'gallery.php?page=',$rows); //call function to show pagination ?>
但是如果我没有正确使用where条件分页,
问题是。。。
第二页如何识别where条件的id??
非常感谢,希望有一个正确的答案:)未定义的索引:id->如果您的url中没有定义id,那么您正在使用$\u GET['id']。使用:
if(isSet($_GET['id']) && $_GET['id'])
{
$sql = mysql_query("select id_jualan from jualan where kategori='" . mysql_real_escape_string($_GET[id]) . "'");
$rows = mysql_num_rows($sql);
// ...
}
您是否确实尝试将其传递到服务器?其中是
pagination()
函数,另外可能是因为url中未设置id
参数。设置了pagination函数,并且在url中也设置了id参数,在第一页,它可以正常工作,但在第二页,他们在第15行的D:\xampp\htdocs\project\gallery.php中说Notice:Undefined index:id,在第17行的D:\xampp\htdocs\project\gallery.php中说Notice:Undefined index:id,在第15行和第17行是上面第二页的行mysql\u查询,在前面:Notice:Undefined index:id第15行的D:\xampp\htdocs\project\gallery.php注意:在我用代码更改后,第17行的D:\xampp\htdocs\project\gallery.php中的未定义索引:id未定义:注意:第163行的D:\xampp\htdocs\project\gallery.php中的未定义变量:sql警告:mysql\u fetch\u array()预期参数1是资源,第163行的D:\xampp\htdocs\project\gallery.php中给出null注意:未定义变量:第181行的D:\xampp\htdocs\project\gallery.php中的行您使用的是未定义的变量和索引。对所有这些变量/索引使用isSet()方法。