Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Proste zapytanie
lukko
post 13.09.2010, 11:56:34
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 12.03.2009

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


Witam,

Z góry zaznaczam że lamerskie pytanie dla was:

Wysyłam dla danego klienta customers_id pobierając z $HTTP_GET_VARS['cID'] nowe hasło:

  1. $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_password, customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . $HTTP_GET_VARS['cID'] . "'");


Jak to przerobić by wysłać do wszystkich klientów (czyli do wszystkich id w customers_id) nowe hasło, czyli jak przerobić:
  1. . TABLE_CUSTOMERS . " where customers_id = '" . $HTTP_GET_VARS['cID'] .


Z góry dzięki
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
nospor
post 13.09.2010, 11:57:27
Post #2





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




yyy.... usun warunek?


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

"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
lukko
post 13.09.2010, 12:05:30
Post #3





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 12.03.2009

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


No właśnie nie bardzo, bo jak dam:

  1. $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_password, customers_id, customers_email_address from " . TABLE_CUSTOMERS);


To wysyła mi do pierwszej osoby z tabeli CUSTOMERS a nie do wszystkich :/
Go to the top of the page
+Quote Post
nospor
post 13.09.2010, 12:08:31
Post #4





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




no bo pewnie dalej w kodzie php masz odebranie tylko jednego rekordu a nie wszystkich smile.gif
Dalej w kodzie php musi być pętla, która przeleci po wszystkich wynikach zapytania.


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

"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
lukko
post 13.09.2010, 12:32:45
Post #5





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 12.03.2009

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


Kurde nie ma tongue.gif

Ogólnie kodu za dużo nie ma:

Tutaj układa nowe hasełka tak:
  1. function tep_create_random_value($length, $type = 'mixed') {
  2. if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return false;
  3.  
  4. $rand_value = '';
  5. while (strlen($rand_value)<$length) {
  6. if ($type == 'digits') {
  7. $char = tep_rand(0,9);
  8. } else {
  9. $char = chr(tep_rand(0,255));
  10. }
  11. if ($type == 'mixed') {
  12. if (eregi('^[a-z0-9]$', $char)) $rand_value .= $char;
  13. } elseif ($type == 'chars') {
  14. if (eregi('^[a-z]$', $char)) $rand_value .= $char;
  15. } elseif ($type == 'digits') {
  16. if (ereg('^[0-9]$', $char)) $rand_value .= $char;
  17. }
  18. }
  19.  
  20. return $rand_value;
  21. }


Dalej treść:
  1. define('EMAIL_PASSWORD_REMINDER_SUBJECT', 'bleble nie wazny tekst');


I pozostała najważniejsza część:
  1. $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_password, customers_id, customers_email_address from " . TABLE_CUSTOMERS);
  2. $check_customer = tep_db_fetch_array($check_customer_query);
  3. // Crypted password mods - create a new password, update the database and mail it to them
  4. $newpass = tep_create_random_value(ENTRY_PASSWORD_MIN_LENGTH);
  5. $crypted_password = tep_encrypt_password($newpass);
  6. tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . $crypted_password . "' where customers_id = '" . $check_customer['customers_id'] . "'");
  7.  
  8. tep_mail($check_customer['customers_firstname'] . " " . $check_customer['customers_lastname'], $check_customer['customers_email_address'], EMAIL_PASSWORD_REMINDER_SUBJECT, nl2br(sprintf(EMAIL_PASSWORD_REMINDER_BODY, $newpass)), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
  9. tep_redirect(tep_href_link(FILENAME_CUSTOMERS, 'info_message=' . urlencode(TEXT_PASSWORD_SENT_TO_CUST)));



No i wysyła mi do pierwszego jakieś pętli hamującej wysłania do wszystkich klientów zmianę hasła nie widzę
Go to the top of the page
+Quote Post
nospor
post 13.09.2010, 12:35:40
Post #6





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




o rety... no wlasnie nie masz petli a masz miec. Czytaj ze zrozumieniem....
Ten kod:
$check_customer = tep_db_fetch_array($check_customer_query);
pobiera ci tylko jeden rekord pomimo ze zapytanie zwraca ci ich wiecej.
Ten kod i pare linii nizej ma byc wlasnie w pętli.


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

"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

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: 14.08.2025 - 06:05