PHP Guestbook: Drop down values and functions
Posted: Wed Apr 13, 2016 1:15 am
Hello! I've been trying to tackle this problem myself over the last few days or so, and haven't really been able to come up with an elegant solution. So instead of breaking more pages, I thought I'd come to all you code-gurus out there for some much needed guidance! (Seriously... ; A;)
I'm using PHP Guestbook to set up a theoretical guestbook for my site (I'm not sure if I'm going to implement it just yet, haha). Everything's working great so far, but there's one problem that's bothering me a lot.
I set up a drop down menu so visitors would be able to pick and choose a site they'd like to comment on. I can display the text of the selected option just fine, but I'd also like to find a way to link the text to the URL of the site. So if someone selected "lost-boy.org," it would show up as "lost-boy.org" and if someone selected "And they shall fall," it would show up as "And they shall fall."
So, uh, I think what I'm asking is: How can I get the selected option value of the drop down menu recognized and displayed the way I would like?
Is what I'm trying to do even possible with one value? Or do I have to create multiple values and functions?
Here's my coding so far:
the drop down menu as it is on the form:
the PHP coding connected to the form value ($from):
The "/// SITE URL HERE ///" is just a placeholder because I'm not sure what to do, haha. Also, I don't know if this is important, but the value I'm currently using is one that was provided by the script for a different purpose. I just thought it'd be easier to hijack it for my own uses instead of creating a new one.
I know my explanation is probably not the greatest and it's suuuper late as I'm typing this, so I probably missed something important. Feel free to ask me to clarify things or provide more coding as needed!
Alsooo... I'm terrible at PHP, so assume you're explaining things to a rock (I'm almost positive I've butchered all the PHP semantics I could possibly butcher with this one post!). Thanks for any assistance you can provide!
I'm using PHP Guestbook to set up a theoretical guestbook for my site (I'm not sure if I'm going to implement it just yet, haha). Everything's working great so far, but there's one problem that's bothering me a lot.
I set up a drop down menu so visitors would be able to pick and choose a site they'd like to comment on. I can display the text of the selected option just fine, but I'd also like to find a way to link the text to the URL of the site. So if someone selected "lost-boy.org," it would show up as "lost-boy.org" and if someone selected "And they shall fall," it would show up as "And they shall fall."
So, uh, I think what I'm asking is: How can I get the selected option value of the drop down menu recognized and displayed the way I would like?
Is what I'm trying to do even possible with one value? Or do I have to create multiple values and functions?
Here's my coding so far:
the drop down menu as it is on the form:
Code: Select all
<div class="gbook_left"><span class="gbook_entries"><b>Comment on:</b></span></div>
<div class="gbook_right">
<select type="dropdown" name="from" value="<?php echo $from; ?>">
<option value="lost-boy.org">lost-boy.org</option>
<option value="fanlistings">— fanlistings (please specify which one)</option>
<option value="And they shall fall">And they shall fall (Shadow of the Colossus)</option>
</select>
</div>
Code: Select all
if ($from)
{
$from = '<a href="/// SITE URL HERE /// '.$settings['target'].' rel="nofollow">'.$from.'</a>';
}
else
{
$from = '<a href="http://lost-boy.org" '.$settings['target'].' rel="nofollow">lost-boy.org</a>';
}
I know my explanation is probably not the greatest and it's suuuper late as I'm typing this, so I probably missed something important. Feel free to ask me to clarify things or provide more coding as needed!
Alsooo... I'm terrible at PHP, so assume you're explaining things to a rock (I'm almost positive I've butchered all the PHP semantics I could possibly butcher with this one post!). Thanks for any assistance you can provide!