A have a simple task here. Its easy to complete but there`s some snares. Please give me some advice how to create it and what to drew attention. Thanks to everyone ! ?
Here is the tast with the picture inside [url]http://www.mediafire.com/?7xj656uh9vdb31s[/url]
@NoEffinWayMar 02.2012 — #Are you pulling this info from a database? And what is the PHP you are using now? (Please edit out and sensitive info). And Possibly, but I need more info before I can say yes or no. @_@
@spufiMar 02.2012 — #If this is for school, then you need to find a solution based on what technologies you are suppose to know for that class. If you aren't suppose to know jQuery, then even if you get it working you won't get it right since you found an answer that doesn't line up with what it should be.
@NoEffinWayMar 02.2012 — #If this is for school, then you need to find a solution based on what technologies you are suppose to know for that class. If you aren't suppose to know jQuery, then even if you get it working you won't get it right since you found an answer that doesn't line up with what it should be.[/QUOTE]
Good point, I haven't been in school for like 6 years so I didn't think about it. ?
$id=(int)$_POST['edit_id']; if($id>0) { mysql_query('UPDATE sub SET name_sub="'.$name.'",color="'.$color.'" WHERE id_sub="'.$id.'" '); } else { mysql_query('INSERT INTO sub (name_sub,color) VALUES ("'.$name.'","'.$color.'")'); }
}
$rs=mysql_query('SELECT * FROM Main'); while($row=mysql_fetch_assoc($rs)) { echo $row['name'].'<br />'; }
if($_GET['mode']=="edit" && $_GET['id_sub']>0) { $id=(int)$_GET['id_sub']; $rs=mysql_query('SELECT * FROM sub WHERE id_sub='.$id); $ed_info=mysql_fetch_assoc($rs); }
@NoEffinWayMar 02.2012 — #Do do the trees properly, without Javascript/jQuery, you are going to want to use the GET method to get the sub cats. For example: [code=php]if(isset($_GET['root'])){ $rootid = $_GET['root']; $tree = mysql_query("SELECT * FROM $db.$table WHERE sub_id = '$rootid'"); $sub = ''; while($fulltree = mysql_fetch_array($tree)){ $sub .= '<a href="?root='.$rootid.'&sub='.$fulltree['id'].'">'.$fulltree['name'].'</a>'; }}[/code]
Try seeing if you can modify that to fit your needs. I would write it for you but then you will never learn. XD
@spufiMar 02.2012 — #If I understand this correctly... <i> </i>Table root id, name, color
Table submenu id, rootid, name, color.
1. Select for each root item. 2. Loop through the resulting array. a. Display each root item. b. Select from submenu where root.id = rootid. c. Loop through resulting array i. Display each submenu item.
Theres no problem to write the parent ID in the DB when create new item.<br/> The question is how to draw the tree.<br/> Should I use a recursion?<br/> I must start the recursion and calling it every time when there is some deeper Item on the tree.<br/> I cant figure it out how it should be made ?