Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Moore
7,121 PointsDisplaying tasks in conjunction with a radio button(may be beyond the scope)
My goal for a little personal challenge was to make the php script display only the tasks based on the radio button that was clicked, but I am unsure as to how to make the radio button click run a php function then display it the webpage. And upon clicking of another button, erase the old information and display the new information. If it is way beyond the scope of this course(PHP Arrays and Control Structures) and covered in another one, I would appreciate knowing which one. I am going down the php track currently.
The functions and code I have is the following:
PHP
<?php
include 'list.php';
$radiobuttonvalue = 'value_of_radio_button_from_webpage';
$order = array();
foreach($list as $key => $item){
if($item['complete'] == $radiobuttonvalue){
$order[] = $key;
}else{
$order = array_keys($list);
}
}
echo "<br>";
cho '<table>';
echo '<tr>';
echo '<th>Title</th>';
echo '<th>Priority</th>';
echo '<th>Due Date</th>';
echo '<th>Complete</th>';
echo '</tr>';
foreach($order as $id){
echo '<tr>';
echo '<td>' . $list[$id]['title'] . "</td>\n";
echo '<td>' . $list[$id]['priority'] . "</td>\n";
echo '<td>' . $list[$id]['due'] . "</td>\n";
echo '<td>';
if($list[$id]['complete']){
echo "\t- yes";
}else{
echo "\t- no";
}
echo "</td>\n";
echo '</tr>';
}
echo "</table>";
?>
HTML
<input type="radio" name="records" value="true" class="displayValue">Completed Only<br>
<input type="radio" name="records" value="false" class="displayValue">Not Completed Only
<input type="radio" name="records" value="allrecords" class="displayValue">All Records