freaker87 Posted March 12, 2012 Share Posted March 12, 2012 i have a mysql table which contains name like mid mname 101 AAA 102 BBB 103 CCC now i have to print this name in a html table like AAA, BBB, CCC i am getting this by while loop in a variable but when loop changes then value also change so please tell me how i get this only in one variable & print Link to comment https://forums.phpfreaks.com/topic/258724-display-multiple-data-from-mysql-table-in-one-line/ Share on other sites More sharing options...
dragon_sa Posted March 12, 2012 Share Posted March 12, 2012 show us the code you are using to do the while loop Link to comment https://forums.phpfreaks.com/topic/258724-display-multiple-data-from-mysql-table-in-one-line/#findComment-1326330 Share on other sites More sharing options...
freaker87 Posted March 12, 2012 Author Share Posted March 12, 2012 $qry = "select * from memaster"; $result = mysql_query($qry,$link); while ($row = mysql_fetch_array($result)) { $mid = $row['mid']; $mname = $row['mname']; } echo "<td> $mname</td>"; this is i am using...... Link to comment https://forums.phpfreaks.com/topic/258724-display-multiple-data-from-mysql-table-in-one-line/#findComment-1326333 Share on other sites More sharing options...
Muddy_Funster Posted March 12, 2012 Share Posted March 12, 2012 Use something like the following: $sql = "SELECT mname FROM tableName"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result){ $myArray[] = $row['mname']; } $myList = implode(', ', $myArray); echo $myList; Link to comment https://forums.phpfreaks.com/topic/258724-display-multiple-data-from-mysql-table-in-one-line/#findComment-1326334 Share on other sites More sharing options...
freaker87 Posted March 12, 2012 Author Share Posted March 12, 2012 It works... Thanks Muddy..... Link to comment https://forums.phpfreaks.com/topic/258724-display-multiple-data-from-mysql-table-in-one-line/#findComment-1326336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.