Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Proste zapytanie
Forum PHP.pl > Forum > Przedszkole
lukko
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
nospor
yyy.... usun warunek?
lukko
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 :/
nospor
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.
lukko
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ę
nospor
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.
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.