slapdashgrim Posted August 26, 2008 Share Posted August 26, 2008 hello, I am working on a CMS I need to make it so the user can choose where a new link they are creating is placed in a list. they should be able to choose if it goes before or after another link. this is what i tried at first. right now each link is designated a value and when they choose to add a link after or before another link it either adds or subtracts a number from the current value so when it is sorted by mySQL it will be before or after. but it is to simple and im sure there is a better way out there. print'<fieldset> <legend>Add new Link</legend> <form method="post" action="menu/add.php"> Display text: <input type="text" value="Click me!" name="value"> link url: <input type="text" value="path/to/file.html" name="url"> Viewable by: <select name="permission"> <option value="0">Anyone</option> <option value="1">Registered</option> <option value="2">Admin</option> </select> Place link: <select name="beforeafter"> <option value="0">Before</option> <option value="1">After</option> </select> <select name="orderlink">'; $query = 'SELECT * FROM menu ORDER BY `order` ASC'; if ($r = mysql_query ($query)) { while ($row = mysql_fetch_array ($r)) { print '<option value="'.$row['order'].'">'.$row['value'].'</option>'; }//end while }//end query if print '</select> Target: <select name="target"> <option value="_self">_self</option> <option value="_blank">_blank</option> </select> <input type="submit" value="Add link" name="submitaddmenu"> </form> </fieldset>'; }//submit end ?> Link to comment https://forums.phpfreaks.com/topic/121473-need-help-with-a-cms-navigation-script/ Share on other sites More sharing options...
JREAM Posted August 26, 2008 Share Posted August 26, 2008 Can you explain what you are trying to implement or fix? Link to comment https://forums.phpfreaks.com/topic/121473-need-help-with-a-cms-navigation-script/#findComment-626435 Share on other sites More sharing options...
slapdashgrim Posted August 26, 2008 Author Share Posted August 26, 2008 ya sorry my post i wrote was screwed up becuase of the code tags. i re wrote a summery of what i had before. and the code should say <?php if (isset($submitaddmenu)){ $value = $_POST['value']; $url = $_POST['url']; $permission = $_POST['permission']; $order = $_POST['order']; $target = $_POST['target']; if ($_POST['beforeafter']==0){ $order = $_POST['orderlink'] - rand(1,9); }else{ $order = $_POST['orderlink'] + rand(1,9); } //display menu items $query = "INSERT INTO `menu` (`id`, `value`, `url`, `permission`, `order`, `target`) VALUES ('', '$value', '$url', '$permission', '$order', '$target')"; mysql_query ($query); }else{//not submited print'<fieldset> <legend>Add new Link</legend> <form method="post" action="menu/add.php"> Display text: <input type="text" value="Click me!" name="value"> link url: <input type="text" value="path/to/file.html" name="url"> Viewable by: <select name="permission"> <option value="0">Anyone</option> <option value="1">Registered</option> <option value="2">Admin</option> </select> Place link: <select name="beforeafter"> <option value="0">Before</option> <option value="1">After</option> </select> <select name="orderlink">'; $query = 'SELECT * FROM menu ORDER BY `order` ASC'; if ($r = mysql_query ($query)) { while ($row = mysql_fetch_array ($r)) { print '<option value="'.$row['order'].'">'.$row['value'].'</option>'; }//end while }//end query if print '</select> Target: <select name="target"> <option value="_self">_self</option> <option value="_blank">_blank</option> </select> <input type="submit" value="Add link" name="submitaddmenu"> </form> </fieldset>'; } ?> Link to comment https://forums.phpfreaks.com/topic/121473-need-help-with-a-cms-navigation-script/#findComment-626437 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 Okay, I get a what you want. You're basically making a sort of tree structure, and you need to be able to move "nodes" (links) around. You need to store, for each link, the one before and after it, and the parent node if you're making it multi-level. Link to comment https://forums.phpfreaks.com/topic/121473-need-help-with-a-cms-navigation-script/#findComment-626438 Share on other sites More sharing options...
slapdashgrim Posted August 26, 2008 Author Share Posted August 26, 2008 ya sorta what is the best way to go about this does anyone know? Link to comment https://forums.phpfreaks.com/topic/121473-need-help-with-a-cms-navigation-script/#findComment-626441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.