Jump to content

Php/xml problem.


captb

Recommended Posts

so i want to call my php file with a query string to select a record out of a XML file... im close but cant get the variable i pass to be the record selected..

 

example... index.php?auction=1

 

i highlighted in red, where it doesnt pick up the proper row

 

 

<?php
ini_set('display_errors', 1); 
error_reporting(E_ALL);

$auction = $_GET{auction}; 


// parse the xml
$xmlFileData = file_get_contents("items.xml");
$xmlData = new SimpleXMLElement($xmlFileData);

[color=red]$location = $xmlData->item[$auction];[/color]

//Retrieving the content from the selected item
$title = $location->title;
$value = $location->value;
$itemnumber = $location->itemnumber;
$description = $location->description;
$donatedby = $location->donatedby;
$image1 = $location->image1;
$image2 = $location->image2;
$image3 = $location->image3;
$image4 = $location->image4;
$image5 = $location->image5;
$image6 = $location->image6;
$image7 = $location->image7;
$image8 = $location->image8;

?>


<style>
.itemimages img {width: 10px; height: 10px;}
img.large {width: 100px; height: 100px;}
</style>
<script language="JavaScript" src="http://code.jquery.com/jquery-1.5.min.js" type="text/javascript"></script>
<script>
$().ready(function() {

$(".itemimages img").click(
$("#largepic").attr("src","this");
});


});
</script>


<table border="1" cellpadding="10">
<tr>
<td valign="top">
<img src="<?php echo $image1 ?>" alt="" border="0" class="large" id="largepic"><br>
<div class="itemimages">
<?php 
// image 1
if (trim(''.$image1) != '') { 
echo "<img src='";
echo $image1;
echo "' alt='' border='0'/> ";
}	
// image 2
if (trim(''.$image2) != '') { 
echo "<img src='";
echo $image2;
echo "' alt='' border='0'/> ";
}	
// image 3
if (trim(''.$image3) != '') { 
echo "<img src='";
echo $image3;
echo "' alt='' border='0'/> ";
}	
// image 4
if (trim(''.$image4) != '') { 
echo "<img src='";
echo $image4;
echo "' alt='' border='0'/> ";
}	
// image 5
if (trim(''.$image5) != '') { 
echo "<img src='";
echo $image5;
echo "' alt='' border='0'/> ";
}	
// image 6
if (trim(''.$image6) != '') { 
echo "<img src='";
echo $image6;
echo "' alt='' border='0'/> ";
}	
// image 7
if (trim(''.$image7) != '') { 
echo "<img src='";
echo $image7;
echo "' alt='' border='0'/> ";
}	
// image 8
if (trim(''.$image8) != '') { 
echo "<img src='";
echo $image8;
echo "' alt='' border='0'/> ";
}	
?>
</div>


</td>
<td valign="top">

<?php echo $title ?><br>
Estimated Value: <?php echo $value ?><br>
Item Number: <?php echo $itemnumber ?><br><br>

<?php echo $description ?><br><br>

Donated by: <?php echo $donatedby ?><br>
</td>
</tr>
</table>

 

[attachment deleted by admin]

Link to comment
Share on other sites

here's the xml

<?xml version="1.0"?> 
<auction> 


<item> 
	<title>The title of item 0</title> 
	<value>$500</value>
	<itemnumber>5</itemnumber>
	<description><![CDATA[why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road?<br><br> why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road? why did the <a href="?">chicken cross the</a> road? ]]></description> 
<image1>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image1>
<image2>http://t1.gstatic.com/images?q=tbn:ANd9GcQndA4h13Voxf7i6eWkdhzqQveavAR4Dzm8Zg6OHROj67wSR-gWBw</image2>
<image3>http://t1.gstatic.com/images?q=tbn:ANd9GcSCq1uboGhPJj2OJdfjUwH52FoXwSJJN4RDFjTW_Nhy7VYQLcWo</image3>
<image4>http://t2.gstatic.com/images?q=tbn:ANd9GcSispWO6sgemQzL3S_RhVd4W8Z2TtY6ujG0j4XAgTJZdPL7EIvx</image4>
</item> 

	<item> 
	<title>The title of item 1</title> 
	<value>$500</value>
	<itemnumber>5</itemnumber>
	<description><![CDATA[why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road?<br><br> why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road? why did the <a href="?">chicken cross the</a> road? ]]></description>  
	<image1>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image1>
	<image2>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image2>
	<image3>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image3>
	<image4>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image4>
	<image5>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image5>
	<image6>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image6>
</item> 

	<item> 
	<title>The title of item 2</title> 
	<value>$500</value>
	<itemnumber>5</itemnumber>
	<description><![CDATA[why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road?<br><br> why did the chicken cross the road? why did the chicken cross the road? why did the chicken cross the road? why did the <a href="?">chicken cross the</a> road? ]]></description> 
	<image1>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image1>
	<image2>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image2>
	<image3>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image3>
	<image4>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image4>
	<image5>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image5>
	<image6>http://farm4.static.flickr.com/3257/3310895789_c1fc5219dc.jpg</image6>
</item> 


</auction>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.