dongye7231
2018-09-22 08:04
浏览 105
已采纳

PHP Mysqli代码不显示查询结果

I want to output data from a query result. the query uses a print_r(json_encode($regions)) in another php page but it is not outputting anything. I have no errors in php, am I doing something wrong in mysqli code that it is not echoing anything?

//connecting to database
    <?php
    require_once('DbConnection.php');   
    //querying the database 
    $region_id = isset( $_GET['region_id'] )? $_GET['region_id']: false;
    $sql=mysqli_query($connection,"SELECT sales.region_id, sales.image_name,                 sales.price, sales.location, sales.Terms, sales.Contacts
    FROM sales INNER JOIN region ON sales.region_id=region.region_id  where region_id = $region_id") or die(mysqli_error($connection));
    $result = mysqli_query($connection,"SELECT sales.region_id, sales.image_name, sales.price, sales.location, sales.Terms, sales.Contacts FROM sales INNER JOIN region ON sales.region_id=region.region_id  where region_id = $region_id");             
    while ($row = mysql_fetch_assoc($sql)) {
             ?>
    <div class="col-md-4">
    <div class="thumbnail">
    <a href="<?php echo "http://" . $_SERVER['SERVER_NAME'] ?>/photo/imageuploads/<?php echo $row["image_name"]; ?>">
    <img src="<?php echo "http://" . $_SERVER['SERVER_NAME'] ?>/photo/imageuploads/<?php echo $row["image_name"]; ?>" alt="Lights" style="width:100%">
    <div class="caption">
    Image Name:<?php echo $row["image_name"]; ?>
    Price:<?php echo $row["price"]; ?>
    Location`enter code here`:<?php echo $row["location"]; ?>
    Terms:<?php echo $row["Terms"]; ?>
    Contacts:<?php echo $row["Contacts"]; ?>
    </div>
     </a>
    </div>
    </div>
    <?php
    }
    ?>

图片转代码服务由CSDN问答提供 功能建议

我想从查询结果中输出数据。 该查询在另一个php页面中使用 print_r(json_encode($ regions))</ code>,但它没有输出任何内容。 我在php中没有错误,我在mysqli代码中做错了它没有回应任何东西吗?</ p>

  //连接到数据库
&lt;?php 
 require_once  ( 'DbConnection.php');  
 //查询数据库
 $ region_id = isset($ _GET ['region_id'])?  $ _GET ['region_id']:false; 
 $ sql = mysqli_query($ connection,“SELECT sales.region_id,sales.image_name,sales.price,sales.location,sales.Terms,sales.Contacts 
 FROM FROM INNER  JOIN区域ON sales.region_id = region.region_id where region_id = $ region_id“)或die(mysqli_error($ connection)); 
 $ result = mysqli_query($ connection,”SELECT sales.region_id,sales.image_name,sales.price  ,sales.location,sales.Terms,sales.Contacts FROM sales INNER JOIN region ON sales.region_id = region.region_id where region_id = $ region_id“);  
 while($ row = mysql_fetch_assoc($ sql)){
?&gt; 
&lt; div class =“col-md-4”&gt; 
&lt; div class =“thumbnail”&gt; 
&lt;  ; a href =“&lt;?php echo”http://“。$ _SERVER ['SERVER_NAME']?&gt; / photo / imageuploads /&lt;?php echo $ row [”image_name“];?&gt;”&gt;  ; 
&lt; img src =“&lt;?php echo”http://“。$ _SERVER ['SERVER_NAME']?&gt; / photo / imageuploads /&lt;?php echo $ row [”image_name“] ;?  &gt;”中 alt =“Lights”style =“width:100%”&gt; 
&lt; div class =“caption”&gt; 
图片名称:&lt;?php echo $ row [“image_name”];  ?&gt; 
价格:&lt;?php echo $ row [“price”];  ?&gt; 
位置`输入代码此处`:&lt;?php echo $ row [“location”];  ?&gt; 
条款:&lt;?php echo $ row [“Terms”];  ?&gt; 
联系人:&lt;?php echo $ row [“Contacts”];  ?&gt; 
&lt; / div&gt; 
&lt; / a&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt;?php 
} 
?&gt; 
 </ code  > </ pre> 
 </ div>

1条回答 默认 最新

相关推荐 更多相似问题