Submitting Data
$sql = "INSERT INTO table (field, names, here) VALUES (1, 2, 3)";
$res = DB::query($sql);
Retrieving Data
$sql = "SELECT * FROM table WHERE id='5'";
return DB::get_results($sql);
Then you'd get the data as per your example and loop through the rows.