Reputation: 113
For this project, I have an upload page for the user to upload a CSV file where it is inserted into a DB in one single staging table. From there, some things are split and also inserted into separate tables. Each CSV has 2 to 8 rows, and each row has 228 fields, so there are 228 columns in my staging table.
Once uploaded, the user can go to a page (userSelect.php) and use dropdowns to help select a work order to view where it will be displayed in multiple tables.
The upload/insert works great, and the dropdowns are populating with the elements from the database properly but I can't seem to connect the selections to the table page.
For instance, if the user selects the "Work Order Packet" dropdown and chooses 'February Zone B1', I want this to show links with any record from the database that has this work order packet name. Then, once they select the record they want, I want the display.php page to fill all the tables with the 228 elements from that specific record, using the id I assume.
I have the code for these two pages below. The userSelect page does not currently have any code for showing the database records as links either so i'm hoping to figure out how I can show those and then use the one the user selects to fill the tables on the display page.
userSelect.php
<form method="post" action="display.php" enctype="multipart/form-data">
<input type="submit" name="submit" value="Confirm" >
</form>
<?php
$server = "localhost";
$user = "root";
$pw = "root";
$db = "uwsTest";
$connect = mysqli_connect($server, $user, $pw, $db);
if ($connect->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{
echo'success!';
}
?>
<label>Select Work Order Packet:</label>
<select name="workOrderPacket">
<?php
$sql = mysqli_query($connect, "SELECT workOrderPacket FROM staging;");
while($row = $sql->fetch_assoc()){
echo "<option >" . $row['workOrderPacket'] . "</option>";
}
?>
</select>
<label>Select Work Order ID:</label>
<select name="WorkOrderNumber">
<?php
$sql2 = mysqli_query($connect, "SELECT workOrderNum FROM staging;");
while($row2 = $sql2->fetch_assoc()){
echo "<option>" . $row2['workOrderNum'] . "</option>";
}
?>
</select>
display.php
<?php
if(isset($_POST['submit']))
{
while($row = mysqli_fetch_array($result1)){
?>
<!--Qa Table-->
<table>
<tr>
<th colspan="2">Qa/Qc CheckList</th>
</tr>
<tr>
<td>Service Address Correct</td>
<td><? echo $row['serviceAddress'];?> </td>
</tr>
<tr>
<td>Service Loc Correct</td>
<td><? echo $row['serviceLoc'];?> </td>
</tr>
<tr>
<td>Meter Number Correct</td>
<td><? echo $row['meterNumber'];?> </td>
</tr>
<tr>
<td>Meter Manufacturer Changed</td>
<td><? echo $row['meterManufacturer'];?> </td>
</tr>
<tr>
<td>Meter Type Changed</td>
<td><? echo $row['meterType'];?> </td>
</tr>
<tr>
<td>Meter Model Changed</td>
<td><? echo $row['meterModel'];?> </td>
</tr>
<tr>
<td>Low Register Correct</td>
<td><? echo $row['registerCorrect'];?> </td>
</tr>
<tr>
<td>High Register Correct</td>
<td><? echo $row['registerCorrect'];?> </td>
</tr>
</table>
UPDATE - unfinished SQL query for display.php:
$query1 = "SELECT * FROM staging WHERE StageID = ;";
$result1 = mysqli_query($connect,$query1);
Upvotes: 1
Views: 722
Reputation: 261
You will need to update your SQL statement to filter the associated results.
SELECT workOrderNum FROM staging WHERE workOrderPacket = '.$_REQUEST["workOrderPacket"] ';
Upvotes: 1