Jump to content

I'm getting duplicate values in my array from my MySQL table


scrubbicus

Recommended Posts

$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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.