Jump to content

[SOLVED] storing the output xml from my php in an xml file


cleary1981

Recommended Posts

sorry heres my script

 

<?php 

header("Content-type: text/xml"); 

require "config.php";

$proj = 'j8888'; //$_REQUEST['proj'];

$q1 = mysql_query("SELECT * FROM company, project WHERE company.company_name = project.company_name AND proj_id = '$proj'") or die(mysql_error);
$r1 = mysql_fetch_assoc($q1);
$acc_no = $r1['acc_no'];
$company_name = $r1['company_name'];
$contact = $r1['contact'];
$add1 = $r1['add1'];
$add2 = $r1['add2'];
$town = $r1['town'];
$county = $r1['county'];
$pcode = $r1['pcode'];
$tel = $r1['tel'];
$proj_id = $r1['proj_id'];
$project_name = $r1['project_name'];
$form = $r1['form'];
$access = $r1['access'];
$cable_entry = $r1['cable_entry'];
$ip_rating = $r1['ip_rating'];
$fault_rating = $r1['fault_rating'];
$proj_manager = $r1['proj_manager'];
$deadline = $r1['deadline'];

$q2 = mysql_query("SELECT * FROM object, module WHERE object.module_name = module.module_name AND proj_id = '$proj'");


//start of xml document
$xml_output = "<?xml version=\"1.0\"?>\n"; 
$xml_output = "<?xml-stylesheet type='text/xsl' href='quote.xsl'?>\n";
$xml_output .= "<quote>\n"; 
$xml_output .= "\t<company>\n";
	$xml_output .= "\t\t<comp_name>" . $company_name . "</comp_name>\n";
	$xml_output .= "\t\t<contact>" . $contact . "</contact>\n";  
	$xml_output .= "\t<address>\n";
		$xml_output .= "\t\t<add1>" . $add1 . "</add1>\n";  
		$xml_output .= "\t\t<add2>" . $add2 . "</add2>\n";
		$xml_output .= "\t\t<town>" . $town . "</town>\n";  
		$xml_output .= "\t\t<county>" . $county . "</county>\n";  
		$xml_output .= "\t\t<pcode>" . $pcode . "</pcode>\n";  
	$xml_output .= "\t</address>\n";
	$xml_output .= "\t\t<tel>" . $tel . "</tel>\n";  
$xml_output .= "\t</company>\n";
$xml_output .= "\t<details>\n";
	$xml_output .= "\t\t<proj_id>" . $proj_id . "</proj_id>\n";
	$xml_output .= "\t\t<proj_name>" . $project_name . "</proj_name>\n";  
	$xml_output .= "\t\t<form>" . $form . "</form>\n";  
	$xml_output .= "\t\t<access>" . $access . "</access>\n";  
	$xml_output .= "\t\t<cable_entry>" . $cable_entry . "</cable_entry>\n";  
	$xml_output .= "\t\t<ip>" . $ip_rating . "</ip>\n";  
	$xml_output .= "\t\t<fault>" . $fault_rating . "</fault>\n";  
	$xml_output .= "\t\t<proj_manager>" . $proj_manager . "</proj_manager>\n";  
	$xml_output .= "\t\t<deadline>" . $deadline . "</deadline>\n";  
$xml_output .= "\t</details>\n";

$xml_output .= "<objects>\n";
	for($x = 0 ; $x < mysql_num_rows($q2) ; $x++){
		$r2 = mysql_fetch_assoc($q2); 
		$obj_id = $r2['object_id'];
		$xml_output .= "\t<obj id='$obj_id'>\n";
			$xml_output .= "\t\t<object_name>" . $r2['object_name'] . "</object_name>\n"; 
			$xml_output .= "\t\t<module_name>" . $r2['module_name'] . "</module_name>\n"; 
			$xml_output .= "\t\t<mod_desc>" . $r2['mod_desc'] . "</mod_desc>\n"; 
			$xml_output .= "\t\t<obj_desc>" . $r2['objDesc'] . "</obj_desc>\n"; 
			$xml_output .= "\t\t<xpos>" . $r2['xpos'] . "</xpos>\n"; 
			$xml_output .= "\t\t<ypos>" . $r2['ypos'] . "</ypos>\n"; 
			$xml_output .= "\t\t<height>" . $r2['height'] . "</height>\n"; 
			$xml_output .= "\t\t<width>" . $r2['width'] . "</width>\n"; 
			$xml_output .= "\t\t<depth>" . $r2['depth'] . "</depth>\n"; 
		$xml_output .= "\t</obj>\n"; 
	}
$xml_output .= "</objects>"; 

$xml_output .= "\t</quote>\n";

echo $xml_output; 

?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.