shadiadiph Posted December 9, 2008 Share Posted December 9, 2008 Probably a simple solution to this but i can't think of one right now can anyone help i have a tale that achos the data i want to make table td name="news[]" produce a different value on each row i.e name="news0" next row name="news1" The value row dispalays a different valiable as it has one already. anyway here is my code any pointers will be appreciated I want to keep this simple. <table class="users"> <tr><td><strong>CURRENTLY DISPLAYED NEWS ARTICLES</strong></td></tr> <? $sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 20"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $tradeaid = $row["intnewsID"]; $accountid = $row["intAccountID"]; $stitle = $row["newsshTit"]; $mtitle = $row["newsTit"]; $nmain = $row["newsMn"]; $updated = $row["dtAddedOn"]; ?> <? echo '<tr><td><input type="checkbox" name="news[]" value="'. $tradeaid. '" /></td><td width="90% align="left">'. $mtitle. '</td></tr>'; } ?> </form> </table> Link to comment https://forums.phpfreaks.com/topic/136155-solved-how-to-make-each-name-different-in-an-echo-table/ Share on other sites More sharing options...
gevans Posted December 9, 2008 Share Posted December 9, 2008 I assume you mean this; <table class="users"> <tr><td><strong>CURRENTLY DISPLAYED NEWS ARTICLES</strong></td></tr> <?php $sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 20"; $result = mysql_query($sql); $i=0; while ($row = mysql_fetch_assoc($result)) { $tradeaid = $row["intnewsID"]; $accountid = $row["intAccountID"]; $stitle = $row["newsshTit"]; $mtitle = $row["newsTit"]; $nmain = $row["newsMn"]; $updated = $row["dtAddedOn"]; echo '<tr><td><input type="checkbox" name="news'.$i.'" value="'. $tradeaid. '" /></td><td width="90% align="left">'. $mtitle. '</td></tr>'; $i++; } </form> </table> ?> Link to comment https://forums.phpfreaks.com/topic/136155-solved-how-to-make-each-name-different-in-an-echo-table/#findComment-710164 Share on other sites More sharing options...
shadiadiph Posted December 9, 2008 Author Share Posted December 9, 2008 awesome so simple thanks alot works great just what i needed like my post yesterday the answer was so simple but i had made it too complicated. Link to comment https://forums.phpfreaks.com/topic/136155-solved-how-to-make-each-name-different-in-an-echo-table/#findComment-710178 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.