3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $table = 'ILRL'; $requestedWO = $_GET['wo']; // Grab last 20 workorders $query = $bd->prepare("SELECT DISTINCT workorder FROM $table Order By date_time DESC LIMIT 20"); try { if(!$query->execute()) die(print_r($bd->errorInfo())); $woList = $query->fetchAll(PDO::FETCH_OBJ); } catch (Exception $e) { echo $e->getMessage(); } // wo results if( empty($requestedWO) ) $requestedWO = $woList[0]->workorder; $tableheader = false; $query = $bd->prepare("SELECT * FROM $table WHERE workorder=$requestedWO ORDER BY date_time DESC LIMIT 1000"); try { if(!$query->execute()) die(print_r($bd->errorInfo())); echo "<table class='striped responsive-table'>"; while($row = $query->fetch(PDO::FETCH_ASSOC)) { if($tableheader == false) { echo '<thead><tr>'; foreach($row as $key=>$value) { echo "<th>{$key}</th>"; } echo '</tr></thead><tbody>'; $tableheader = true; } echo "<tr>"; foreach($row as $value) { echo "<td>{$value}</td>"; } echo "</tr>"; } echo "</tbody></table>"; } catch (Exception $e) { echo $e->getMessage(); } ?> <script type="text/javascript"> var woListFromSQL = <?php print(json_encode($woList)); ?>; </script>
based on p4YWR
Output for 7.0.5 - 7.2.0
Notice: Undefined index: wo in /in/bkp2O on line 4 Notice: Undefined variable: bd in /in/bkp2O on line 7 Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/bkp2O:7 Stack trace: #0 {main} thrown in /in/bkp2O on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined index: wo in /in/bkp2O on line 4 Notice: Undefined variable: bd in /in/bkp2O on line 7 Fatal error: Uncaught Error: Call to a member function prepare() on unknown in /in/bkp2O:7 Stack trace: #0 {main} thrown in /in/bkp2O on line 7
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Notice: Undefined index: wo in /in/bkp2O on line 4 Notice: Undefined variable: bd in /in/bkp2O on line 7 Fatal error: Call to a member function prepare() on null in /in/bkp2O on line 7
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Notice: Undefined index: wo in /in/bkp2O on line 4 Notice: Undefined variable: bd in /in/bkp2O on line 7 Fatal error: Call to a member function prepare() on a non-object in /in/bkp2O on line 7
Process exited with code 255.