Witam,
Przygode z php i SQL zaczalem dopiero tydzine temu, wiec prosze o wyrozumialosc.
Troche opisze sytuacje: Mam tabele w MySQL zwana 'Hirer' która zawiera informacje takie jak adres zamieszkania, telefon, email itd.
Kazdy wiersz w tej tabeli jest identyfikowany przez pole 'HirerID' które jest auto_increment primary key.
Teraz, zrobilem w php skrypt który wyswietla na stronie wszystkich Hirer'ów w tej tabeli. Jednak chce zeby na koncu kazdego wiersza miec link który skasuje z tej tabeli dany wiersz, jednak link ten nie dziala.
Bylbym wdzieczny gdyby ktos mógl podac gdzie mam blad i jak powinna ta strona wygladac by poprawnie dzialala:
<html>
<head>
</head>
<body>
<?php
if (!$dbcnx) {
exit('<p>Unable to connect to the database server at this time.</p>'); }
exit('<p>Unable to locate the Village Hall database at this time.</p>'); }
//removing deleted hirers if set
if (isset($_GET['deletehirer'])) { $HirerID = $row['HirerID'];
$sql = "DELETE FROM Hirer WHERE HirerID=$HirerID";
echo '<p> The Hirer has been removed from the database.</p>'; } else {
}
}
?>
<!-- show Hirers currently in the database -->
Here are all the hirers currently in the database:</p>
<?php
$result = @mysql_query('select HirerID, Title, Surname, Forename, Street_Number, Town_City, County, Post
Code, Home_Tel,
Mobile_Tel, Email from Hirer');
if (!$result) {
}
?> <table width="85%" valign="center"><tr><td width="10"> <?php
echo $row['HirerID']; ?> </td>
<td width="15">
<?php echo $row['Title']; ?> </td>
<td width="20">
<?php echo $row['Surname']; ?> </td>
<td width="20">
<?php echo $row['Forename']; ?> </td>
<td width="10">
<?php echo $row['Street_Number']; ?> </td>
<td width="20">
<?php echo $row['Street_Name']; ?> </td>
<td width="20">
<?php echo $row['Town_City']; ?> </td>
<td width="20">
<?php echo $row['County']; ?> </td>
<td width="20">
<?php echo $row['PostCode']; ?></td>
<td width="20">
<?php echo $row['Home_Tel']; ?></td>
<td width="25">
<?php echo $row['Mobile_Tel']; ?></td>
<td width="25">
<?php echo $row['Email']; ?></td>
<!-- set to delete Hirer on click -->
<td width="25">
<?php echo ' <a href="' . $_SERVER['PHP_SELF'] .'?deletehirer=' . $HirerID . '">' .
'Remove Hirer</a>';
?>
</td>
</table> <?php
}
?>
</body>
</html>
Dziekuje i pozdrawiam,
eXido
Ten post edytował eXido 20.04.2006, 14:54:49