Jump to content

Recommended Posts

Hi,

 

im trying to display mysql results in a form but for some reason im only getting the first field and not the rest, it will show me the "firstname" field but nothing else, for the life of me cant figure out why, any help would be appreciated.

 

<?php
$sql = mysql_query("SELECT * FROM invoicing.customers WHERE id = '$id' ");
$sql_res = mysql_query($sql); //execute query

while($row = mysql_fetch_array($sql))
  
$firstname=$row['firstname'];
$lastname=$row['lastname'];
$address=$row['address'];
$suburb=$row['suburb'];
$postcode=$row['postcode'];
$phone1=$row['phone1'];
$phone2=$row['phone2'];
$email1=$row['email1'];
$email2=$row['email2'];
$billingemail=$row['billingemail'];
?>

 

and then i display it in forms with

 

<td>First Name<input name="firstname" style="width: 191px" type="text" class="style15" value="<?php print "$firstname" ?>"></td>
<td>Last Name<input name="lastname" type="text" class="style14" value="<?php print "$lastname" ?>" style="width: 191px"> </td>

 

has it got something to do with the fact im using $row?

 

Link to comment
https://forums.phpfreaks.com/topic/136624-not-displaying-all-results/
Share on other sites

Surprised you got any results at all...

 

Try:

 

$sql = mysql_query("SELECT * FROM customers WHERE id = '$id' ");
$sql_res = mysql_query($sql); //execute query

while($row = mysql_fetch_array($ql_res))
{ 
$firstname=$row['firstname'];
$lastname=$row['lastname'];
$address=$row['address'];
$suburb=$row['suburb'];
$postcode=$row['postcode'];
$phone1=$row['phone1'];
$phone2=$row['phone2'];
$email1=$row['email1'];
$email2=$row['email2'];
$billingemail=$row['billingemail'];
}

He meant:

$sql = mysql_query("SELECT * FROM customers WHERE id = '$id' ");
$sql_res = mysql_query($sql); //execute query

while($row = mysql_fetch_array($sql_res))  //Forget the "S"
{ 
$firstname=$row['firstname'];
$lastname=$row['lastname'];
$address=$row['address'];
$suburb=$row['suburb'];
$postcode=$row['postcode'];
$phone1=$row['phone1'];	
$phone2=$row['phone2'];	
$email1=$row['email1'];	
$email2=$row['email2'];
$billingemail=$row['billingemail'];
}

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.