Jump to content

strip php for xml


sullyman

Recommended Posts

Hi folks,

 

i need some help extracting a single mysql column [images] containing images (image01.jpg, image02.jpg, image03.jpg) to form an xml page.

 

I have got the following to work

 

$image = "http://www.site.ie/files/".cleanText($row["images"]);

 

but the result is <image>http://www.site.ie/files/image01.jpg image02.jpg image03.jpg)</image>

 

I would like it to come out as

 

<image>http://www.site.ie/files/image01.jpg, http://www.site.ie/files/image02.jpg, http://www.site.ie/files/image03.jpg</image>

 

If there is no image for that row, i would like the xml to show nothing e.g. <image></image>

 

Is the above possible. Can anyone help please?

 

Thanks,

Sully

 

 

Link to comment
https://forums.phpfreaks.com/topic/124711-strip-php-for-xml/
Share on other sites

That's not the point.  You shouldn't have more than one value in a single column.  Commas, spaces, pipes (|), anything...doesn't matter.  There should be another table so you can do a simple JOIN query and then use implode().  You shouldn't have to parse MySQL results.

Link to comment
https://forums.phpfreaks.com/topic/124711-strip-php-for-xml/#findComment-644167
Share on other sites

Lol, you purchased something that does that?  =P  Kinda funny.  You should go complain to the creator that his code is bad.  Really bad.  If you *REALLY* aren't able to change it, I guess you could do:

 

<?php
//assume you're connected
$query = "SELECT images FROM your_table WHERE id=$id"; //who cares, change this how you need to =P
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$row = str_replace(' ', ',', $row);
//continue from here
?>

Link to comment
https://forums.phpfreaks.com/topic/124711-strip-php-for-xml/#findComment-644174
Share on other sites

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.