Jump to content

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

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.