Salve ragazzi ho un problema, sto creando dei file xml con le tabelle, campi e valori del Database. Non mi stampa i Valori !
PHP:
mysql_connect( 'localhost', 'root', '' );
mysql_select_db( 'name' );
$list['table'] = @mysql_list_tables('name');
for ( $i = 0; $i < mysql_num_rows( $list['table'] ); $i++ ){
$cache = '<?xml version="1.0" encoding="utf-8"?>';
$cache .= '<rss version="2.0">';
$cache .= '<channel>';
$tab = mysql_tablename( $list['table'], $i);
$query = mysql_query( 'select * from '.$tab );
if( $query && mysql_num_rows( $query ) > 0 ){
$columns = mysql_num_fields( $query );
for ( $u = 0; $u < $columns; $u++ ) {
if( $u == 0 )
$cache .= '<item>';
$field = mysql_field_name( $query, $u );
while( $obj = mysql_fetch_object( $query ) ){
$cache .= '<'.$field.'>'.$obj->field.'</'.$field.'>';
}
if( $u == ( $columns - 1 ) )
$cache .= '</item>';
}
}
mysql_free_result( $query );
$cache .= '</channel>';
$cache .= '</rss>';
$url = 'cache/'.$tab.'.xml';
$open = fopen( $url, 'w' );
fwrite( $open, $cache );
fclose($open);
}
mysql_close();
mysql_free_result( $list['table'] );
Ultima modifica: