doulin9679 2016-05-23 18:10
浏览 29
已采纳

你如何使用mysqli_stmt_fetch()[关闭]获取id

im new in mysqli prepared and i convert all my mysqli to mysqli prepared.

i want to get the id of the specific data and i can easily do that in mysqli. here is my old code:

        echo "<th>".$record['first_name']."</th>";
        echo "<th>".$record['middle_name']."</th>";
        echo "<th>".$record['last_name']."</th>";
        echo "<th>".$record['date_added']."</th>";
        echo "<th>".$record['crew_status']."</th>";
        echo "<th><a target='_blank' href='review.php?id={$record['id']}'>Click</a></th>";
        echo '</tr>';

and in the mysqli prepared, this is my code:

        while($record = mysqli_stmt_fetch($stmt)) {
        echo "<tr>";
        echo "<th>".sprintf("%s", $col2)."</th>";
        echo "<th>".sprintf("%s", $col3)."</th>";
        echo "<th>".sprintf("%s", $col4)."</th>";
        echo "<th>".sprintf("%s", $col18)."</th>";
        echo "<th>".sprintf("%s", $col19)."</th>";
        echo "<th><a target='_blank' href='review.php?id=$rows[] = $col1'>Click</a></th>";
        echo '</tr>';

below is my entire code:

    $search = 'PENDING';
    $query = "SELECT * FROM `crew_info` WHERE `crew_status` = ?";
    $stmt = mysqli_prepare($conn, $query);
    mysqli_stmt_bind_param($stmt, 's', $search);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_bind_result($stmt, $col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8, $col9, $col10, $col11, $col12, $col213, $col14, $col15, $col16, $col17, $col18, $col19);

echo '<!DOCTYPE html>
    <html>
    <head>
        <title>All Crew</title>
    </head>
    <body>
    <form method="POST">
        <table border="2" align="center" width="600" cellspacing="3" cellpadding="4">
            <tr>
                <th>First Name</th>
                <th>Middle Name</th>
                <th>Last Name</th>
                <th>Date Added</th>
                <th>Status</th>
                <th>REVIEW</th>
            </tr>
            <tr>';
            $rows = array();
            while($record = mysqli_stmt_fetch($stmt)) {
            echo "<tr>";
            echo "<th>".sprintf("%s", $col2)."</th>";
            echo "<th>".sprintf("%s", $col3)."</th>";
            echo "<th>".sprintf("%s", $col4)."</th>";
            echo "<th>".sprintf("%s", $col18)."</th>";
            echo "<th>".sprintf("%s", $col19)."</th>";
            echo "<th><a target='_blank' href='review.php?id=$rows[] = $col1'>Click</a></th>";
            echo '</tr>';
          }
         echo '</table>
    </form>
    </body>
    </html>';

展开全部

  • 写回答

1条回答 默认 最新

  • doushi8187 2016-05-23 18:20
    关注

    instead using

    $rows[] = $col1
    

    why don you change it to $col1 only? remove the $rows[]

    change your code from:

        echo "<th><a target='_blank' href='review.php?id=$rows[] = $col1'>Click</a></th>";
    

    to this

        echo "<th><a target='_blank' href='review.php?id=$col1'>Click</a></th>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 雄安新区高光谱数据集的下载网址打不开
  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
  • ¥15 Python中关于代码运行报错的问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部