Search code examples
phprecord

Displaying a MySQL Record


I have a form on a page that posts a record id to a page I want to display that record on. The form is:

<form method="post" action="update.php">
<input type="hidden" name="sel_record" value="$id">
<input type="submit" name="update" value="Update this Order">    
</form>

I have tested to see if $id is getting the correct value and it does. When it post to update.php it does not return any values. Any ideas? here is the update page code:

$sel_record = $_POST['sel_record'];

$result = mysql_query("SELECT * FROM `order` WHERE `id` = '$sel_record'") or die     (mysql_error());
    if (!$result) {
    print "Something has gone wrong!";
    } else {
    while ($record = mysql_fetch_array($result)) {
        $id = $record['id'];
        $firstName = $record['firstName'];
        $lastName = $record['lastName'];
        $division = $record['division'];
        $phone = $record['phone'];
        $email = $record['email'];
        $itemType = $record['itemType'];
        $job = $record['jobDescription'];
        $uploads = $record['file'];
        $dateNeeded = $record['dateNeeded'];
        $quantity = $record['quantity'];
        $orderNumber = $record['orderNumber'];
    }
    }

Solution

  • you have not put the php tags <?php ?> inside the html

    <input type="hidden" name="sel_record" value="<?php echo $id; ?>">