MySQL Forums
Forum List  »  PHP

Re: Only can display first row of tables to a form
Posted by: Peter Brawley
Date: September 06, 2017 06:37PM

> $first_name = ($_get['first_name']);

Problems here ...

(i) the code shown has no <form ... action='get' ...> html code that would populate $_GET[]. Consider reading about html forms and how they work, then download & run & work with form code that is reliably reputed to work till you get the hang of it.

(ii) never accept unfiltered data from a $_get[], it exposes your page to elementary hacks, eg see

> $row=mysqli_fetch_array($result);

That will return one row if it succeeds.


// while($row=mysqli_fetch_array($result)( { //////// RETURNS NO ROWS WHEN I USE A LOOP
// }

That code has no display instructions so it will display nothing. Perhaps you meant something like this?

while( $row=mysqli_fetch_array($result) ) {  
  echo "first name: ", $row['first_name'], " last name: ", $row['last_name'], "<br />"; 

And I'm unclear what the incomplete form at the bottom of the page is for.

Edited 1 time(s). Last edit at 09/06/2017 06:39PM by Peter Brawley.

Options: ReplyQuote

Written By
Re: Only can display first row of tables to a form
September 06, 2017 06:37PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.