Page 1 of 1

Grab mysql entry id

Posted: Thu Jun 16, 2005 11:44 pm
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

Posted: Fri Jun 17, 2005 12:16 am
by anjanesh

Code: Select all

<?php
echo '<option value="" selected="'.($month==1 ? 'selected':'').'"></option>'; 
?>

Posted: Fri Jun 17, 2005 1:54 am
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

Posted: Fri Jun 17, 2005 5:34 am
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.

Posted: Fri Jun 17, 2005 5:48 am
by phpScott
for you other question look into http://www.php.net/mysql_insert_id