Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Stara zmienna zostaje, brak nowej
EdeusEx
post 17.06.2008, 19:04:24
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 1
Dołączył: 6.04.2008

Ostrzeżenie: (20%)
X----


Po kolei.

Szablon wyświetlania przedmiotów:
Cytat
<td>
<table class="wh">
<tr>
<td><input type="checkbox" class="" name="to_update[]" value="{$slot}"></td><td align="center"><img src="{$image}" title="body=[{$title}]"></td>
</tr>
<tr>
<td>Price:</td> <td><input type="text" maxlength="7" name="of_price[]" size="7" value="{$price}"></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="button" value="-" onClick="window.location='delete.php?id={$slot}'"></td>
</tr>
</table></form></td>



Wyświetlanie przedmiotów:
  1. <?php
  2. echo &apos;&apos;;
  3. $rows=0;
  4. $getStorageItems = $this->query(&#092;"SELECT * FROM __tabela__ WHERE place=&apos;market&apos; and name=&apos;\".$this->Player.\"&apos;\");
  5. while ($Storage = mysql_fetch_assoc($getStorageItems)) {
  6. if ($rows == 5) {
  7. echo &apos;&apos;;
  8. $rows = 0;
  9. } else {
  10. $rows++;
  11. }
  12.  
  13. $item_info = $this->item->get($Storage[&apos;slotid&apos;], 1);
  14. $this->smarty->assign(&#092;"image\", $item_info[0]);
  15. $this->smarty->assign(&#092;"title\", $item_info[1]);
  16. $this->smarty->assign(&#092;"slot\", $Storage[&apos;slotid&apos;]);
  17. $this->smarty->assign(&#092;"price\", $Storage[&apos;price&apos;]);
  18. $this->smarty->display(&#092;"market.tpl\");
  19. }
  20. echo &apos;
  21. &apos;;
  22. ?>


Po naciśnięciu "Update all items":
  1. <?php
  2. $update = $_POST[&apos;to_update&apos;];
  3. $of_price = $_POST[&apos;of_price&apos;];
  4.  
  5. if (count($update)>0) {
  6. for ($i=0; $i
  7. if (isset($update[$i])) {
  8. $game->market->update_stall($update[$i], $of_price[$i]);
  9. echo $update[$i].&apos;&apos;s price is now &apos;.$of_price[$i].&apos;
  10. &apos;;
  11. }
  12. }
  13. } else {
  14. Header(&#092;"Location: update.php\");
  15. }
  16. ?>


Funkcja update_stall:
  1. <?php
  2. function update_stall($slot_id, $price) {
  3. $slot_id = (int)$slot_id;
  4. $price = (int)$price;
  5. if ($price == 0) { $price = 500; }
  6.  
  7. $this->query(&#092;"UPDATE __tabela__ SET place=&apos;market&apos;, price=&apos;\".$price.\"&apos; WHERE slotid=&apos;\".$slot_id.\"&apos;\");
  8. }
  9. ?>


Problem jest w tym, że gdy zaznaczę pierwszy przedmiot i zmienię cenę, na przykład na 1000, zaakceptuję - dobrze, cena dla pierwszego przedmiotu się zmieni.

Natomiast, gdy zmienię cenę drugiego przedmiotu, na przykład na 17000 (zaznaczając checkbox) i nacisnę na przycisk "Update all items", cena zmienia się na cenę poprzednią. Tak jest cały czas.

Co jest nie tak?

Ten post edytował EdeusEx 17.06.2008, 20:57:50
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 07:49