I few weeks ago, I posted some code that I need help converting to MySQLi, now I need some help converting it to PDO. The code allows you to enter queries and commands and brings back the column headings and the information that I am looking for into a table. I did try out a few combination of things before posting it here. I am almost there, but my column headings are off by a few. Below is the original code and any help is greatly appreciated. Thank you.
if($type =="query") {
$qtext2 = str_replace("\\", " ", $qtext);
if($result = DB::inst()->query("$qtext2"))
_e( _t( "Successly Executed - " ) );
else
echo "<font color=red>Not able to execute the query<br>Either the
table doesnot exist or a wrong query.</font><br><br>";
_e( _t( "Query is : " ) );
echo("<font color=blue>".$qtext2."</font>\n");
echo "<table class=\"dynamicTable tableTools table table-striped table-bordered table-condensed table-white\">
<thead>
<tr>\n";
$sds = $result->field_count;
$ee = $result->fetch_fields();
foreach ($ee as $val) {
printf("<th class=\"center\">%s</th>\n", $val->name);
}
echo "</tr>\n</thead>\n";
$vv = true;
while ($line = $result->fetch_assoc()) {
if($vv === true) {
echo "<tr>\n";
$vv = false;
}
else{
echo "<tr>\n";
$vv = true;
}
foreach ($line as $col_value) {
echo "<td>".clean($col_value)."</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
/* Free resultset */
$result->free_result();
}