Three Different Approaches to MySql Queries

query("SELECT * FROM " . $tname . " WHERE fname LIKE '$fname'"); if ($res == 0) { echo("Error " . mysqli_errno() . ": " . mysqli_error() . ""); } else if ($con->field_count == 0) { echo("Query executed successfully"); } else { /* Get field information for all columns */ $finfo = $res->fetch_fields(); foreach ($finfo as $val) { echo(""); } echo(""); $res = $con->real_query("SELECT * FROM persons WHERE fname LIKE '$fname'"); if ($result = $con->store_result()) { while ($row = $result->fetch_row()) { echo(""); for ($jj = 0; $jj < $con->field_count; $jj++) { echo(""); } echo(""); } $result->close(); } echo("
mysqli (objects) " . $val->name . "
" . $row[$jj] . "
"); } $con->close($con); ?>

Error " . mysql_errno() . ": " . mysql_error() . ""); } else if (mysql_num_rows($res) == 0) { echo("Query executed successfully"); } else { for ($ii = 0; $ii < mysql_num_fields($res); $ii++) { echo(""); } echo(""); while (($r_array = mysql_fetch_row($res))) { echo(""); for ($jj = 0; $jj < mysql_num_fields($res); $jj++) { echo(""); } echo(""); } echo("
mysql (functional) " . mysql_field_name($res,$ii) . "
" . $r_array[$jj] . "
"); } mysql_close($link); ?>

table; $stmt = $dbh->prepare($sql); try { if($stmt->execute()){ $raw_column_data = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($raw_column_data as $outer_key => $array){ foreach($array as $inner_key => $value){ if (!(int)$inner_key){ //$this->column_names[] = $value; echo(""); } } } } } catch (Exception $e){ return $e->getMessage(); //return exception } echo(""); $STH = $dbh -> prepare( "SELECT * FROM " . $tname . " WHERE fname LIKE '$fname'" ); if ($STH -> execute()) { $raw_column_data = $STH->fetchAll(PDO::FETCH_ASSOC); foreach($raw_column_data as $outer_key => $array){ echo(""); foreach($array as $inner_key => $value){ if (!(int)$inner_key){ echo(""); } } echo(""); } } $dbh->close(); } catch(PDOException $e) { echo $e->getMessage(); } echo("
PDO (objects) " . $value . "
" . $value . "
"); ?>