Displaying a Database Field

Hello,

I have a php script that displays the contents of a field from a database.
For this example, I am displaying a postal code (format: XXX XXX)

Here is my code

<?php
$sTemp1 = $iRow[‘postalcode’];
?>

<table border=“0” width=“420”>
<tr>
<td width=“90” align=“left”>Postal Code: </td>
<td align=“left”>
<input type=“text” name=“CustPC” size=“10” maxlength=“12” value=<?php print $sTemp1 ?>>
</td>
</tr></table>

Only the 1st part of the postal code displays - It should display M3M 3M3, but only M3M shows up.
How do I fix this so that the entire field shows up?

Thanks.

have you done an echo($sTemp1); after pulling in your row?


<?php
$sTemp1 = $iRow['postalcode'];
echo($sTemp1);
?>

Put your ‘value’ attribute ALSO in quotes. Like this:


<input type="text" name="CustPC" size="10" maxlength="12" value="<?php print $sTemp1 ?>">

I think the space in the PostalCode is tripping you up.