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
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Thu Jun 16, 2005 11:44 pm
Hi,
I have a form that submits data to mysql database then proceeds to use mail()
How can I grab the id from the entry and send it along with mail()
Also what is the correct way to keep a checkbox checked using echo, ie as you would for a list menu:
Code: Select all
<?php echo $month=='1' ? 'selected' : ''?>>1</option>
Thanks
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Fri Jun 17, 2005 12:16 am
Code: Select all
<?php
echo '<option value="" selected="'.($month==1 ? 'selected':'').'"></option>';
?>
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Fri Jun 17, 2005 1:54 am
Hi,
How would you incorp that into:
Code: Select all
<input type="e;checkbox"e; name="e;c1"e; value="e;Share Twin or Double"e; class="e;input-box"e;>
Thanks
Bennettman
Forum Contributor
Posts: 130 Joined: Sat Jun 15, 2002 3:58 pm
Post
by Bennettman » Fri Jun 17, 2005 5:34 am
Code: Select all
echo '<input type="checkbox" name="c1" value="Share Twin or Double" class="input-box"' . ($month == 1) ? ' CHECKED' : '' . '>';
What you're doing is coming out of the string where the "CHECKED" would appear normally, and using tertiary if-else syntax to add it if the condition is true.
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Fri Jun 17, 2005 5:48 am