Emran Posted July 4, 2009 Share Posted July 4, 2009 hi all i am new in PHP. think i have 2 table category(ID, name, type) feature(ID, categoryID, sentence) mysql_connect("localhost", "root", ""); mysql_select_db("cost"); $categories = mysql_query("SELECT * FROM category") or die(mysql_errno()." : ".mysql_error()); while($catRow = mysql_fetch_array($categories)) { echo("<B>$catRow[name]</B><BR />"); $features = mysql_query("SELECT * FROM feature WHERE categoryID = $catRow[iD]") or die(mysql_errno()." : ".mysql_error()); while ($featureRow = mysql_fetch_array($features)) { if ($catRow[type] == 0) { echo("<input type=\"radio\" id=\"_$featureRow[iD]\" /><lable for=\"_$featureRow[iD]\">$featureRow[sentence]</lable>"); } else { echo("<input type=\"checkbox\" id=\"_$featureRow[iD]\" /><lable for=\"_$featureRow[iD]\">$featureRow[sentence]</lable>"); } echo ("<BR />"); } } mysql_close(); i use code blow, but when i have 2 category, it will show first category content and second category content will not show. i debug code and i see when second while finished when again want to start mysql_fetch_array($features) will returen false, why? note : category.ID is PK and feature.categoryID is FK Link to comment https://forums.phpfreaks.com/topic/164762-solved-mysql_fetch_array-in-dedicate-while/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.