Jump to content

Recommended Posts

I'm trying to edit records from the web. I can display the list of records, but I can't display the lists of records to edit.

I am trying to display the records with the use of an id.

Basically, I trying to SELECT a record WHERE id=$id.

Here is the code:

[code]
<!--set up the table -->
<TABLE BORDER="1" CELLPADDING="5">



<TR>
  <TH>Title</TH>
  <TH>First name</TH>
  <TH>Last name</TH>
  <TH>Date of birth</TH>
  <TH>UK residency</TH>
  <TH>Marital status</TH>
  <TH>Disability</TH>
  <TH>Employment status</TH>
  <TH>Address line 1</TH>
  <TH>Area</TH>
  <TH>Town</TH>
  <TH>County</TH>
  <TH>Post code</TH>
  <TH>Telephone work</TH>
  <TH>Telephone home</TH>
  <TH>Fax number</TH>
  <TH>Email</TH>
</TR>
<?

$id = isSet($_POST['id']) ? $_POST['id'] : '';

include 'includes/db_conn.txt';



// build and execute the query
    $select = "SELECT title, first_name, surname, date_of_birth, uk_residency,
    marital_status, disability, employment_status, address_line_1, area, town,
    county, post_code, telephone_work, telephone_home, fax_number, email FROM policy_holder
    WHERE id=$id";
    $result= mysqli_query($link, $select);

while ($row = mysqli_fetch_array($result)) {
  $t = $row['title'];
  $fn = $row['first_name'];
  $sn = $row['surname'];
  $dob = $row['date_of_birth'];
  $uk = $row['uk_residency'];
  $ms = $row['marital_status'];
  $d = $row['disability'];
  $es = $row['employment_status'];
  $ad1 = $row['address_line_1'];
  $a = $row['area'];
  $tn = $row['town'];
  $c = $row['county'];
  $pc = $row['post_code'];
  $tw = $row['telephone_work'];
  $th = $row['telephone_home'];
  $fax = $row['fax_number'];
  $em = $row['email'];
  $id = $row['id'];

  echo <<<END
<TR>
  <TD>$t</TD>
  <TD>$fn</TD>
  <TD>$sn</TD>
  <TD>$dob</TD>
  <TD>$uk</TD>
  <TD>$ms</TD>
  <TD>$d</TD>
  <TD>$es</TD>
  <TD>$ad1</TD>
  <TD>$a</TD>
  <TD>$tn</TD>
  <TD>$c</TD>
  <TD>$pc</TD>
  <TD>$tw</TD>
  <TD>$th</TD>
  <TD>$fax</TD>
  <TD>$em</TD>
  <TD><a href="mysqli_list_update.php?id=$id">Edit details</a></TD>
</TR>
END;
}
?>
<!-- Close table -->
</TABLE>
[/code]

I get this message when I trying to run it:

[quote]Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in E:\Program Files\Apache Group\Apache2\htdocs\policylist.php on line 40
[/quote]

Help me please!!!
Link to comment
https://forums.phpfreaks.com/topic/18479-updating-an-existing-record/
Share on other sites

This is the error I get now with adding - $result= mysql_query($link, $select) or die(mysql_error($link));

[quote]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4[/quote]

I don't know where it is referring to.  Can somebody look at my code to see where the problem is.

Look above in the post to see my code for the list page.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.