Page 1 of 1

fields+text+images?

Posted: Mon Jan 11, 2010 4:16 pm
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.

Re: fields+text+images?

Posted: Mon Jan 11, 2010 6:36 pm
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.

Re: fields+text+images?

Posted: Tue Jan 12, 2010 6:17 am
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']; ?>

Re: fields+text+images?

Posted: Wed Jan 13, 2010 3:07 am
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

Re: fields+text+images?

Posted: Mon Jan 18, 2010 6:42 am
by andyman682009
Hi SimpleManWeb, are you still around???

Re: fields+text+images?

Posted: Mon Jan 18, 2010 8:01 am
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.