Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Funkcja generująca formularz
Joachim Peters
post
Post #1





Grupa: Zarejestrowani
Postów: 196
Pomógł: 2
Dołączył: 1.03.2006

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


Pisze swojego cms i chce w nim dać funkcje, która generuje formularze.
Stworzyłem funkcje, która zarządza formularzami od newsów, czyli odpowiada za edytowanie i dodawanie.
Jak narazie to zostałem na tworzeniu tej funkcji, bo coś mi nie wychodzi:
mam plik z funkcją:
  1. <?php
  2. function form_news()
  3. {
  4. $news = '';
  5. if(isset($row['news_title'])) 
  6. {
  7. $news .= '<input type="text" name="news_title" value="' . $row['news_title'] . '"/>';
  8. }
  9. if(isset($row['news_author'])) 
  10. {
  11. $news .= '<input type="text" name="news_author" value="' . $row['news_author'] . '"/>';
  12. }
  13. if(isset($row['news_text'])) 
  14. {
  15. $news .= '<textarea name="news_text" value="' . $row['news_text'] . '">' . $row['news_text'] . '</textarea>';
  16. }
  17. return $news;
  18. }
  19. ?>


a plik, który wykorzystuje tą funkcje:
  1. <?php
  2.  
  3. include('configs/config.php');
  4. include('includes/form.php');
  5.  
  6. $sql = "SELECT * FROM php_news WHERE news_id = $id";
  7. $result = @mysql_query($sql);
  8.  
  9. $row = mysql_fetch_array($result);
  10.  
  11. form_news();
  12. echo $news;
  13.  
  14. ?>


nie wiem co jest nie tak, ale wyświetla się biała strona z bazą jest wszystko ok, to nie jest jej błąd.

Ten post edytował d@ro 21.07.2006, 19:14:31
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
acztery
post
Post #2





Grupa: Zarejestrowani
Postów: 945
Pomógł: 7
Dołączył: 15.03.2005
Skąd: katowice

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


  1. <?php 
  2.  
  3. function form_news($row)
  4. {
  5. $news = '';
  6. if(isset($row['news_title'])) 
  7. {
  8. $news .= '<input type="text" name="news_title" value="' . $row['news_title'] . '"/>';
  9. }
  10. if(isset($row['news_author'])) 
  11. {
  12. $news .= '<input type="text" name="news_author" value="' . $row['news_author'] . '"/>';
  13. }
  14. if(isset($row['news_text'])) 
  15. {$news .= '<textarea name="news_text" value="' . $row['news_text'] . '">' . $row['news_text'] . '</textarea>';
  16.  
  17. }
  18. return $news;
  19. }
  20. ?>



wywolanie
  1. <?php
  2. form_news($row);
  3. ?>


Ten post edytował acztery 22.07.2006, 10:32:35
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: 7.10.2025 - 22:53