douwen5066 2013-11-25 09:18
浏览 23

如何在mysql中更新表单选择2行值

How to update a form select 2 row value in mysql using php

i have this link

floorsedit.php?id=Building1&floorno=1

when i visit this link it is showing blank please tell me why it is showing blank and why it is not update and i think there is a problem thats why it is not showing nothing

$sql="SELECT * FROM $tbl_name where buildingname='".$id."' and floorno='".$floorno."' ";

please help me to fix this issue

thanks ...

this is main page

floorsedit.php

    $host="localhost"; // Host name 
    $username="root"; // Mysql username 
    $password=""; // Mysql password 
    $db_name="building"; // Database name 
    $tbl_name="floors"; // Table name

    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");

    // get value of id that sent from address bar
     $id = $_GET['id']; 

     $floorno = $_GET['$floorno'];

    // Retrieve data from database 
    $sql="SELECT * FROM $tbl_name where buildingname='".$id."' and floorno='".$floorno."' ";
    $result=mysql_query($sql);
    $rows=mysql_fetch_array($result);
    ?>
    <?php
    // close connection 
    mysql_close();
    ?>

and this is a form
<form name="form1" method="post" action="update_ac.php" class="registration_form">

  <fieldset>
    <legend>New Floor </legend>
<input name="id" type="hidden" id="buildingname" value="<? echo $rows['buildingname']; ?>">

    <p>Create A New Floor of Building <span class="style4" style="background:#EAEAEA none repeat scroll 0 0;line-height:1;margin-left:410px;;padding:9px 9px;">Please Fill the All Info </span> </p>

    <div class="elements">
      <label for="buildingname">Building Name  :</label>
      <input type="text" id="buildingname" name="buildingname" value="<? echo $rows['buildingname']; ?>" size="25" />
       <label2 for="floorno">Floor No   :</label2>
      <input type="text" id="floorno" name="floorno" value="<? echo $rows['floorno']; ?>" size="25" />
</div>
    <div class="elements">
      <label for="flatno">Floor No of Flats  :</label>
      <input type="text" id="flatno" name="flatno" value="<? echo $rows['flatno']; ?>" size="25" />

    </div>

    </p >

    <div class="submit">
<input type="submit" name="Submit" value="Submit">
    </div>
  </fieldset>
</form>

update_ac.php

<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="building"; // Database name 
$tbl_name="floors"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// update data in mysql database 
$sql="UPDATE $tbl_name SET buildingname='$buildingname', floorno='$floorno', flatno='$flatno' WHERE buildingname='$id' AND floorno='$floorno'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='vieweditfloor.php'>View result</a>";
}

else {
echo "ERROR";
}

?>
  • 写回答

1条回答 默认 最新

  • douxian3828 2013-11-25 09:36
    关注

    In the floorsedit.php , use

    $floorno = $_GET['floorno'];
    

    rather than,

    $floorno = $_GET['$floorno'];
    

    I think the issue is in this line. Hope it helps...

    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行