duanjurong1347 2013-11-24 12:03
浏览 82
已采纳

如何在mysql中获取id

this is showing all floors of building and i want to show selected building floors how can i do this i use this link floors.php?id=Building1 but its is not working please help me

if i write in there building1 it is working fine where buildingname='building1'

if i use this one where buildingname='$id' it is not working

how can i use like this

floors.php?id=Building1

if i enter this link then it will show all selected building result

<?php
    $max_results = 8;

    $from = (($page * $max_results) - $max_results);


    if(empty($_POST)) {
                  $query = "SELECT * FROM floors  where buildingname='$id' ORDER BY floorno ASC LIMIT $from, $max_results ";
    } 
    $result = mysql_query("SET NAMES utf8"); //the main trick
    $result = mysql_query($query) or die(mysql_error());
    $rows = mysql_num_rows($result);

    $count=0;
    while($row = mysql_fetch_array($result))
        {
            if($count%4==0)
            {
            echo "<tr/>";
            echo "<tr>";
            }

            echo "<td><div align='center'><img src='images/floor.gif' width='60' height='90'></a><p>" . $row['floorno'] . "</p><div></td>";

            $count++;


    }



    echo "</tr>";
    echo "</table>"; 
    echo '</div>';
    ?>
  • 写回答

2条回答 默认 最新

  • dongtuanzi1080 2013-11-24 12:17
    关注
    if(empty($_POST)) {
        $query = "SELECT * FROM floors  where buildingname='$id' ORDER BY floorno ASC LIMIT $from, $max_results ";
    } 
    

    the right is:

    if (isset($_GET['id'])) {
        $id = filter_input(INPUT_GET, 'id');
        $query = "SELECT * FROM floors  where buildingname='$id' ORDER BY floorno ASC LIMIT $from, $max_results ";
    } 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度