dourun2990 2014-10-19 01:41 采纳率: 100%
浏览 46
已采纳

(PHP / SQL)不会基于查询参数从数据库中提取

So I'm trying to build a php page to edit records. Right now I'm trying to get it to take the ID in the url and return data based on that. I can echo out the id from the url, that's fine, but the sql query isn't doing anything. I threw the 2 echo's at the bottom to try to get them to display values. The ID displays fine, coming from the URL, but it should display the name corrosponding with that gigid and isn't.

Any ideas?

<?php

 // query db

 $gigid = $_GET['gigid'];
 $result = ORM::for_table('gigs')->where('gigid', $gigid)
 or die(mysql_error()); 
 $row = mysqli_fetch_array($result);

 // check that the 'id' matches up with a row in the databse
 if($row)
 {
 // get data from db
        $gig_name = $row['gig_name'];
        $gig_type = $row['gig_type'];
        $gig_date = $row['gig_date'];
        $gig_customer = $row['gig_customer'];
        $gig_venue = $row['venue_name'];
        $gig_fee = $row['gig_fee'];
        $gig_status = $row['gig_status'];   
 }
mysqli_close($con);
 ?>
 <?php echo $gigid; ?>
 <?php echo $gig_name; ?>
  • 写回答

1条回答 默认 最新

  • douye2111 2014-10-19 01:48
    关注

    I would just use mysqli_query for any database manipulation.

    . . .
    $con = mysqli_connect("i.p.addr","username","password","database");
    $result = mysqli_query($con, "SELECT * FROM gigs WHERE gigid=$gigid") or die(mysqli_error($con)); 
    $row = mysqli_fetch_array($result);
    mysqli_close($con);
    

    UPDATE:: changed to mysqli_error()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路