Jump to content

SalientAnimal

Members
  • Posts

    366
  • Joined

  • Last visited

Everything posted by SalientAnimal

  1. $result = mysqli_query($link,$sqlsearch)or die(mysqli_error()); while($row = mysqli_fetch_array($result)) { $store_code = $row['store_code']; $outlet_name = $row['outlet_name']; $address_0 = $row['address_0']; $address_1 = $row['address_1']; $address_2 = $row['address_2']; $address_3 = $row['address_3']; $address_4 = $row['address_4']; $contact_number_1 = $row['contact_number_1']; $contact_number_2 = $row['contact_number_2']; $license = $row['scanned_license']; $permit_renewal = $row['scanned_permit_renewal']; $identity_document = $row['scanned_identity_document']; $other_document = $row['scanned_other_document']; echo "<div class='row'>"; echo "<div class='col-md-12'>"; echo "<div class='box box-primary'>"; echo "<div class='box-header with-border'>"; echo "<h3 class='box-title'>Outlet Details</h3>"; echo "<table> <tr> <th>Outlet Details</th> <th>Outlet Documentation</th> </tr> <tr> <td> <table> <tr> <th>Store Code</th> </tr> <tr> <td>".$store_code."</td> </tr> <tr> <th>Store Name</th> </tr> <tr> <td>".$outlet_name."</td> </tr> <tr> <th>Store Address</th> </tr> <tr> <td>".$address_0."</td> </tr> <tr> <td>".$address_1."</td> </tr> <tr> <td>".$address_2."</td> </tr> <tr> <td>".$address_3."</td> </tr> <tr> <td>".$address_4."</td> </tr> <tr> <th>Contact Person</th> </tr> <tr> <td>Jim</td> </tr> <tr> <th>Contact Number</th> </tr> <tr> <td>".$contact_number_1."</td> </tr> <tr> <td>".$contact_number_2."</td> </tr> </table> </td> <td> <table> <tr> <th>License</th> </tr> <tr> <td><a href='uploads/".$license."'>".$license."</a></td> </tr> <tr> <th>Permit Renewal</th> </tr> <tr> <td><a href='uploads/".$permit_renewal."'>".$permit_renewal."</a></td> </tr> <tr> <th>Identity Document</th> </tr> <tr> <td><a href='uploads/".$identity_document."'>".$identity_document."</a></td> </tr> <tr> <th>Other Documents</th> </tr> <tr> <td><a href='uploads/".$other_document."'>".$other_document."</a></td> </tr> <tr> <th>Reference Number</th> </tr> <tr> <td>HSA0123456</td> </tr> <tr> <td>HSA0123457</td> </tr> </table> </td> </table> "; } echo "</table>"; mysqli_close($link); Some code improvements made
  2. Hi All, I'm trying to get my head wrapped around how to create a Table from a DB. I have no issues getting the information, and all the data is pulling through as expected. I just cant seem to get my layout of my table right. I have tried to draw a diagram of how I would like my table to be displayed. The left hand side of the table is pretty much static with the amount of rows always being static. Here there are 5 rows with headings, the 3 row / nested table returning an address section with 5 address rows, and the last row will return the contact number row with 2 contact numbers. The biggest complication is on the right hand side of the table which shows a list of hyperlinked documents, however each document type (heading) may have anywhere from 1 - 10 documents. And I would need this section of the table to expand as each row with a new document is returned. I have attached the layout diagram. My current code for this section looks as follows (The code below is still a work in progress): echo "<div class='row'>"; echo "<div class='col-md-12'>"; echo "<div class='box box-primary'>"; echo "<div class='box-header with-border'>"; echo "<h3 class='box-title'>Outlet Details</h3>"; echo "<table border = '0'>"; echo " <tr> <th width='50%'>Outlet Details</th> <th width='50%'>Outlet Documentation</th> </tr> "; while($row = mysqli_fetch_array($result)) { $store_code = $row['store_code']; $outlet_name = $row['outlet_name']; $address_0 = $row['address_0']; $address_1 = $row['address_1']; $address_2 = $row['address_2']; $address_3 = $row['address_3']; $address_4 = $row['address_4']; $license = $row['scanned_license']; $permit_renewal = $row['scanned_permit_renewal']; $identity_document = $row['scanned_identity_document']; $other_document = $row['scanned_other_document']; echo "<tr> <td>".$store_code."</td> <td><a href='uploads/".$license."'>".$license."</a></td> </tr>"; echo "<tr> <td>".$outlet_name."</td> <td><a href='uploads/".$permit_renewal."'>".$permit_renewal."</a></td> </tr>"; echo "<tr> <td>".$address_0."</td> <td><a href='uploads/".$identity_document."'>".$identity_document."</a></td> </tr>"; echo "<tr> <td>".$address_1."</td> <td><a href='uploads/".$other_document."'>".$other_document."</a></td> </tr>"; }
  3. Somehow with my brain working overtime and not being a seasoned php script writer I didn't even think of doing this, although I know I have done it in the past. Thanks...
  4. Hi All, I am running a PHP script on a daily basis to import data into my database. THe PHP file is executed by my Windows Services. The PHP file is a LOAD DATA IN FILE script and looks like the below: LOAD DATA LOCAL INFILE '\master_import\\myfilename.csv' IGNORE INTO TABLE mydatabase.mytable CHARACTER SET latin1 FIELDS TERMINATED BY ',' ENCLOSED BY '"' IGNORE 1 LINES ( record_number , name , action_date , location , type_of_outlet .... ) ; The ENCLOSED BY '"' is where my problem lies, as I do not know how to use the '"' without PHP reading it as a " to close the script. Any help will be appreciated. Thanks.
  5. I've made some changes to this now and I have managed to get the entity code from the previous page to echo correctly. But what I can seem to get right is to now use this entity number that is passed to query my database and populate the form: $link = mysqli_connect("localhost", "username", "password", "db"); if(isset($_GET['entity_number'])) { $store_code = $_GET['entity_number'];} echo $entity_number; $sql = mysqli_query ($link,"SELECT id , username , entity_number , entity_name , address_0 , address_1 , address_2 , address_3 , address_4 , contact_number_1 , contact_number_2 FROM scrm.liquor_licenses WHERE entity_number= '$entity_number'"); while ($row = mysqli_fetch_assoc($sql)); $username = $row['username']; $entity_number= $row['entity_number']; $entity_name= $row['entity_name']; /* close connection */ The form which is on the same page as the above query: <input type="hidden" class="form-control" value="<?php ECHO $_SESSION['username']; ?>" name="username" readonly> <div class="form-group"> <label>Outlet Number :</label> <input type="text" class="form-control" value="<?php ECHO $entity_number?>" name="entity_number"> </div> <div class="form-group"> <label>Outlet Number :</label> <input type="text" class="form-control" value="<?php ECHO $entity_name?>" name="entity_name"> </div>
  6. Hi all, I have a pretty basic front end system where specific details are displayed. There is also and edit button next to each record that is displayed however not all info about this record is displayed. When I click edit, I want a query to run on my next page, which will pre-populate the form with information from a query using the reference from the previous page. A basic example is: if(isset($_GET['entity_code'])) echo $entity_code; $sql = "SELECT id , username , region , entity_code , address_0 , address_1 , address_2 , address_3 , address_4 , contact_number_1 , contact_number_2 FROM scrm.entity_details WHERE entity_number= '$entity_number'"; if ($result = $mysqli->query($sql)) { /* fetch associative array */ while ($row = $result->fetch_assoc()) { printf ("%s (%s)\n", $row['outlet_number'], $row['outlet_name']); } } /* close connection */ $mysqli->close(); The entity number is passed successfully from the previous page, however my form is not populating and various I have tried give me a number of different outcomes. The below is where I am trying to populate my form: <input type="hidden" class="form-control" value="<?php ECHO $_SESSION['username']; ?>" name="username" readonly> <div class="form-group"> <label>Entity Number :</label> <input type="text" class="form-control" value="<?php ECHO $row['entity_number']; ?>" name="outlet_number"> </div> <div class="form-group"> <label>Entity Name :</label> <input type="text" class="form-control" value="<?php ECHO $row['entity_name']; ?>" name="outlet_number"> </div> I really don't know where I am going wrong...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.