嗨,我试图在点击标题名称时显示数据的特定细节。这是我的代码。如果我在blog.php中使用where where $id=$_GET['blog_title']
注意:未定义的索引:C:\ xampp \ htdocs \ accounting \ blogs.php中的标题 在第6行
警告:mysql_fetch_array()期望参数1是资源, 第7行的C:\ xampp \ htdocs \ accounting \ images.php中给出的布尔值
images.php
<table>
<tbody>
<?php include "blogs.php" ;
while($row = mysql_fetch_array($result))
{?>
<tr>
<td><img src="admin/upload/<?php echo $row['image'];?>" height="100" width="100"/></td>
<td><a href="blogimages.php?title=<?php echo $row['blog_title'];?>"><?php echo $row['blog_title']; ?></a></td>
</tr>
<?php }?>
</tbody>
</table>
blog.php的
<?php
$connection = mysql_connect("localhost", "root", "") or die(mysql_error());
$db = mysql_select_db("accountant", $connection);
$id=$_GET['title'];
$res = "SELECT * FROM blogs WHERE blog_title=$id";
$result=mysql_query($res);
?>
答案 0 :(得分:1)
在单个页面上,您可以按以下方式执行此操作: -
<强> blog.php的: - 强>
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
$connection = mysqli_connect("localhost", "root", "","accountant");
$new_array = array();
if(isset($_GET['title'])){
if($connection){
$res = "SELECT image,blog_title FROM blogs WHERE blog_title='".$_GET['title']."'";
$result=mysqli_query($connection,$res);
$i = 0;
if(mysqli_num_row($result)>0){
while($row = mysqli_fetch_assoc($result)){
$new_array[$i]['image'] = $row['image'];
$new_array[$i]['blog_title'] = $row['blog_title'];
$i++;
}
}else{
echo "no record exist";
}
}else{
echo mysqli_error();
}
}else{
echo "title is not selected";
}
?>
<table>
<tbody>
<?php if(count($new_array) >=1){?>
<?php foreach($new_array as $new_arr){?>
<tr>
<td><img src="admin/upload/<?php echo $new_arr['image'];?>" height="100" width="100"/></td>
<td><a href="blogimages.php?title=<?php echo $new_arr['blog_title'];?>"><?php echo $new_arr['blog_title']; ?></a></td>
</tr>
<?php }?>
</tbody>
</table>
<?php}?>