First word only appearing in a form text box

前端 未结 3 1110
孤城傲影
孤城傲影 2020-12-11 21:10

Yes, I am coding on New Year\'s eve. Anyway, I have what I think is a strange problem (strange enough to need help). The following code works (sort of). The echo on line 6 (

相关标签:
3条回答
  • 2020-12-11 21:36

    You may find that using HEREDOC notation is useful. http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

    $results = $pdo->query($query);
    $out = NULL;
    while ($row = $results->fetch()) 
    { 
        $out. = <<<ENDOUT
        $row["sitename"]
        <form action="dummypage.php" method="post">
        <table width="526">
        <tr>
        <td width="520" align="right">
        <p>Site Name: 
        <input type="text" name="sitename" value="{$row["sitename"]}" />
        </p>
        <p>Program: 
        <input type="text" name="program" value="{$row["program"]}" />
        </p>
        <p>Phone: 
        <input type="text" name="sitephone" value="{$row["sitephone"]}" />
        </p>
        </td>
        </tr>
        </table>
        </form>
    ENDOUT;
    }
    echo $out;
    
    0 讨论(0)
  • 2020-12-11 21:55

    Your code outputs:

    <input type="text" name="sitename" value=Huntington Park>
    

    and it should be:

    <input type="text" name="sitename" value="Huntington Park">
    

    Change:

        <input type="text" name="sitename" value='.$row["sitename"].'>
    

    to:

        <input type="text" name="sitename" value="'.$row["sitename"].'">
    

    Since the value is not in quotes - it picks only the first string! You should do the same with the other inputs.

    0 讨论(0)
  • 2020-12-11 22:00

    Change:

    <input type="text" name="sitename" value='.$row["sitename"].'>
    

    to:

    <input type="text" name="sitename" value="'.$row["sitename"].'">
    
    0 讨论(0)
提交回复
热议问题