Met de foreign key ['hardware_idhardware'] haal ik informatie of een bepaalde stukje hardware op die op de leenbon staat. Alleen ik wil dat je op de leenbon meerdere stukjes hardware kan uitlenen.
Moet ik dan een extra foreign keys aanmaken bijv. ['hardware_idhardware2'] en ['hardware_idhardware3'] etc?
Ik had dat al geprobeerd, dat lukt wel, alleen was het een probleem voor mij om de extra toegevoegde stukjes hardware te tonen, de eerste lukt wel maar de andere niet.
Kan iemand mij helpen?
Met deze scripts haalt die 1 stukje hardware op...
<?php
include("db_connect.php");
$voornaam=$_POST['voornaam'];
$achternaam=$_POST['achternaam'];
$telefoon=$_POST['telefoon'];
$hardware_idhardware=$_POST['hardware_idhardware'];
$gebruiker_idgebruiker=$_POST['gebruiker_idgebruiker'];
$datumafgifte = date('d-m-Y');
$datumretour=$_POST['datumretour'];
$datumwijzig = date('d-m-Y');
$result=mysql_query("INSERT INTO leenbon (voornaam, achternaam, telefoon, datumafgifte, datumretour, datumwijzig, hardware_idhardware, gebruiker_idgebruiker) VALUES (
'$voornaam','$achternaam','$telefoon','$datumafgifte','$datumretour','$datumwijzig','$hardware_idhardware','$gebruiker_idgebruiker')") or die("Insert Error: ".mysql_error());
mysql_query("
UPDATE
hardware
SET
statushardware_idstatus = '2'
WHERE
idhardware = '". $hardware_idhardware ."'
");
mysql_close($link);
print "<font color='green'><b>Leenbon toegevoegd</b><br><br>";
header("Location: print.php");
?>
<?php
include("db_connect.php");
$result = mysql_query( "SELECT leenbon.idleenbon, leenbon.voornaam, leenbon.achternaam, leenbon.telefoon, leenbon.datumafgifte, leenbon.datumretour, hardware.model, hardware.serienummer, hardware.merk, hardware.nodelid, gebruiker.naam, gebruiker.idnr, gebruiker.bureau, gebruiker.telefoon FROM leenbon, hardware, gebruiker WHERE leenbon.hardware_idhardware=hardware.idhardware AND leenbon.gebruiker_idgebruiker = gebruiker.idgebruiker" ) or die("SELECT Error: ".mysql_error());
while ($row = mysql_fetch_array($result)){
echo "<div id='center'>";
echo "<h3>Leenbon NR: ";
echo $row['idleenbon'];
echo " </h3>";
echo "<br>";
echo "<table border='1'>";
echo "<tr><th>model</th><th>serienummer</th><th>merk</th><th>nodelid</th></tr>";
echo "<td>";
echo $row['model'];
echo "</td>";
echo "<td>";
echo $row['serienummer'];
echo "</td>";
echo "<td>";
echo $row['merk'];
echo "</td>";
echo "<td>";
echo $row['nodelid'];
echo "</td>";
echo "</table>";