Jump to content

cocolino

New Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by cocolino

  1. I resolve my problem. Thank you for your time @mac_gyver !
  2. Here is all code from file.php <?php session_start(); require ('login.php'); if ($user['status'] != '1' || $user['group'] != '2') { header('Location: '. $s['url'] .'/enter.php'); exit(); } $action = $_GET['select']; if ($action == 'categories') { $categories = array (); $categories_query = mysql_query("SELECT * FROM categories ORDER BY name"); while ($categories_row = mysql_fetch_array($categories_query)) { $categories[] = array ( 'id' => $categories_row['catid'], 'name' => $categories_row['name'], 'title' => $categories_row['title'], 'url' => $categories_row['url'], 'icon' => $categories_row['icon'], 'description' => $categories_row['description'] ); } categories_admin(); } elseif ($action == 'edit_category') { $category_id = (int) $_GET['categ']; if (isset($_POST['submit_edit_category'])) { $edit_category_query = mysql_query("UPDATE categories SET name = '". $_POST['name'] ."', description = '". $_POST['description'] ."' WHERE catid = '". $category_id ."'"); // categories sidebar $delete_category_query = mysql_query("delete FROM map_category WHERE catid2 = '". $category_id ."'"); if (empty($_POST['check_list'])) {echo '';} if (is_array($_POST['check_list'])) { foreach ($_POST['check_list'] as $selected) { $insert_category_query = mysql_query("INSERT INTO map_category(catid1, catid2) VALUES ('". $category_id ."','". $selected ."')"); } } // categories footer $delete_category_query = mysql_query("delete FROM map_category_footer WHERE catid2 = '". $category_id ."'"); if (empty($_POST['check_list_footer'])) {echo '';} if (is_array($_POST['check_list_footer'])) { foreach ($_POST['check_list_footer'] as $selected) { $insert_category_query = mysql_query("INSERT INTO map_category_footer(catid1, catid2) VALUES ('". $category_id ."','". $selected ."')"); } } redirect_page('/admin/file.php?select=edit_category&categ='. $category_id); } $category_query = mysql_query("SELECT * FROM categories WHERE catid = '". $category_id ."' LIMIT 1"); $category_row = mysql_fetch_assoc($category_query); $edit_category = array ( 'name' => $category_row['name'], 'description' => $category_row['description'] ); // select categories sidebar $top_category_query = mysql_query("SELECT c.catid, c.name, (CASE WHEN mc.catid1 IS NULL THEN 0 ELSE 1 END) AS is_selected FROM categories c LEFT JOIN map_category mc ON c.catid = mc.catid2 and mc.catid1 = '". $category_id ."' WHERE c.catid <> '". $category_id ."' ORDER BY c.name ASC "); while($top_category_row = mysql_fetch_assoc($top_category_query)) { $top_edit_category[] = $top_category_row; } // select categories footer $top_category_footer_query = mysql_query("SELECT c.catid, c.name, (CASE WHEN mc.catid1 IS NULL THEN 0 ELSE 1 END) AS is_selected FROM categories c LEFT JOIN map_category_footer mc ON c.catid = mc.catid2 and mc.catid1 = '". $category_id ."' WHERE c.catid <> '". $category_id ."' ORDER BY c.name ASC "); while($top_category_footer_row = mysql_fetch_assoc($top_category_footer_query)) { $top_edit_category_footer[] = $top_category_footer_row; } edit_category_admin(); } ?>
  3. Hi, i understand your opinion but this part of code make a action for that request. Way you want all code?
  4. Thanks but i want solutions because i'm beginner and don't know what to do in the code!
  5. Wen i update the page. every time wen i push submit button the checkboxes selected is duplicate. Here is the printscreen of issue. Thanks!
  6. I'm beginner and i hope to get answer from advanced members. The code from file start with elseif because that is the code witch make the call of execute... i don't see the sense to post entire code.
  7. because that is the code witch make the call of execute... i don't see the sense to post entire code. thanks
  8. Hello, my name is Terry and i'm new here. I hope to find the best answear from experts!
  9. Hello, i have the following problem with checkbox option... Wen i have selected one or more checkboxes and update a page the checkbox return same values doubled, tripled or how many time is page updated. I want to resolve this error. Can anybody help me? Here is the 2 files, file.php and template.php the file.php code <?php elseif ($action == 'edit_category') { $category_id = (int) $_GET['categ']; if (isset($_POST['submit_edit_category'])) { $edit_category_query = mysql_query("UPDATE categories SET name = '". $_POST['name'] ."', description = '". $_POST['description'] ."' WHERE catid = '". $category_id ."'"); // categories sidebar $delete_category_query = mysql_query("delete FROM map_category WHERE catid2 = '". $category_id ."'"); if (empty($_POST['check_list'])) {echo '';} if (is_array($_POST['check_list'])) { foreach ($_POST['check_list'] as $selected) { $insert_category_query = mysql_query("INSERT INTO map_category(catid1, catid2) VALUES ('". $category_id ."','". $selected ."')"); } } // categories footer $delete_category_query = mysql_query("delete FROM map_category_footer WHERE catid2 = '". $category_id ."'"); if (empty($_POST['check_list_footer'])) {echo '';} if (is_array($_POST['check_list_footer'])) { foreach ($_POST['check_list_footer'] as $selected) { $insert_category_query = mysql_query("INSERT INTO map_category_footer(catid1, catid2) VALUES ('". $category_id ."','". $selected ."')"); } } redirect_page('/admin/file.php?select=edit_category&categ='. $category_id); } $category_query = mysql_query("SELECT * FROM categories WHERE catid = '". $category_id ."' LIMIT 1"); $category_row = mysql_fetch_assoc($category_query); $edit_category = array ( 'name' => $category_row['name'], 'description' => $category_row['description'] ); // select categories sidebar $top_category_query = mysql_query("SELECT c.catid, c.name, (CASE WHEN mc.catid1 IS NULL THEN 0 ELSE 1 END) AS is_selected FROM categories c LEFT JOIN map_category mc ON c.catid = mc.catid2 and mc.catid1 = '". $category_id ."' WHERE c.catid <> '". $category_id ."' ORDER BY c.name ASC "); while($top_category_row = mysql_fetch_assoc($top_category_query)) { $top_edit_category[] = $top_category_row; } // select categories footer $top_category_footer_query = mysql_query("SELECT c.catid, c.name, (CASE WHEN mc.catid1 IS NULL THEN 0 ELSE 1 END) AS is_selected FROM categories c LEFT JOIN map_category_footer mc ON c.catid = mc.catid2 and mc.catid1 = '". $category_id ."' WHERE c.catid <> '". $category_id ."' ORDER BY c.name ASC "); while($top_category_footer_row = mysql_fetch_assoc($top_category_footer_query)) { $top_edit_category_footer[] = $top_category_footer_row; } edit_category_admin(); } ?> and template.php code <?php function edit_category_admin() {global $edit_category,$top_edit_category,$top_edit_category_footer; main_header(); main_menu(); echo'<div id="center"><div id="admin"><h3>Edit category</h3>'; echo '<form action="" method="POST" name="form" onsubmit="return verify_add()"> <div class="left">Name</div> <div class="right"><input type="text" name="name" size="55" value="'. $edit_category['name'] .'" /></div> <div class="clear"></div> <div class="left">Description</div> <div class="right"><textarea name="description" rows="5" cols="95">'. $edit_category['description'] .'</textarea></div> <div class="clear"></div> <div class="left">Sidebar Category:</div> <div class="right"><div id="cat" style="background-color:#fcfebc;width: 100%px;height: 400px;overflow: scroll;">'; foreach ($top_edit_category as $top_cat) { echo '<label><input type="checkbox" name="check_list[]" value="'. $top_cat['catid'] .'" '. ($top_cat['is_selected'] == '1' ? 'checked' : '') .' /> '. $top_cat['name'] .'</label>'; } echo '</div></div> <div class="clear"></div> <div class="left">Footer Category:</div> <div class="right"><div id="cat" style="background-color:#DAF7A6;width: 100%px;height: 200px;overflow: scroll;">'; foreach ($top_edit_category_footer as $top_cat) { echo '<label><input type="checkbox" name="check_list_footer[]" value="'. $top_cat['catid'] .'" '. ($top_cat['is_selected'] == '1' ? 'checked' : '') .' /> '. $top_cat['name'] .'</label>'; } echo '</div></div> <div class="clear"></div> <div align="center"> <input type="submit" name="submit_edit_category" value="Edit category" /> </div><br /> </form>'; echo '</div></div> <div class="clear"></div>'; main_footer(); } ?> Many thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.