$devicename ); $deviceRequest_stmt = $conn->prepare($deviceRequest_sql); $deviceRequest_stmt->execute($deviceRequest_qryparams); //$row = $deviceRequest_stmt->setFetchMode(PDO::FETCH_ASSOC); $rowCount = $deviceRequest_stmt->rowCount(); //echo "Row Count: " . $rowCount . "\r\n"; if ($deviceRequest_stmt->rowCount() > 0){ //should only be 1 record returned (assumed), but adjust below if expecting multi-record results //$requestedData = $deviceRequest_stmt->fetch(PDO::FETCH_ASSOC); $requestedData = $deviceRequest_stmt->fetchAll(PDO::FETCH_ASSOC); //example data output check for($x=0; $x < count($requestedData); $x++){ /* //output example: 1 (all data/automated) foreach($requestedData[$x] as $name => $value) { echo "Name=" . $name . " : Value=" . $value; echo "\r\n"; } //output example: 2 (pre-known values to collect) $record_id = $requestedData[$x]['record_id']; $device_name = $requestedData[$x]['device_name']; $time_stamp = $requestedData[$x]['time_stamp']; $value1 = $requestedData[$x]['value1']; echo "\r\n"; echo 'Record ID: ' . $record_id; echo "\r\n"; echo 'Time Stamp: ' . $time_stamp; echo "\r\n"; echo 'Device Name: ' . $device_name; echo "\r\n"; echo 'Value 1: ' . $value1; echo "\r\n"; echo "\r\n"; //output example: 3 (output the list of requested values/columns) echo 'Parameter Request List:'; echo "\r\n"; foreach($paramarray as $name => $value) { echo "Name=" . $name . ": Value=" . $value; echo "\r\n"; } echo "\r\n"; echo "\r\n"; */ //outputting -only- the requested query param values echo 'Parameter Request List Results:'; //echo "\r\n"; //echo 'Param Array Count: ' . count($paramarray); //re-key itself to use in for loop if desired, or just use foreach loop above $paramarray = array_keys($paramarray); for($z=0; $z < count($paramarray); $z++){ echo "\r\n"; echo ($z + 1) . " - " . $paramarray[$z] . ': ' . $requestedData[$x][$paramarray[$z]]; } } } } ?>