Reusable SELECT from any table and fields

A

Anonymous

Guest
Hi there, wanted to see how I would have the columns I specified in
Code:
$fields = array('id','type');
then be generated dynamically in the while loop and any other field I state in
Code:
$fields = array('id','type');
then its added to the while loop in the below


Code:
include('db.php');

class SelectData{


public function wpquery_select($conn,$sql,$fields){

$results = $conn->query($sql);

if($results->num_rows > 0){

	while($row = $results->fetch_assoc()){
		
		// How would you process the array $fields which holds all the rows specified and dynamically create echo $row['id'], $row['id'] and so on?
		
	}
	
  }

$conn->close();

 }

	
}



$select = new SelectData();

$sql = "SELECT * FROM orders";


$fields = array('id','type');


$select->wpquery_select($conn,$sql,$fields);
 
Back
Top