Jump to content
Killersites Forums

Can Someone Help me about add in database?


Recommended Posts

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;
}




?>



Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...