Current location: Hot Scripts Forums » General Web Coding » JavaScript » Can Someone Help me about add in database?

Can Someone Help me about add in database?

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-22-09, 03:16 AM
reza01 reza01 is offline
New Member
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Can Someone Help me about add in database?

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.

Code:
<head>
<style type="text/css">
table{FONT-SIZE: 10pt ; FONT-FAMILY: Tahoma}
input{FONT-SIZE: 10pt ; FONT-FAMILY: Tahoma}
select{FONT-SIZE: 10pt ; FONT-FAMILY: Tahoma}
</style>
</head>

<?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 .= "<a href=\"../main_group.php?id=$id\"><img src=\%22../images/fbrows4R.gif\">&nbsp;$name</a><br>";
      }

    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 .= "<option value=\"$id\">$name</option>";
      }

    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 .= "<option value=\"$id\">$name</option>";
      }

    return $groups_html;
  }

  

 
?>

<script type="text/javascript">

  function get_sub_groups(group)
  {
    document.newad.sub_group.options.length = 0;
    jsel = document.createElement('script');
    jsel.type = "text/javascript";
    jsel.src = "get_sub_groups.php?grp=" + group;
    document.body.appendChild(jsel);
  }


  function validate()
  {
    valid_arr = new Array(3);

    valid_arr[0]  = document.newad.group.value;
    valid_arr[1]  = document.newad.sub_group.value;
    valid_arr[2]  = document.newad.sub_group2.value;
  
 for (i=0; i<3; i++)
      if (valid_arr[i] == "")
        {
        isvalid = false;
        alert("erroe.");
        return false;
        }

    return true;
  }

</script>

				</body>

				<table style="width: 100%">
					<tr>
						<td style="width: 121px">
		&nbsp;</td>
						<td style="width: 1384px">
		&nbsp;</td>
					</tr>
					<tr>
		<span lang="en-us">
						<td style="width: 121px" class="style13"><strong>
						<span lang="en-us">p</span> 
						1</strong></td>
		</span>
						<td style="width: 1384px">
		<span lang="en-us">
						&nbsp;&nbsp;&nbsp;
							<input type="text" style="width: 50px" name="title" size="20"> 
		group:&nbsp;
							<select name="group" onchange="get_sub_groups(this.value)">
								<?php echo $ad_groups; ?>
							</select>&nbsp;sub_group:
							<select name="sub_group">
								<?php echo $ad_sub_groups; ?>
							</select></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		</td>
					</tr>
		<span lang="en-us">
					<tr>
						<td style="width: 121px" class="style14"><strong>
						<span lang="en-us">p</span> 
						2</strong></td>
						<td style="width: 1384px">
		<span lang="en-us">
						&nbsp;</span>&nbsp;&nbsp; <span lang="en-us">
							<input type="text" style="width: 50px" name="title2" size="20"> 
		group:&nbsp;
							<select name="group0" onchange="get_sub_groups(this.value)">
								<?php echo $ad_groups; ?>
							</select>&nbsp;sub_group:
							<select name="sub_group0">
								<?php echo $ad_sub_groups; ?>
							</select></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
							&nbsp;</table>
		</span></html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Multi script PayPal add to cart order form Tito1 JavaScript 5 02-23-09 05:21 AM
ASP Upload and add link to database minority ASP 15 06-20-05 11:36 AM
How to add the last login DATE in MySql database? Edward Han PHP 6 02-13-05 11:43 AM
View, edit, delete and add data to a database bigkid PHP 9 07-22-04 12:51 AM


All times are GMT -5. The time now is 03:17 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.