karatekid36 Posted October 6, 2007 Share Posted October 6, 2007 Howdy Everyone, I have the following code where I want to create an update query in a form so that I can update my groups attendance. The variables 100% are working and are pulling the correct info. In the update attendance column, I would like an If else statement that says if the attend_status == present echo SELECTED VALUE="", so that the pull down menu will display the current attendance value. From there I will select the new update attendance info and then submit it using an update query. Below is the code. I am running into other problems with the quotation marks in such because this is all located within the <php> tags. Thanks for the help and let me know if I am being unclear at all. THANKS! <code>// Table header. echo '<h1 align="center">' . $row2['name'] .', ' . $row2['date'] .'</h1> <table align="center" cellspacing="0" cellpadding="5"> <tr> <td align="left"><b>Name</b></td> <td align="left"><b>Current Attendance</b></td> <td align="left"><b>Update Attendance</b></td> </tr> '; // Fetch and print all the records. $bg = '#eeeeee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['BrotherName'] . '</td> <td align="left">' . $row['attend_status'] . '</td> <td><select><option>Present</option><option>Excused</option><option>Unexcused</option></select></td> </tr> '; }</code> Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/ Share on other sites More sharing options...
darkfreaks Posted October 6, 2007 Share Posted October 6, 2007 <?php // Table header. echo '<h1 align="center">' . $row2['name'] .', ' . $row2['date'] .'</h1> <table align="center" cellspacing="0" cellpadding="5"> <tr> <td align="left">Name</td> <td align="left">Current Attendance</td> <td align="left">Update Attendance</td> </tr> '; // Fetch and print all the records. $bg = '#eeeeee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color. echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['BrotherName'] . '</td> <td align="left">' . $row['attend_status'] . '</td> <td><select><option>Present</option><option>Excused</option><option>Unexcused</option></select></td> </tr> '; }?> what is the exact problem you get? please be more informative? Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-363558 Share on other sites More sharing options...
karatekid36 Posted October 6, 2007 Author Share Posted October 6, 2007 All I was saying is that when I have tried to generate this code on my own, I have run into issues with quotes and such. Is there anyone who could point me in the right direction as to how to create the IF/ELSE statement? Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-363561 Share on other sites More sharing options...
sasa Posted October 6, 2007 Share Posted October 6, 2007 try echo '<tr bgcolor="' . $bg . '"> <td align="left">' . $row['BrotherName'] . '</td> <td align="left">' . $row['attend_status'] . '</td> <td><select name="updated"> <option', $x = $row['attend_status'] == 'Present' ? ' selected="selected"' : '' ,'>Present</option> <option', $x = $row['attend_status'] == 'Excused' ? ' selected="selected"' : '' ,'>Excused</option> <option', $x = $row['attend_status'] == 'Unexcused' ? ' selected="selected"' : '' ,'>Unexcused</option> </select></td> </tr> '; Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-363562 Share on other sites More sharing options...
karatekid36 Posted October 7, 2007 Author Share Posted October 7, 2007 Right now I am receiving this error from your code which I am trying to debug... Parse error: syntax error, unexpected $end in /home/carrigan/public_html/php_attend/event_attendance_admin.php on line 113 Let me know what you think. Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-364182 Share on other sites More sharing options...
darkfreaks Posted October 7, 2007 Share Posted October 7, 2007 check your code your missing a close bracket somewhere Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-364184 Share on other sites More sharing options...
teng84 Posted October 7, 2007 Share Posted October 7, 2007 ignore Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-364186 Share on other sites More sharing options...
darkfreaks Posted October 7, 2007 Share Posted October 7, 2007 nvm Link to comment https://forums.phpfreaks.com/topic/72113-solved-ifelse-statment-within-an-selectoption-group/#findComment-364187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.