SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    288
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    have you done an echo($sTemp1); after pulling in your row?

    Code:
    <?php
    $sTemp1 = $iRow['postalcode'];
    echo($sTemp1);
    ?>
    Last edited by ParkinT; Apr 12, 2012 at 11:41. Reason: Wrapped code in CODE tags

  3. #3
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,335
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    Put your 'value' attribute ALSO in quotes. Like this:
    Code:
    <input type="text" name="CustPC" size="10" maxlength="12" value="<?php print $sTemp1 ?>">
    I think the space in the PostalCode is tripping you up.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •