I am using PHP to get fields from my database I am using the following code:
$result = mysql_query("SELECT * FROM product_form WHERE id=1");
while($row = mysql_fetch_array($result))
{
$ProductName = $row['ProductName'];
$ProductName1 = $row['ProductName1'];
$ProductName2 = $row['ProductName2'];
$ProductName3 = $row['ProductName3'];
$ProductName4 = $row['ProductName4'];
$ProductName5 = $row['ProductName5'];
}
I then am displaying the filed on the page like this:
<? echo("<input type='text' name = 'product_name' size='29' value='$ProductName'/>");?>
<? echo("<input type='text' name = 'product_name1' size='29' value='$ProductName1'/>");?>
<? echo("<input type='text' name = 'product_name2' size='29' value='$ProductName2'/>");?>
<? echo("<input type='text' name = 'product_name3' size='29' value='$ProductName3'/>");?>
<? echo("<input type='text' name = 'product_name4' size='29' value='$ProductName4'/>");?>
<? echo("<input type='text' name = 'product_name5' size='29' value='$ProductName5'/>");?>
The problem I am facing is that ProductName & ProductName1 are displaying correctly but ProductName2, ProductName3, ProductName4, ProductName5 is only showing the first word from the database.
However when I view it in phpMyAdmin it is showing more then one word for the field.
I seem to be able to echo and display it on the page but can’t echo/display the full field in a text box, it seems to drop everything after a ‘space’ when displaying it in a text box but it does work when just displaying it on a page not in a text box.
Anyone know where I am going wrong?
Create new test.php and paste following code into it and run.
Now see what comes as result.