Using phpmyadmin (MySQL)
I used the following code to generate a query table:
SELECT
s.WO_NUM,
s.WO_LINE,
s.DESCRIPTION,
s.CUS_LOC_NAME,
s.MFG_LINE,
u1.username,
u1.lastname AS MECHANICAL,
u2.lastname AS APPLICATIONS,
u3.lastname AS DESIGN
FROM production_schedule s, users u1, users u2, users u3
WHERE s.PM_MECHANICAL = u1.USERID
AND s.PM_APPLICATIONS = u2.USERID
AND s.PM_DESIGN = u3.USERID
The query table came out exactly how I wanted it to. At the bottom where it says "Bookmark this SQL Query" I gave it a label 'eng_schedule' and checked the box that says "Let every user access this bookmark". Then I clicked "Bookmark this Query"
I was under the assumption that I can now treat this query like a table (correct me if I'm wrong)
So in my php file I did this:
<table class='tablesorter tablesorter-jobs'>
<thead>
<tr>
<th>JOB NUMBER</th>
<th>MODEL</th>
<th>LINE</th>
<th>CUSTOMER</th>
<th>AE</th>
<th>PE</th>
<th>DE</th>
<th>CE</th>
</tr>
</thead>
<tbody>
<?php
require_once ('../config.php');
$user_name = $_SESSION['user_name'];
$db = null;
$limit = 10;
$counter = 0;
while (true) {
try {
$db = new PDO($dsn, $uname, $pword);
$db->exec( "SET CHARACTER SET utf8" );
$db->setAttribute( PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC );
$db->setAttribute( PDO::ATTR_PERSISTENT, true );
break;
}
catch (Exception $e) {
$db = null;
$counter++;
if ($counter == $limit)
throw $e;
}
}
//$current_date = new DateTime();
$result = $db->prepare("SELECT * FROM eng_schedule");
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$wonum=$row["WO_NUM"];
$x=$row["WO_LINE"];
$model=$row["DESCRIPTION"];
$a=$row["MFG_LINE"];
$customer=$row["CUS_LOC_NAME"];
$proj_eng=$row["PM_MECHANICAL"];
$app_eng= $row["PM_APPLICATIONS"];
$design_eng=$row["PM_DESIGN"];
$controls_eng=$row["PM_PROGRAM"];
$olddate = DateTime::createFromFormat('m/d/y', $date_initiated); // for example, see manual for formats
$today = new DateTime();
$diff = $today->diff($olddate);
$age = $diff->format('%a');
$x = ltrim($x, '0');
if (strlen($x) > 1) {
$woline = $x;
} else {
$woline = "-0".$x;
}
$jobnum = $wonum ."". $woline;
if ($a == 1) {
$prod = "A";
} else if ($a == 2) {
$prod = "B";
} else if ($a == 3) {
$prod = "C";
} else {
$prod = "N/A";
}
$jobnum = $wonum . "" . $woline;
echo "<tr><td>".$jobnum."</td>";
echo "<td>".$model."</td>";
echo "<td>".$prod."</td>";
echo "<td>".$customer."</td>";
echo "<td>".$app_eng."</td>";
echo "<td>".$proj_eng."</td>";
echo "<td>".$design_eng."</td>";
echo "<td>".$controls_eng."</td></tr>";
}
?>
</tbody>
</table>
But I'm getting NOTHING in the tbody tags. I checked the code and tried to use the master table 'production_schedule' and it worked great. But I can't query 'eng_schedule'.
Am I missing something here? Why can't I fetch from the query?