I have a table which will give back the requested information from a MySQL database. But now I want to have 2 options at the end of each row. One to EDIT al the information and one to DELETE the whole row.
Up to this point I have this code:
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<h1 align="center"><CENTER><img border="0" src="ACLogo.gif" width="620" height="75"></CENTER></h1>
<h1><CENTER><font face="Arial">Welkom bij de Machine Database</font></CENTER></h1><br>
<font face="Arial" size="2">
<?php
//machineID nameID description
// 1 Simdis Goed
//begin openen site
if (!isset($index) || $index == 0)
{
print "<h3><u>Kies hier 1 of meer velden om mee te zoeken</u></h3><br>";
print "<p><a href='MachineDatabase1.php?index=2'>Laat de hele database zien</a></p><BR>";
print "<form method='POST' action='http://sales-15/MachineDatabase1.php?index=1'>
Machine nr:<BR><input type='integer' name='machineID' size='20'><BR>
</textarea><BR>
Machine naam:<BR> <input type='text' name='nameID' size='20'><BR>
</textarea><BR>
Omschrijving:<BR> <input type='text' name='description' size='20'><BR>
</textarea><BR><BR>
<input type='submit' value='Zoeken' name='OK_button'></p><BR><BR>
</form>";
print "<p><a href='MachineDatabaseBegin.php?'>Klik hier om terug te gaan naar het begin</a></p>";
}
//Eén record opzoeken
if($index == 1)
{
$string == "";
if($machineID != ""){ $string = "SELECT * from machines where machineID ='".$machineID."'"; }
if($nameID != ""){ $string = "SELECT * from machines where nameID='".$nameID."'"; }
if($description != ""){ $string = "SELECT * from machines where description='".$description."'"; }
if($machineID != "" & $nameID != ""){ $string = "SELECT * from machines where machineID='".$machineID."' AND nameID='".$nameID."'"; }
if($machineID != "" & $description != ""){ $string = "SELECT * from machines where machineID='".$machineID."' AND description='".$description."'"; }
if($nameID != "" & $description != ""){ $string = "SELECT * from machines where nameID='".$nameID."' AND description='".$description."'"; }
if($machineID != "" & $nameID != "" & $description != ""){ $string = "SELECT * from machines where machineID='".$machineID."' AND nameID='".$nameID."' AND description='".$description."'"; }
if($machineID == "" & $nameID == "" & $description == "" & $cdID == "")
{
print "<h1>U heeft niks ingevuld!!!</h1>";
print "<p><a href='MachineDatabase1.php?index=0'>Klik hier om terug te gaan</a></p>";
exit();
}
$connection = mysql_pconnect ("localhost", "login", "password") or die ("Kan geen connectie maken");
mysql_select_db ("heins") or die ("Kan geen Database selecteren");
$result = mysql_query ($string) or die("Niet gelukt!!!");
print "U heeft de volgende opdracht gegeven: <B>".$string."</B><BR><BR>";
{
print "<B>Resultaten: </B>";
print '<table border=10 width="90%" cellspacing=1>';
print '<tr bgColor="#ccccc">';
print '<td width="10%" bgcolor="#ffffff">#</td>';
print '<td width="15%" bgcolor="#ffffff"><u>Machine nr</u></td>';
print '<td width="20%" bgcolor="#ffffff"><u>Machine Naam</u></td>';
print '<td width="30%" bgcolor="#ffffff"><u>Omschrijving</u></td>';
print '<td width="10%" bgcolor="#ffffff"><u>Edit File</u></td>';
print '<td width="15%" bgcolor="#ffffff"><u>Delete File</u></td>';
print '</tr>';
while ($row = mysql_fetch_object($result))
{
print '<tr bgColor="#ddddd">';
print '<td>'.$row->RowNumber.'</td>';
print '<td>'.$row->machineID.'</td>';
print '<td>'.$row->nameID.'</td>';
print '<td>'.$row->description.'</td>';
print '</tr>';
}
print '</table>';
}
print "<BR><BR><p><a href='MachineDatabase1.php?index=0'>Klik hier om terug te gaan</a></p>";
}
//Hele database laten zien
if ($index == 2)
{
$connection = mysql_pconnect ("localhost", "login", "password") or die ("Kan geen connectie maken");
mysql_select_db ("heins") or die ("Kan geen Database selecteren");
$string = "SELECT * from machines";
$result = mysql_query ($string) or die("Niet gelukt!!!");
print "<h4>Totaaloverzicht: </h4>";
print '<table border=10 width="90%" cellspacing=1>';
print '<tr bgColor="#ccccc">';
print '<td width="10%" bgcolor="#ffffff">#</td>';
print '<td width="15%" bgcolor="#ffffff"><u>Machine nr</u></td>';
print '<td width="20%" bgcolor="#ffffff"><u>Machine Naam</u></td>';
print '<td width="30%" bgcolor="#ffffff"><u>Omschrijving</u></td>';
print '<td width="10%" bgcolor="#ffffff"><u>Edit File</u></td>';
print '<td width="15%" bgcolor="#ffffff"><u>Delete File</u></td>';
print '</tr>';
while ($row = mysql_fetch_array($result))
{
print '<tr bgColor="#ddddd">';
print '<td>'.$row[RowNumber].'</td>';
print '<td>'.$row[machineID].'</td>';
print '<td>'.$row[nameID].'</td>';
print '<td>'.$row[description].'</td>';
print '</tr>';
}
print '</table>';
print "<p><a href='MachineDatabase1.php?index=0'>Klik hier om terug te gaan</a></p>";
}
//Toevoegen
if ($index == 3)
{
print "<h3><u>Vul hier zo veel mogelijk velden in!!</u></h3><br>";
print "<form method='POST' action='http://sales-15/MachineDatabase1.php?index=4'>";
print "Machine nr:<BR><input type='integer' name='machineID' size='20'><BR>";
print "Machine naam:<BR><input type='text' name='nameID' size='20'><BR>";
print "Omschrijving:<BR><input type='text' name='description' size='20'><BR>";
print "</textarea><BR><BR>";
print "<input type='submit' value='Machine toevoegen' name='OK_button'></p><BR><BR>";
print "</form>";
print "<p><a href='MachineDatabaseBegin.php?'>Klik hier om terug te gaan naar het begin</a></p>";
}
if ($index == 4)
{
$fout=="";
if($machineID == "") $fout.="<h3>Er is geen '<u>Machine Nr</u>' ingevuld</h3>";
if($nameID == "") $fout.="<h3>Er is geen '<u>Machine Naam</u>' ingevuld</h3>";
if($description == "") $fout.="<h3>Er is geen '<u>Omschrijving</u>' ingevuld</h3><BR>";
echo $fout;
if($fout == ""){
if(!mysql_pconnect("localhost", "login", "password")){
echo "Er is geen connectie mogelijk met database<br>";
exit;
}
mysql_select_db("heins");
mysql_query("INSERT INTO machines(machineID, nameID, description)
VALUES('$machineID', '$nameID', '$description')");
mysql_close();
echo "<h3>Gegevens zijn toegevoegd!!!</h3><br>";
}
else{ echo "<h3>Er zijn fouten geconstateerd. Database is niet bijgewerkt.</h3>";}
print "<p><a href='MachineDatabase1.php?index=3'>Klik hier om terug te gaan</a></p>";
}
?>
</font>
</body>
Does anybody know how to get the same 2 options (Edit & Delete) at the end of a table row, just like in the database of MySQL????