Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z panelem administracyjnym własnej roboty
Forum PHP.pl > Forum > PHP
furman12
Mam problem w takim kodzie i nie potrafię go rozwiązać
  1. <?php
  2. include("lib.php");
  3. define("PAGENAME", "Home");
  4. $player = check_user($secret_key, $db);
  5. ?>
  6. <img src="templates/images/header.png">
  7. <div id="menu">
  8. <?php
  9. include("templates/admin_header.php")
  10. ?>
  11. </div>
  12. <table>
  13. <tr>
  14. <th width="30%"><font color="white"><b>Nazwa</b></font></td>
  15. <th width="40%"><font color="white"><b>Opis</b></font></td>
  16. <th width="10%"><font color="white"><b>Typ</b></font></td>
  17. <th width="5%"><font color="white"><b>Efektywność</b></font></td>
  18. <th width="5%"><font color="white"><b>Koszt</b></font></td>
  19. <th width="10%"><font color="white"><b>Akcja</b></font></td>
  20. </tr>
  21. <?php
  22. $query = $db->execute("select `id`, `name`, `description`, `type`, `effectiveness`, `price` from `blueprint_items` order by `type`, `price`");
  23.  
  24. while($item = $query->fetchrow())
  25. {
  26. echo "<tr>";
  27. echo "<td>" . $item['name'] . "</td>\n";
  28. echo "<td>" . $item['description'] . "</td>\n";
  29. echo "<td>" . $item['type'] . "</td>\n";
  30. echo "<td>" . $item['effectiveness'] . "</td>\n";
  31. echo "<td>" . $item['price'] . "</td>\n";
  32. echo "<td><a href=\"admin_items.php?delete=" . $item['id'] . "\">Usuń</a></td>\n";
  33. }
  34.  
  35. if(isset($_GET['delete']) && $_GET['delete']=='' . $item['id'] .'')
  36. {
  37. echo "<td><a href=\"admin_items.php?delete=" . $item['id'] . "\">Usuń</a></td>\n";
  38. }
  39. ?>




PS na razie zamiast usówać chce wyświetlić link

Sorki, zapomniałem napisać, chodzi o to, że nie wyświetla tego usuń po kliknięciu w usuń
Armstrong
Cytat(furman12 @ 30.12.2009, 18:08:26 ) *
Mam problem w takim kodzie i nie potrafię go rozwiązać

tu masz problem zmień to: na to: i będzie działać.

Mógłbyś powiedzieć jaki problem?
darko
co pokazują print_r($_GET['delete']); i print_r($item); ?
furman12
Nie ma czegoś takiego
Armstrong
  1. if(isset($_GET['delete']) && $_GET['delete']=='' . $item['id'] .'')

Porównujesz, do czegoś czego nie ma
furman12
Może sprubójmy jeszcze raz. Mam to i chce żeby po wciśnięciu na usuń usówało mi z bazy wybrany element.
  1. <?php
  2. include("lib.php");
  3. define("PAGENAME", "Home");
  4. $player = check_user($secret_key, $db);
  5. ?>
  6. <img src="templates/images/header.png">
  7. <div id="menu">
  8. <?php
  9. include("templates/admin_header.php")
  10. ?>
  11. </div>
  12. <table>
  13. <tr>
  14. <th width="30%"><font color="white"><b>Nazwa</b></font></td>
  15. <th width="40%"><font color="white"><b>Opis</b></font></td>
  16. <th width="10%"><font color="white"><b>Typ</b></font></td>
  17. <th width="5%"><font color="white"><b>Efektywność</b></font></td>
  18. <th width="5%"><font color="white"><b>Koszt</b></font></td>
  19. <th width="10%"><font color="white"><b>Akcja</b></font></td>
  20. </tr>
  21. <?php
  22. $query = $db->execute("select `id`, `name`, `description`, `type`, `effectiveness`, `price` from `blueprint_items` order by `type`, `price`");
  23.  
  24. while($item = $query->fetchrow())
  25. {
  26. echo "<tr>";
  27. echo "<td>" . $item['name'] . "</td>\n";
  28. echo "<td>" . $item['description'] . "</td>\n";
  29. echo "<td>" . $item['type'] . "</td>\n";
  30. echo "<td>" . $item['effectiveness'] . "</td>\n";
  31. echo "<td>" . $item['price'] . "</td>\n";
  32. echo "<td><a href=\"admin_items.php?delete=" . $item['id'] . "\">Usuń</a></td>\n";
  33. }
  34. ?>

darko
  1. if(is_numeric($_GET["delete"]) && $_GET["delete"] > 0) {
  2. $q = "delete from blueprint_items where id=".$_GET["delete"];
  3. $result = $db->execute($q);
  4. if(!$result) {
  5. }
  6. else {
  7. echo "usunięto";
  8. }
  9. }
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.