Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php/mysql] pobieranie rekordów + wyświetlenie z nazwą
b4x
post
Post #1





Grupa: Zarejestrowani
Postów: 658
Pomógł: 95
Dołączył: 20.12.2005
Skąd: N54,35° E18,63° (Gdańsk)

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


plik teledyski.php
  1. <?php
  2. function site_main() {
  3.  
  4. global $id, $mess;
  5.  
  6. if(isset($id)) {
  7. show_info();
  8. count_info();
  9.  
  10. } else {
  11.  
  12. main_title_open();
  13. echo 'bląd';
  14. main_title_close();
  15.  
  16. main_text_open();
  17. echo $mess[e0];
  18. main_text_close();
  19.  
  20.  
  21. }
  22.  
  23. }
  24. ?>


- wiec tak chciałbym aby wszystkie teledyski wyświetlały się na jednej stronie - chodzi mi o to żeby pobierały się nazwy z bazy i były do nich linki . Jak to zrobic?

  1. <?php
  2.  
  3. # wyswietlanie teledysku
  4.  
  5. function show_info() {
  6.  
  7. global $info_tbl, $PHP_SELF, $id, $color, $mess;
  8.  
  9. $id = (int) $id;
  10.  
  11. $query = "SELECT * FROM $info_tbl WHERE id=$id";
  12. $result = mysql_query($query);
  13. $a = mysql_num_rows($result);
  14.  
  15. if($a==0) {
  16.  
  17. $title = 'bląd!';
  18. $text = 'Nie ma teledysku o takim numerze w bazie danych! '.$mess['e0'];
  19.  
  20.  
  21. } else {
  22.  
  23. $r = mysql_fetch_array($result);
  24.  
  25. $title = $r['title'];
  26. $count = $r['opened'];
  27. $text = $r['text'];
  28. $date = $r['date'];
  29. $author = $r['author'];
  30.  
  31. $title = stripslashes($title);
  32. $text = make_clickable($text);
  33. $print = 'print.php?what=infopage&id='.$id;
  34.  
  35. }
  36.  
  37. if(is_login()=='yes') {
  38. $link_a = '<a href="admin.php?op=info&cmd=edit&id='.$id.'&goto=index.php" title="edit" class="t_main">E</a>';
  39. $link_b = '<a href="admin.php?op=info&cmd=del&id='.$id.'&goto=index.php" title="delete" class="t_main">D</a>';
  40. $title = $title.' <b>&middot;&middot;&middot;</b> (<b> '.$link_a.'</b> | <b>'.$link_b.' </b>)';
  41. }
  42.  
  43.  
  44. main_title_open();
  45. echo $title;
  46. main_title_close();
  47.  
  48. main_text_open($author, $date, $comment, $comment_num, $print);
  49. echo '<html><center>
  50. <object width="425" height="350">
  51. <param name="movie" value="http://www.youtube.com/v/'.$text.'"></param>
  52. <param name="wmode" value="transparent"></param>
  53. <embed src="http://www.youtube.com/v/'.$text.'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350">
  54. </embed></object>
  55. </html><br />
  56. </center>';
  57. }
  58.  
  59.  
  60. function count_info() {
  61.  
  62. global $id, $info_tbl;
  63.  
  64. $query = "SELECT opened FROM $info_tbl WHERE id=$id";
  65. $result = mysql_query($query);
  66. $r = mysql_fetch_array($result);
  67.  
  68. $count = $r['opened'];
  69. $count++;
  70.  
  71. $query = "UPDATE $info_tbl SET opened=$count WHERE id=$id";
  72. $result = mysql_query($query);
  73.  
  74.  
  75. }
  76.  
  77. ?>


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Ociu
post
Post #2





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




  1. <?php
  2. function show_names()
  3. {
  4. global $info_tbl;
  5. $query = "SELECT id, title FROM $info_tbl";
  6.  
  7. while($r = mysql_fetch_array($query))
  8. {
  9. print "<a href='index.php?cmd=show&id=".$r['id']."'>".$r['title']."</a><br />";
  10. }
  11.  
  12. }
  13. ?>


Zmień tylko format linku.
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 Aktualny czas: 21.08.2025 - 17:59