Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]while
mit2
post
Post #1





Grupa: Zarejestrowani
Postów: 160
Pomógł: 5
Dołączył: 4.08.2010

Ostrzeżenie: (40%)
XX---


witam mam problem z while mam taki kod
  1. $has = "SELECT * FROM has";
  2. $has = mysql_query("$has");
  3. while($haslo = mysql_fetch_array($has))
  4. {
  5. if($ser['id'] == $haslo['idser'])
  6. {
  7. $is = "UPDATE has SET haslo='$_POST[haslo]' WHERE idser='$ser[id]'";
  8. $is = mysql_query("$is");
  9. echo'update';
  10. }
  11. else
  12. {
  13. $in = "INSERT INTO has VALUES ('$ser[id]', '$_POST[haslo]')";
  14. $in = mysql_query($in);
  15. echo'zrobione';
  16. }
  17. }

i chce w nim aby gdy w $haslo[idser] jest id serwera to robi update a jeżeli go nie ma to robi insert. i jeżeli mam wogule coś w tabeli to robi insert gdy jest juz w tabeli to robi insert i update jednoczesnie
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
mit2
post
Post #2





Grupa: Zarejestrowani
Postów: 160
Pomógł: 5
Dołączył: 4.08.2010

Ostrzeżenie: (40%)
XX---


problem rozwiązany sam zrobiłem
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 Aktualny czas: 20.08.2025 - 11:12