Jump to content

text field array


baiju

Recommended Posts

This is my coding, but i cant accept value

<?
for ($i=0; $i<=$count; $i++)
{
$record=db_fetch_object($rs);
?>
<input type="hidden" name="id[<? echo $i; ?>]" value="<? echo $record->linx_id; ?>">
          <tr>
            <td width="50%"><input type="text" value= "<? echo $record->title ?>" name="title[<? echo $i ?>]" size="31"></td>
            <td width="50%"><input type="text" value= "<? echo $record->url ?>" name="url[<? echo $i ?>]" size="31"></td>
          </tr>
<?
}
?>
Link to comment
Share on other sites

Hm...this works for me(script delimiter is needed on my system):
[code]
for ($i=0; $i<=mysql_num_rows($result); $i++)
{
$record=mysql_fetch_object($result);
?>
<input type="hidden" name="id[<?php echo $i; ?>]" value="<?php echo $record->linx_id; ?>">
          <tr>
            <td width="50%"><input type="text" value= "<?php echo $record->title ?>" name="title[<?php echo $i ?>]" size="31"></td>
            <td width="50%"><input type="text" value= "<?php echo $record->url ?>" name="url[<?php echo $i ?>]" size="31"></td>
          </tr>
<?php
}
?>
[/code]

For retreiving values of form you should use loop.Also,if you don't need value of every field you can leave []-blank without $i(id number),like this title[],or url[].
PhP automaticaly read  this var as array...
For example:
if(isset($submit)){
for($i=0;$i<count(title);$i++){
echo title[$i];
}
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.