This is my first page..
It shows all the values from 1 table
so anything that is mp_num=7 or whatever number will show all the repairs from another table that = 7
<?php
include( './../connection.php' );
mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect to database");
@mysql_select_db("$dbname") or die("Unable to select database $dbname");
if (isset($_GET['mp_num'])) {
$mp_num = $_GET['mp_num'];
} else {
$mp_num = 'id';
}
$query = "SELECT * FROM $table3 WHERE id = '$mp_num'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo "<input type='hidden' name='mp_info_id' value='$_GET[mp_num]'>";
echo "<center><p>" .$row['mac_address'] . "</p>";
echo "<center><p>" .$row['ide_sata'] . "</p>";
}
$query = "SELECT * FROM $table3,$table4 WHERE $table3.id = $table4.mp_info_id AND ($table4.mp_info_id = $mp_num) ORDER BY $table4.id ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo "<table width='' border=''>";
echo "<tr>";
echo "<td>Previous MP Name</td>";
echo "<td>Repair Details</td>";
echo "<td>Repaired By</td>";
echo "<td>Comments</td>";
echo "<td>Date Repaired</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='350'>".$row['mp_name']. "</td>";
echo "<td width='120'>".$row['repair_details']."</td>";
echo "<td width='100'align='center'>".$row['repaired_by']. "</center></td>";
echo "<td width='350'>".$row['comments']. "</td>";
echo "<td width='120'>".$row['date']. "</td>";
echo " </tr>
</table>";
}
?>
<br><input value="Add Repair" type="button" onclick="document.getElementById('addnew').style.display = 'block';">
<div id="addnew" style="display:none;">
<form id='form1' name='form1' method='POST' action='send_mp_details.php'
<input type='hidden' name='mp_num' value='<?$_POST[$mp_num]?>'>
<table width='' border='1'>
<tr>
<td width='400' height='26'>MP_Name
<label>
<input name='mp_name' type='text' size='40' />
</label></td>
<td width='461'><label>Repair Details</label>
<select name='repair_details' id='repair_details'>
<option>Replaced HD</option>
<option>Replaced Case Fan</option>
<option>Software Problem - Re-Imaged</option>
<option>Replaced PSU Board</option>
</select> </td>
<td width='193'><label>Repaired by
<input name='repaired_by' type='text' size='10' />
</label></td>
</tr>
<tr>
<td height='37' colspan='3'>Comments
<label>
<input name='comments' type='text' size='110' /> <input type='submit' value='Save'>
</label></td>
</tr>
</table>
</form>
</div>
</html>
Now here is the submit page.
Everything else is going in other then the mp_num into the mp_info_id in the second table. Not sure why.
Tried post get nothing will take the number from the url mp_list.php?mp_num=7 for example
<?php
include( './../connection.php' );
$mp_info_id = $_POST['mp_info_id'];
$mp_name = $_POST['mp_name'];
$repair_details = $_POST['repair_details'];
$repaired_by = $_POST['repaired_by'];
$comments = $_POST['comments'];
$date = date("F j, Y");
mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect to database");
@mysql_select_db("$dbname") or die("Unable to select database $dbname");
$sqlquery = "INSERT INTO $table4 VALUES ('', '$mp_info_id', '$mp_name', '$repair_details', '$repaired_by', '$comments', '$date')";
$results = mysql_query($sqlquery);
mysql_close();
print "<br>Stuff was added";
?>