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
https://forums.phpfreaks.com/topic/25687-text-field-array/#findComment-117244
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
https://forums.phpfreaks.com/topic/25687-text-field-array/#findComment-117257
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.