Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Pobieranie danych z bazy. Else i if
teez
post
Post #1





Grupa: Zarejestrowani
Postów: 186
Pomógł: 6
Dołączył: 20.12.2010

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


Hej,

Mam następujacy kod :

  1. <?
  2. @$db = mysql_pconnect("localhost", "root", "123");
  3. if (!$db)
  4. {
  5. print "wystąpił błąd w połączeniu";
  6. exit;
  7. }
  8.  
  9. mysql_select_db("test");
  10.  
  11.  
  12. $query = "select * from ibf_members";
  13. $result = mysql_query($query);
  14. $num_results = mysql_num_rows($result);
  15. $tabela1 = "ipb_members";
  16. $title = "title";
  17. $mgi = "member_group_id";
  18.  
  19.  
  20. print "<p>Ilość użytkowników w bazie danych: ".$num_results."</p>";
  21. print "<hr>";
  22. for ($i=0; $i <$num_results; $i++) {
  23. $row = mysql_fetch_array($result);
  24. print "<b>Nazwa użytkownika: </b>";
  25. print stripslashes($row["name"]);
  26. print "<br>";
  27. print "<b>ID użytkownika: </b>";
  28. print stripslashes($row["member_id"]);
  29. print "<br>";
  30. print "<b>ID grupy: </b>";
  31. print stripslashes($row["$mgi"]);
  32. print "<br>";
  33. print "<b>E-mail: </b>";
  34. print stripslashes($row["email"]);
  35. print "<br>";
  36. print "<b>Liczba postów: </b>";
  37. print stripslashes($row["posts"]);
  38. print "<br>";
  39. print "<b>Adres IP: </b>";
  40. print stripslashes($row["ip_address"]);
  41. print "<br>";
  42. print "<b>Tytuł: </b>";
  43. print stripslashes($row["$title"]);
  44. print "<br>";
  45. print "<b>Wybrany język: </b>";
  46. print stripslashes($row["language"]);
  47. print "<br>";
  48. print "<b>Wyświetleń profilu: </b>";
  49. print stripslashes($row["members_profile_views"]);
  50. print "<br>";
  51.  
  52. print "<hr>";
  53. }
  54.  
  55. ?>


Ukazujący :

(IMG:http://www.iv.pl/images/38469450270753812408.png)

I jak widać po pierwsze, jeżeli ktoś nie wybrał Tytułu to chcę tą pustotę zamienić na np "Brak".

Próbowałem kodem :


  1. if ($mgi = 0)
  2.  
  3. { print = "BRAK"
  4.  
  5. }




Ale nie idzie..

I w ID Grupy chcę zmienić ID na grupę. Czyli np. if (group_id = 1) {print = Moderator } ;

Macie może jakieś pomysły, albo przynajmniej nakierowanie mnie jak to zrobić? (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 24.08.2025 - 00:37