Jump to content

populate text box values


amalafrida

Recommended Posts

how do I populate the textbox values in form.html?

Thanks in advance for any help you might offer.

 

//formfill.php
<?php
$hours="akj";
//split string characters to array
$hours_array = str_split($hours);
//iterate through the characters in the array
foreach($hours_array as $char)
{
    echo($char."<br />");
    //somehow populate text boxes in form.html
}
?>
//form.html
<html>
<body>

<form>
    <table>
        <tr>
            <td><input type="text" name="hour[0]" value="" /></td>
            <td><input type="text" name="hour[1]" value="" /></td>
            <td><input type="text" name="hour[2]" value="" /></td>
        </tr>
    </table>
</form>

</body>
</html>

Link to comment
Share on other sites

Thanks for the response, requinix. However, I'm still not clear on this. Here's the code. When I call form_fill.php ... just a blank screen.

 

<html>
<body>

<?php
$hours="akj";
$hours_array = str_split($hours);
foreach($hours_array as $value)
{
        <form>
            <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" />
        </form>
}
?>
</body>
</html>

Link to comment
Share on other sites

my /etc/php5/cli/php.ini file shows:

; error_reporting

:  Default Value: E_ALL & ~E_NOTICE

;  Development Value: E_ALL | E_STRICT

;  Production Value: E_ALL & ~E_DEPRECATED

error_reporting = -1

 

; display_errors

;  Default Value: On

;  Development Value: On

;  Production Value: Off

display_errors = On

 

restarted apache

still just a blank screen when I call form_fill.php

 

view source code ... nothing.

 

Link to comment
Share on other sites

phpinfo() reports:

Loaded Configuration File /etc/php5/apache2/php.ini

Scan this dir for additional .ini files /etc/php5/apache2/conf.d

 

changed php.ini to:

Default Value: On

restarted apache

reloaded form_fill.php

received error message:

Parse error: syntax error, unexpected '<' in formfill.php on line 9

but I don't see an error at line 9 ... code follows

 

form_fill.php follows:

<html>
<body>

<?php
$hours="akj";
$hours_array = str_split($hours);
foreach($hours_array as $value)
{
        <form> //line 9
            <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" />
        </form>
}
?>
</body>
</html>

 

Link to comment
Share on other sites

This should fix your parse error.

<html>
<body>

<?php
$hours="akj";
$hours_array = str_split($hours);
foreach($hours_array as $value)
{
?>
        <form>
            <input name="lname" type="text" value="<?php echo htmlspecialchars( $value); ?>" />
        </form>
<?php 
}
?>
</body>
</html>

Link to comment
Share on other sites

wow! snapped it right into line. I don't really get that final <?php ?> ... but it works and I'll note it.

 

thanks to everyone for working me through this.

 

pleasant to have gotten the immediate problem solved, but, perhaps more delightful, was to watch the diagnostic process, especially the phpinfo() bit.

 

once again, many thanks to everyone.

Link to comment
Share on other sites

Just to be clear, I had you follow the steps to enable error reporting so you would at least have a fighting chance to find these types of errors without taking the time to post them to a message forum and wait for an answer. I could have simply corrected your code and reposted it, but you what would you have learned? Being able to debug code is an important part of coding.

Link to comment
Share on other sites

yes, yes.  i think the approach was perfect. i'd much rather learn to handle/explore/diagnose than simply have the answer handed to me.

 

knowing that first step ... looking at php.ini and phpinfo() were two priceless tips.

 

of course, I'll be back for further info, but before I do, I'll certainly have a look at error reports ... and phpinfo() readout.

 

once again, thanks for the assistance/solution/guidance.

 

a.

Link to comment
Share on other sites

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.