Changes between Version 10 and Version 11 of Docs/825gen2/Dev/Networking/PHP


Ignore:
Timestamp:
11/28/23 08:29:34 (12 months ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/825gen2/Dev/Networking/PHP

    v10 v11  
    9595Following is a more advanced demo. This reads from an ID storage transaction table and also displays vehicle images associated with transactions.
    9696
     97ids.php
     98
    9799{{{
    98100<!DOCTYPE html>
     
    116118  $result = $conn->query($sql);
    117119  if($result->num_rows > 0) {
    118     echo '<table><tr><th>Tran Num</th><th>date/time</th><th>Gross Wt</th><th>Tare Wt</th><th>Net Wt</th><th>Image</th></tr>';
     120    echo '<table><tr><th>Tran Num</th><th>date/time</th><th>Vehicle</th><th>Gross Wt</th><th>Tare Wt</th><th>Net Wt</th><th>Image</th><th>First pass</th></tr>';
    119121    while($row = $result->fetch_assoc()) {
    120122      $tkt_num = $row['tkt_num'];
    121123      $datetime = $row['date'] . ' ' . $row['time'];
     124          $veh = $row['truck'];
    122125      $gross = $row['gross'];
    123126      $tare = $row['tare'];
    124127      $net = $row['net'];
    125       echo '<tr><td>' . $tkt_num . '</td><td>' . $datetime . '</td><td>' . $gross . '</td><td>' . $tare . '</td><td>'. $net  . '</td>';
     128      echo '<tr><td>' . $tkt_num . '</td><td>' . $datetime . '</td><td>' . $veh . '</td><td>' . $gross . '</td><td>' . $tare . '</td><td>'. $net  . '</td>';
    126129      $imgfile = sprintf("v%06d_1.jpg", $tkt_num);
    127130      $img = 'images/' . $imgfile;
    128       if(!file_exists($img)) {
    129         $imgfile = sprintf("v%06da_1.jpg", $tkt_num);
    130         $img = 'images/' . $imgfile;
     131      if(file_exists($img)) {
     132        echo '<td><a href="' . $img . '"><img src="' . $img .'" width="128" height="96" ></a></td>';
     133      } else {
     134        echo '<td></td>';
    131135      }
     136      $imgfile = sprintf("v%06da_1.jpg", $tkt_num);
     137      $img = 'images/' . $imgfile;
    132138      if(file_exists($img)) {
    133         echo '<td><a href="' . $img . '"><img src="' . $img .'" width="128" height="96" ></a></td></tr>';
     139        echo '<td><a href="' . $img . '"><img src="' . $img .'" width="128" height="96" ></a></td>';
    134140      } else {
    135         echo '<td>no image</td>';
     141        echo '<td></td>';
    136142      }
     143          echo '</tr>';
    137144    }
    138145    echo '</table>';