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.
fields+text+images?
Moderator: General Moderators
- SimpleManWeb
- Forum Commoner
- Posts: 57
- Joined: Wed Dec 30, 2009 4:15 pm
- Location: New Hampshire, USA
Re: fields+text+images?
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.
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?
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']; ?>
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?
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 
-
andyman682009
- Forum Newbie
- Posts: 4
- Joined: Mon Jan 11, 2010 4:09 pm
Re: fields+text+images?
Hi SimpleManWeb, are you still around???
- SimpleManWeb
- Forum Commoner
- Posts: 57
- Joined: Wed Dec 30, 2009 4:15 pm
- Location: New Hampshire, USA
Re: fields+text+images?
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
That should display the image if you've found the correct image path.
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
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.these are then echoed by whatever the id is after custom_?
<?php echo $listing['custom_1']; ?>
Code: Select all
?>
<img src="<?php echo $listing[image] ?>" border="0" alt="<?php echo $listing['custom_1'] ?>" />
<?php