baiju Posted October 31, 2006 Share Posted October 31, 2006 HiIs it possible to make text field as array.If possible how we can retrive the values from form. Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 31, 2006 Share Posted October 31, 2006 You mean that every word in textfield be one element of array? Quote Link to comment Share on other sites More sharing options...
baiju Posted October 31, 2006 Author Share Posted October 31, 2006 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><?}?> Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 31, 2006 Share Posted October 31, 2006 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];} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.