function del_line_id($file, $id_to_del) { $last_line = get_nb_last_line($file); $nb_champ = 1; $nb_ligne_boucle = 0; // array lines $array[$last_line]; while (($ligne = fgets($file, 4096)) != false) { $nb_ligne_boucle++; $array[$nb_ligne_boucle] = $ligne; } $champ = get_champ_line($array[$nb_ligne_boucle], $nb_champ); if ($champ == $id_to_del) { $array[$nb_ligne_boucle] = ' '; } for ($i; $i <= $nb_ligne_boucle; $i++) { if ($array[$i] == ' ') { $array[$i] = $array[$i + 1]; } } }
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <h1>categories</h1> <?php require 'bdd.php'; $champ1 = 1; $champ2 = 2; $rep_id_categorie_nom = '../' . $id_categorie_nom; $last_line_categories = get_nb_last_line($rep_id_categorie_nom); $tab_categories[$last_line_categories][2] = 0; for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($rep_id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } $j = 1; for ($i = 1; $i <= $last_line_categories; $i++) { if ($j == 1) { echo '<div style="color:green;background-color:D8D8D8;float:left;width:72%;height:45px;">'; $j++; } else { echo '<div style="color:green;float:left;width:72%;height:45px;">'; $j = 1; } echo '<strong>' . $tab_categories[$i][$champ2] . '</strong><br />'; echo '</div>'; echo '<div style="float:left;width:28%;height:45px;">'; echo '<img onclick="edit_categorie();" width="45px" height="45px" src="../bdd/images/icones/edit.png">'; echo '<img onclick="delete_categorie();" width="45px" height="45px" src="../bdd/images/icones/delete.png">'; echo '</div>'; }
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <strong><h1>wiki</h1></strong> <?php // afficher categories et ses pages // boutons add page et categorie require 'core/bdd.php'; // champs $champ0 = 0; $champ1 = 1; $champ2 = 2; $champ3 = 3; // numero dernieres lignes fini $last_line_categories = get_nb_last_line($id_categorie_nom); $last_line_relations = get_nb_last_line($id_page_id_categorie_nom_page); // tableaux fini $tab_categories[$last_line_categories][2] = 0; $tab_relations[$last_line_relations][3] = 0; // tab categories fini for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } // tab avec lignes relations fini for ($j = 1; $j <= $last_line_relations; $j++) { $relation = get_line($id_page_id_categorie_nom_page, $j); $tab_relations[$j][$champ1] = get_champ_line($relation, $champ1); $tab_relations[$j][$champ2] = get_champ_line($relation, $champ2); $tab_relations[$j][$champ3] = get_champ_line($relation, $champ3); } // affichage des categories et ses pages