Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [mysql] czy da sie to uwydajnic?
michalek1986
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 19.05.2007

Ostrzeżenie: (0%)
-----


  1. include("../config.php");
  2. $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
  3. mysql_select_db($mysql_database, $bd);
  4.  
  5. $zapytanie = "SELECT * FROM users WHERE id = $id";
  6.  
  7. $result = mysql_query($zapytanie);
  8. while ($wiersz = mysql_fetch_array($result)) {
  9. $id="{$wiersz['id']}";
  10. $point="{$wiersz['point']}";
  11. $plus=$point+1;
  12. $minus=$point-1;
  13. }
  14. $sql = "UPDATE `users` SET `point` = '$plus' WHERE `id` = $id LIMIT 1;";
  15. $result = mysql_query($sql);
  16.  
  17. $sql = "UPDATE `pages` SET `point` = '$minus' WHERE `id` = $id LIMIT 1;";
  18. $result = mysql_query($sql);
  19.  
  20. mysql_close($bd);
Czy da się to jakoś uprościć? trwa bardzo dług.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




  1. <?php
  2. $sql = "UPDATE `users` SET `point` = `point` + 1 WHERE `id` = $id";
  3. $result = mysql_query($sql);
  4.  
  5. $sql = "UPDATE `pages` SET `point` = `point`-1 WHERE `id` = $id";
  6. $result = mysql_query($sql);
  7. ?>

I juz


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
michalek1986
post
Post #3





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 19.05.2007

Ostrzeżenie: (0%)
-----


Dzięki winksmiley.jpg
Go to the top of the page
+Quote Post

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 Aktualny czas: 21.08.2025 - 02:17