june_c21 Posted March 15, 2010 Share Posted March 15, 2010 hi, i getting error when i try to execute this code for (i=1 ; i<11 ; i++) { echo "<tr>"; echo"<td><p><strong>[i]</strong></p></td> "; echo"<td><textarea name='causes[i]' cols='30' id='causes' value='$causes[i]'></textarea></td>"; echo"<td><textarea name='corrective_action[i]' cols='50' id='corrective_action' value='$corrective_action[i]'></textarea></td>"; echo"<td><input name='name[i]' type='text' id='name' value='$name[i]' /></td>"; echo "<td><input name='date[i]' type='text' id='date' value='$date[i]' /></td>"; echo "<td><textarea name='remarks[i]' cols='50' id='remarks' value='$remarks[i]'></textarea></td>"; echo"</tr>"; } anyone can tell me what's wrong ?? thanks a lot Link to comment https://forums.phpfreaks.com/topic/195248-help-in-this-line/ Share on other sites More sharing options...
khr2003 Posted March 15, 2010 Share Posted March 15, 2010 what kind of error? Link to comment https://forums.phpfreaks.com/topic/195248-help-in-this-line/#findComment-1026160 Share on other sites More sharing options...
Stephen Posted March 15, 2010 Share Posted March 15, 2010 You didn't use $ before the variable names... and I recommend using brackets when directly using variables within double quotes: for ($i=1; $i<11; $i++) { echo "<tr>"; echo"<td><p><strong>[{$i}]</strong></p></td> "; echo"<td><textarea name='causes[{$i}]' cols='30' id='causes' value='{$causes[$i]}'></textarea></td>"; echo"<td><textarea name='corrective_action[{$i}]' cols='50' id='corrective_action' value='{$corrective_action[$i]}'></textarea></td>"; echo"<td><input name='name[{$i}]' type='text' id='name' value='{$name[$i]}' /></td>"; echo "<td><input name='date[{$i}]' type='text' id='date' value='{$date[$i]}' /></td>"; echo "<td><textarea name='remarks[{$i}]' cols='50' id='remarks' value='{$remarks[$i]}'></textarea></td>"; echo"</tr>"; } I guess you already solved this though? o.O Link to comment https://forums.phpfreaks.com/topic/195248-help-in-this-line/#findComment-1026164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.