Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Status gg
mausik
post
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 20.08.2009

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


Witam, ciągle piszę swój 1 skrypt. Teraz mam problem z umieszczeniem statusu gg w pliku php który czyta dane (IMG:style_emoticons/default/smile.gif)

Numer gg z tabeli gg czyta, ale nie wiem jak zrobić by był odnośnik z obecnym statusem gg.

Mój kod od tego pliku wygląda tak.

  1. <?php
  2. include ('header.php');
  3. ?>
  4.  
  5. <center>
  6. <?
  7. @$db = mysql_pconnect("localhost", "mausik_test", "mojetajnehaslo");
  8. $wyborbazy=@mysql_select_db("mausik_test");
  9. $query = "select * from prezenterzy";
  10. $result = mysql_query($query);
  11. $num_results =mysql_num_rows($result);
  12.  
  13. print "<p>Prezenterów w bazie danych: ".$num_results."</p>";
  14. for ($i=0; $i <$num_results; $i++) {
  15. $row = mysql_fetch_array($result);
  16. print stripslashes($row["imie"] );
  17. print "<br>";
  18. print stripslashes($row["ksywka"] );
  19. print "<br>";
  20. print stripslashes($row["stanowisko"] );
  21. print "<br>";
  22. print stripslashes($row["gg"] );
  23. print "<br>";
  24. }
  25. ?>
  26.  
  27.  
  28.  
  29.  
  30.  
  31. <?php include ('footer.php'); ?>


Myślałem coś typu

  1. <a href="gg:[wczytać numer z bazy]"><img src="http://www.gadu-gadu.pl/users/status.asp?id=[wczytać numer z bazy]" border="0"></a>


lecz nie wiem jak to wykonać, proszę o pomoc
Go to the top of the page
+Quote Post
ShadowD
post
Post #2





Grupa: Zarejestrowani
Postów: 1 333
Pomógł: 137
Dołączył: 25.03.2008
Skąd: jesteś??

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


Człowieku co ty robisz, już kiedyś dostałem kilkaset linii tabeli echowanej linie po linii toż tragedia jest. Wywal e printy i zainteresuj się łączeniem ciągów w php. Skoro wyświetlasz w jednym miejscu nr to jaki problem przenieść go w inne?

  1. [list=1][*]echo '<a href="gg:'.$row["gg"].'"><img src="http://www.gadu-gadu.pl/users/status.asp?id=[wczytać numer z bazy]" border="0"></a>';[/list]


Analogicznie w drugim miejscu, i to w pętlę. ^^

Następnie, dlaczego korzystasz z pętli for(), są inne bardziej odpowiednie stworzone do takich zastosowań np. while()!

Poczytaj jakieś kursy dla początkujących bądź może jakaś książka. ;]

Ten post edytował ShadowD 25.08.2009, 15:58:21
Go to the top of the page
+Quote Post
mausik
post
Post #3





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 20.08.2009

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


Użyłem for, ponieważ tak było w tutku (IMG:style_emoticons/default/smile.gif)
Jestem jeszcze bardzo słaby, może kiedyś.

Jak dałem w echo. to jeden za drugim się wyświetlił, zero odstępu itp, a to powinno iść tak jak w tym print...
czyli

krzys
krzychu
admin
56416

kamil
kamilo
prezenter
21235456

itp ...
Go to the top of the page
+Quote Post
ShadowD
post
Post #4





Grupa: Zarejestrowani
Postów: 1 333
Pomógł: 137
Dołączył: 25.03.2008
Skąd: jesteś??

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


To nie ma znaczenia, jeśli prawidłowo dodasz br to i tak będą takie odstępy!

Uczenie się głupot lekko mija się z celem...

  1. while($row = mysql_fetch_array($result))
  2. echo stripslashes($row["imie"]).'<br />'.stripslashes($row["ksywka"]).'<br />'.stripslashes($row["stanowisko"]).'<br />'.stripslashes($row["gg"] ).'<br /><br />';


Zamiast całego for'a, o ile lepiej...
Go to the top of the page
+Quote Post
mausik
post
Post #5





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 20.08.2009

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


  1. <?php
  2. include ('header.php');
  3. ?>
  4.  
  5. <center>
  6. <?
  7. $query = "select * from prezenterzy";
  8. $result = mysql_query($query);
  9. $num_results =mysql_num_rows($result);
  10.  
  11. print "<p>Prezenterów w bazie danych: ".$num_results."</p>";
  12. while($row = mysql_fetch_array($result))
  13. echo stripslashes($row["imie"]).'<br />'.stripslashes($row["ksywka"]).'<br />'.stripslashes($row["stanowisko"]).'<br />Status: <a href="gg:'.$row["gg"].'"><img src="http://www.gadu-gadu.pl/users/status.asp?id='.$row["gg"].'" border="0"></a><br /><br />';
  14. ?>
  15.  
  16.  
  17.  
  18.  
  19.  
  20. <?php include ('footer.php'); ?>


Okej działa (IMG:style_emoticons/default/smile.gif)

Teraz walczę nad usuwaniem ID użytkownika (IMG:style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post

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: 23.08.2025 - 01:01