Grab mysql entry id

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
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Grab mysql entry id

Post by Jim_Bo »

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
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

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 »

Hi,

How would you incorp that into:

Code: Select all

<input type=&quote;checkbox&quote; name=&quote;c1&quote; value=&quote;Share Twin or Double&quote; class=&quote;input-box&quote;>
Thanks
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post by Bennettman »

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.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

for you other question look into http://www.php.net/mysql_insert_id
Post Reply