简体   繁体   中英

Getting specific table row based on id mysql DB

I have a database where I view all the records, the last column is the table ID, I click it and I want to be able to edit that rows data only, here's what I got but it doesn't waork after updating phpmyadmin:::

      <?php

include "db.inc.php";

$id=$_GET['id'];

      $order = "SELECT * FROM ircb where id='$id'";
      $result = mysql_query($order);
      $row = mysql_fetch_array($result);
      ?>
      <form method="post" action="update.php">
      <input type="hidden" name="id" value="<? echo "$row[id]"?>">

        <tr>        
          <td>Date</td>
          <td>
            <input type="text" name="cdate" 
         value="<? echo "$row[cdate]"?>" size="30"  style="color: black;background-color:#FFFF11">
          </td>
        </tr>  
        <tr>        
          <td>Item</td>
          <td>
            <input type="text" name="item" 
         value="<? echo "$row[item]"?>" size="30"  style="color: black;background-color:#FFFF11">
          </td>
        </tr> 

I end up getting no results returned, when I hover over the link it does display the correct table row id but when I click the link I get empty boxes containing some of the code like <? echo <? echo in the fields..no true values though..and the page header after clicking the link does show ::: ...../edit_form.php?id=8 for row 8 so I assume something in my query is not quite right. thanks

It is because you try to GET a name "id" from a form which is POST ed ;) And also embed PHP in html more clearly. For example, value="<?php echo $row['id']; ?>" is more "true" rather than value="<? echo "$row[id]"?>" ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM