I’m trying to work my way through a problem. It’s two parts:
-
I want to create a loop that reads out each of my page’s menu_name from the database and on the same line that it reads it out, put a radio button to change the visibility. So far It looks like my radio buttons are all connected because (instead of being checked "no" for each of them it is only checked no on the last
<li>item://K's function: function get_all_pages() { global $connection; $query = "SELECT * FROM pages "; $query .= "WHERE visible = 1 "; $query .= "ORDER BY position ASC"; $page_set = mysql_query($query, $connection); confirm_query($page_set); return $page_set; } //K's function: function list_all_pages(){ $output = "<ul>"; $page_set = get_all_pages(); while ($page = mysql_fetch_array($page_set)) { $output .= "<li><a href=\"add_feature.php?page=" . urlencode($page["id"]) . "\">{$page["menu_name"]}</a></li>"; $output .= " <input type=\"radio\" name=\"visible\" value=\"0\" checked=\"checked\" /> No <input type=\"radio\" name=\"visible\" value=\"1\" /> Yes"; } $output .= "</ul>"; return $output; }

- I’m trying to do some sort of ajax thing with Javascript.. so I want the visible radio buttons to be next to my dynamically generated menu list. I want them to all be checked to no… when they are checked to yes I want a dropdown list to appear where they can pick the numbers 1-8 (the numbers will mean what position they will appear in).
I am new and trying to figure this out is a little out of my reach without some assistance from Javascript and php/mysql experts.
Your radio buttons all have the same “name” attribute, so you can only select one at a time. You could append some unique identifier to the attribute value. For example,
visible_{$page_id}:Advanced tip: With PHP you can simplify the processing of “page” data by using specially-formatted input names — like so:
pages[$page_id][visible].pages[$page_id][order].Once the user submits this data, PHP converts it into a “pages” array (with indices being page_id’s). You can then do something like: