reza01 Posted June 22, 2009 Report Share Posted June 22, 2009 Hello... We have a program that it works with one row(p1-->group-->sub_group) that it work correctly. now we want change it. it's output: ($ad_sub_groups). we want add another row in this program that it will have(p2-->group-->sub_group2). how we can change it that it works correctly? that it's output be: ($ad_sub_groups). for guide: sub_group take this array: valid_arr[1] = document.newad.sub_group.value; we want add this variable ($ad_sub_groups2) to our database table. and we want insert an id in the dataBase tables for each sub_groups. <?php include("../config.php"); include("../jdf.php"); mysql_connect($db_server, $db_username, $db_password); mysql_select_db($db_name); $authorized = 1; if ($authorized) { $ad_groups = get_groups2(); $ad_sub_groups = get_sub_groups(); // $ad_sub_groups2 = ???????????????? i don now how fille it. $durations = get_durations(); } else header("location:login.php"); function check_authorization() { session_start(); if (isset($_SESSION['uname']) && isset($_SESSION['upass'])) return true; else return false; } function get_groups() { $query = "SELECT * FROM groups"; $result = mysql_query($query); $groups_html = ""; while (($row = mysql_fetch_array($result))) { $name = $row['Name']; $id = $row['ID']; $groups_html .= " $name"; } return $groups_html; } function get_groups2() { $query = "SELECT * FROM groups WHERE ParentID=0"; $result = mysql_query($query); $groups_html = ""; while (($row = mysql_fetch_array($result))) { $name = $row['Name']; $id = $row['ID']; $groups_html .= "$name"; } return $groups_html; } function get_sub_groups() { $query = "SELECT * FROM groups WHERE ParentID=0"; $result = mysql_query($query); if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); $pid = $row['ID']; } $query = "SELECT * FROM groups WHERE ParentID=$pid"; $result = mysql_query($query); $groups_html = ""; while (($row = mysql_fetch_array($result))) { $name = $row['Name']; $id = $row['ID']; $groups_html .= "$name"; } return $groups_html; }?> Quote Link to comment Share on other sites More sharing options...
BeeDev Posted June 23, 2009 Report Share Posted June 23, 2009 Someone should move this topic to PHP Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.