Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem Z Wyświetlaniem Wyniku, MySQL
MoD
post
Post #1





Grupa: Zarejestrowani
Postów: 193
Pomógł: 0
Dołączył: 14.09.2003
Skąd: Brodnica (koło Torunia)

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


Mam taki kod:
  1. <?php
  2.     require_once( 'includes/sql_functions.inc.php' );
  3.     require_once( 'includes/session.inc.php' );
  4.     
  5.     CheckSession();
  6.     Connect();
  7.     
  8.     print 'Zapytanie SQL:<br>';
  9.     
  10.     require_once( 'includes/sql_form.inc.php' );
  11.     
  12.     if ( $_POST['sql'] )
  13.     {
  14.         if ( ereg( '^SELECT', $_POST['sql'] ) || ereg( '^select', $_POST['sql'] ) )
  15.         {
  16.             $tablename = Table( $_POST['sql'] );
  17.             
  18.             $result = mysql_query( $_POST['sql'] ) or die( 'MySQL zwrócił komunikat: '.mysql_error() );
  19.             
  20.             print '<br>';
  21.             print '<table border=1>';
  22.             print '<tr>';
  23.             
  24.             $fields = mysql_list_fields('database', $tablename);
  25.             
  26.             for ( $i=0; $i<count($fields); $i++ )
  27.             {
  28.                 print '<td><b>'.$fields[$i].'</b></td>';
  29.             }
  30.             
  31.             print '</tr>';
  32.             print '<tr>';
  33.             
  34.             while ( $row = mysql_fetch_array( $result ) )
  35.             {
  36.                 for ( $j=0; $j<count($result); $j++ )
  37.                 {
  38.                     print '<td>'.$row[$j].'</td>';
  39.                 }
  40.             }
  41.             
  42.             print '</tr>';
  43.             print '</table>';
  44.         }
  45.         else
  46.         {
  47.             mysql_query( $_POST['sql'] ) or die( 'MySQL zwrócił komunikat: '.mysql_error() );
  48.         }
  49.     }
  50.     
  51.     print '</center>';
  52.     
  53. ?>

Jak wpiszę zapytanie 'select * from tabela' to powinno mi wyświetlić nazwy pól i ich wartości, a nie wyświetla nic (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) Pomóżcie mi!
Z góry dziękuję.

Ten post edytował MoD 24.08.2004, 18:16:12
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: 22.08.2025 - 22:43