scrubbicus Posted May 4, 2009 Share Posted May 4, 2009 $results = mysql_query('SELECT * FROM '.$table); $num_rows = mysql_num_rows($results); $rows = mysql_fetch_array($results); $count = '0'; $rowsa = array(); for($i=1;$i <= $num_rows; $i++) { $rowsa[$i] = mysql_fetch_array(mysql_query('SELECT * FROM clients WHERE id='.$i.'')); var_dump($rowsa[$i]); echo '<p/>'; } When I dump the current array this is what I get array(12) { [0]=> string(1) "2" ["id"]=> string(1) "2" [1]=> string(5) "Geoff" ["name"]=> string(5) "Geoff" [2]=> string(2) "25" ["wage"]=> string(2) "25" [3]=> string(20) "[email protected]" ["email"]=> string(20) "[email protected]" [4]=> string(14) "scrubbicus.com" ["url"]=> string(14) "scrubbicus.com" [5]=> string(10) "2147483647" ["phone"]=> string(10) "2147483647" } Is there anyway to get rid of the duplicate values in their? I'd like to keep the associative array where it says "name" => "Geoff" but you can see before that it has "2" => "Geoff" which I don't want. Anyone know why it's doin this? Link to comment https://forums.phpfreaks.com/topic/156863-im-getting-duplicate-values-in-my-array-from-my-mysql-table/ Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Use mysql_fetch_assoc. Also, why don't you combine the SQLs? Link to comment https://forums.phpfreaks.com/topic/156863-im-getting-duplicate-values-in-my-array-from-my-mysql-table/#findComment-826305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.