fields+text+images?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andyman682009
Forum Newbie
Posts: 4
Joined: Mon Jan 11, 2010 4:09 pm

fields+text+images?

Post by andyman682009 »

Hi i am using a directory script where when i use a custom field like a select box,drop down box or text input box
i display their selection by using this code to display the selected text:

<?php echo $listing['custom_1']; ?>

Where the number is the id of the box used.
Is it possible in any way to display an image instead of text when a selection is made?

Thankyou.
User avatar
SimpleManWeb
Forum Commoner
Posts: 57
Joined: Wed Dec 30, 2009 4:15 pm
Location: New Hampshire, USA

Re: fields+text+images?

Post by SimpleManWeb »

You will really need to elaborate a little more before I can give you a good answer to this. I think you are asking that if someone picks a selecting out of a drop down box, can it display a image that matches the selection they just picked?

If that's the case, then yes. There are several ways to do it.

Give me a little more detail about what exactly your form is trying to do and I can help. Also, post some code.
andyman682009
Forum Newbie
Posts: 4
Joined: Mon Jan 11, 2010 4:09 pm

Re: fields+text+images?

Post by andyman682009 »

Hiya, ah that sounds great, i was worried it couldnt be done....well i 'll try and explain.If my drop down selection box says shower,bath,sauna for example,and the visitor selects shower and hits the submit button, i want it to echo/show my icon for a shower and not the text shower, hope this helps explain things:-)

Thanks

Edit:i think this is where the fields are sorted out:
$listing_fields = $PMDR->get('Fields')->getFieldsByCategory('listings',$listing['primary_category_id']);
foreach($listing_fields as $key=>$field) {
if($listing['custom_'.$field['id'].'_allow'] AND !$field['admin_only']) {
$description .= $field['name'].': '.str_replace("\n",', ',$listing['custom_'.$field['id']]).'<br />';
}
}
--------------------------------------------------------------------------------------------------

these are then echoed by whatever the id is after custom_?
<?php echo $listing['custom_1']; ?>
andyman682009
Forum Newbie
Posts: 4
Joined: Mon Jan 11, 2010 4:09 pm

Re: fields+text+images?

Post by andyman682009 »

Hiya, does this code help at all? I think this is what controls the fields...i am not that savvy at php just yet hehe :D
andyman682009
Forum Newbie
Posts: 4
Joined: Mon Jan 11, 2010 4:09 pm

Re: fields+text+images?

Post by andyman682009 »

Hi SimpleManWeb, are you still around???
User avatar
SimpleManWeb
Forum Commoner
Posts: 57
Joined: Wed Dec 30, 2009 4:15 pm
Location: New Hampshire, USA

Re: fields+text+images?

Post by SimpleManWeb »

Hi,
Sorry for the long delay. I lost track of this post. The code you posted doesn't really help much, but I will try to explain the best I can.

Where you said
these are then echoed by whatever the id is after custom_?
<?php echo $listing['custom_1']; ?>
That appears like the place the edit needs to be made. In order to display the image, you would need to someone know what the image name and path is. Is that stored in the "$listing" array? Somthing like $listing['image'] maybe? Once you've found that information, you could do the following.

Code: Select all

 
     ?>
        <img src="<?php echo $listing[image] ?>" border="0" alt="<?php echo $listing['custom_1'] ?>" />
     <?php
 
That should display the image if you've found the correct image path.
Post Reply