Mega Code Archive

 
Categories / Php / MySQL Database
 

Its easy to select multiple rows from a mySql Table

function selectMultiRows($query) { if((@$result = mysql_query ($query))==FALSE) { echo "<strong>Error in your query:</strong> <br>$query"; } else { $count = 0; $data = array(); while ( $row = mysql_fetch_array($result)) { $data[$count] = $row; $count++; } return $data; } } /* Usage Example */ $query = "select * from Users"; $returnedData = selectMultiRows($query); $totalRecords = count($returnedData); for($i=0;$i<$totalRecords;$i++) { echo $returnedData[$i]["username"] . "<br>"; }