créé un fichier xml a partir d'une base mysql

Petit nouveau ! | 9 Messages

05 nov. 2007, 22:29

bonjourd
je cher a créé un fichier xml a partir d'un base jaie réusi mais ca ne marche pas car il na pas l'extention (xml) mais php
sa ces le code php
<?xml version="1.0" encoding="iso-8859-1"?> 
<products><?php require_once('../../../Connections/site_2007.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_afiche_tel_top_clik = 10;
$pageNum_afiche_tel_top_clik = 0;
if (isset($_GET['pageNum_afiche_tel_top_clik'])) {
  $pageNum_afiche_tel_top_clik = $_GET['pageNum_afiche_tel_top_clik'];
}
$startRow_afiche_tel_top_clik = $pageNum_afiche_tel_top_clik * $maxRows_afiche_tel_top_clik;

mysql_select_db($database_site_2007, $site_2007);
$query_afiche_tel_top_clik = "SELECT * FROM sites_annuaire ORDER BY nb_clics DESC";
$query_limit_afiche_tel_top_clik = sprintf("%s LIMIT %d, %d", $query_afiche_tel_top_clik, $startRow_afiche_tel_top_clik, $maxRows_afiche_tel_top_clik);
$afiche_tel_top_clik = mysql_query($query_limit_afiche_tel_top_clik, $site_2007) or die(mysql_error());
$row_afiche_tel_top_clik = mysql_fetch_assoc($afiche_tel_top_clik);

if (isset($_GET['totalRows_afiche_tel_top_clik'])) {
  $totalRows_afiche_tel_top_clik = $_GET['totalRows_afiche_tel_top_clik'];
} else {
  $all_afiche_tel_top_clik = mysql_query($query_afiche_tel_top_clik);
  $totalRows_afiche_tel_top_clik = mysql_num_rows($all_afiche_tel_top_clik);
}
$totalPages_afiche_tel_top_clik = ceil($totalRows_afiche_tel_top_clik/$maxRows_afiche_tel_top_clik)-1;
?>
	
	
<?php do { ?>
	<product>
		<name><?php echo $row_afiche_tel_top_clik['titre']; ?></name>
		<category><?php echo $row_afiche_tel_top_clik['date_validation']; ?></category>
		<boximage><?php echo $row_afiche_tel_top_clik['email_proprio']; ?></boximage>
		<bkgimage></bkgimage>
		<descheader><?php echo $row_afiche_tel_top_clik['titre']; ?></descheader>
		<desc><?php echo $row_afiche_tel_top_clik['description']; ?></desc>
		<features>
			<feature>Revolutionary Vanishing Point</feature>
			<feature>Multiple layer control</feature>
			<feature>Smart Objects</feature>
			<feature>Multi-image digital camera raw file processing</feature>
			<feature>Image Warp</feature>
		</features>
	</product>
	<?php } while ($row_afiche_tel_top_clik = mysql_fetch_assoc($afiche_tel_top_clik)); ?>
	
	
</products>

<?php
mysql_free_result($afiche_tel_top_clik);
?>
le résulta et bon mais pas xml
http://88.175.72.162/Spry_P1_6_10-01/de ... oducts.php
j'aie essayer de l'unclure
<?xml version="1.0"?> 
 
 <?cocoon-process type="xinclude"?> 
 <!--<?cocoon-format type="text/xml"?>--> 
 
 <page xmlns:xinclude="http://www.w3.org/1999/XML/xinclude"> 
 <include xinclude:parse="xml" xinclude:href="http://localhost/Spry_P1_6_10-01/demos/products/products.php"/> 
 </page> 
mais mauvais résulta http://88.175.72.162/Spry_P1_6_10-01/de ... ucts/1.xml

je suis perdu jai bien vue des tuto mai je suis débutant je vous remerci

Mammouth du PHP | 2937 Messages

05 nov. 2007, 22:32

Mets le prologue XML dans un echo, comme suit :
echo '<?xml version="1.0" charset="iso-8859-1"?>';

Petit nouveau ! | 9 Messages

05 nov. 2007, 23:01

merci mais jaie essayer mais sa marche pas ces pareil
http://88.175.72.162/Spry_P1_6_10-01/de ... oducts.php
http://88.175.72.162/Spry_P1_6_10-01/de ... oducts.xml
sur le navigateur ces pareil sa marche mais ma page ne le pren pas car il est en php et non en xml

Code : Tout sélectionner

<script type="text/javascript"> <!-- var dsProducts = new Spry.Data.XMLDataSet("products.xml", "products/product"); var dsProductFeatures = new Spry.Data.NestedXMLDataSet(dsProducts, "features/feature"); --> </script>
meme si je change products.xml en products.xml ces pareille :twisted:
ja ces pas quoi faire

Mammouth du PHP | 2937 Messages

05 nov. 2007, 23:08

Ajoute tout en haut de ton fichier php l'en-tête suivante :
header ('Content-Type: application/xml');

Petit nouveau ! | 9 Messages

05 nov. 2007, 23:32

je te remerci sa marche
heureusement que tu étai la ca fait deux jour que je bloquai
merci encore[/b]