Jump to content

[SOLVED] how do I pass my variable


cleary1981

Recommended Posts

Hi

 

My script below generates my code but I want to include a javascript function "checkpanels" in which I need the value of proj_id for that record. Can anyone help please?

 

<?php

require "config.php";


?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="collapse list/mktree.css" />
<style type="text/css">
.a{
color: green;
}
.b{
color: red;
}
.company{
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
line-height: 1.5;
color:#006666;
}
.name{
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
line-height: 1.5;
color:#006666;
}
body {
background-image: url('modulecost.gif');
background-repeat: no-repeat;
}
.panel{
border: 1px solid white;
}
</style>
<script type="text/javascript" src="collapse list/mktree.js"> </script>
<script type="text/javascript">
function checkpanels() {
//check that all panels belonging to this project have been priced

}
</script>
</head>
<body>



</body>
</html>
<?php

$q1 = mysql_query("SELECT company_name FROM company");
print "<ul class='mktree'>"; //open list1
while($nt=mysql_fetch_array($q1)){
print "<li><span>Company - $nt[company_name]</span></li>";
$comp = $nt[company_name];
//add sublist for projects
print "<ul>"; //open list2
$q2 = mysql_query("SELECT proj_id, project_name FROM project WHERE company_name = '$comp'");
while($r = mysql_fetch_array($q2)){
	print "<li>Project - $r[project_name]<input class='button' type='button' value='Quote' onClick='checkpanels()'></li>";
	$proj_id = $r[proj_id];
	print "<ul class='panel'>";  //open list3
	$q3 = mysql_query("SELECT panel_no, panel_name FROM panel WHERE proj_id = '$proj_id'");
	while($r3 = mysql_fetch_array($q3)){
		//print "<li>Panel - $r3[panel_name]</li>";
		$panel_no = $r3[panel_no];
		$q4 = mysql_query("SELECT object_id FROM object, module WHERE object.module_id = module.module_id AND confirmed = '0' AND panel_no = '$panel_no'");
		$count4 = mysql_num_rows($q4);
		print "<table width=90%>";
					if ($count4 == 0){
						print "<li><tr><td width=50%><span class='name'>Panel - $r3[panel_name]</span></td><td><span class=a>Status: Complete</span></td><td width=10%><a href=\"price.php?panel={$r3['panel_no']}\" target='blank'><img src='price.png' border=0/></a></td><td width=10%><a href=\"PanelView.php?panel={$r3['panel_no']}\" target='blank'><img src='view.gif' border=0/></a></td></tr></li>";
					}
					else {

						print "<li><tr><td width=50%><span class='name'>Panel - $r3[panel_name]</span></td><td><span class=b>Status: Modules Awaiting Approval</span></td><td width=10%><a href=\"PanelView.php?panel={$r3['panel_no']}\" target='blank'><img src='view.gif' border=0/></a></td></tr></li>";
					}
					print "</table>";
	}
	print "</ul>";  //close list3
}

print "</ul>";  //close list2
}
print "</ul>"; //close list1
?>

Link to comment
Share on other sites

<?php

require "config.php";


?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="collapse list/mktree.css" />
<style type="text/css">
.a{
   color: green;
}
.b{
   color: red;
}
.company{
   font-family:Arial, Helvetica, sans-serif;
   font-weight:bold;
   line-height: 1.5;
   color:#006666;
}
.name{
   font-family:Arial, Helvetica, sans-serif;
   font-weight:bold;
   line-height: 1.5;
   color:#006666;
}
body {
   background-image: url('modulecost.gif');
   background-repeat: no-repeat;
}
.panel{
   border: 1px solid white;
}
</style>
<script type="text/javascript" src="collapse list/mktree.js"> </script>
<script type="text/javascript">
function checkpanels() {
//check that all panels belonging to this project have been priced
   
}
</script>
</head>
<body>



</body>
</html>
<?php

$q1 = mysql_query("SELECT company_name FROM company");
print "<ul class='mktree'>"; //open list1
while($nt=mysql_fetch_array($q1)){
   print "<li><span>Company - $nt[company_name]</span></li>";
   $comp = $nt[company_name];
   //add sublist for projects
   print "<ul>"; //open list2
   $q2 = mysql_query("SELECT proj_id, project_name FROM project WHERE company_name = '$comp'");
   while($r = mysql_fetch_array($q2)){
      print "<li>Project - $r[project_name]<input class='button' type='button' value='Quote' onClick=\"checkpanels('$r[proj_id]')\"></li>";
      $proj_id = $r[proj_id];
      print "<ul class='panel'>";  //open list3
      $q3 = mysql_query("SELECT panel_no, panel_name FROM panel WHERE proj_id = '$proj_id'");
      while($r3 = mysql_fetch_array($q3)){
         //print "<li>Panel - $r3[panel_name]</li>";
         $panel_no = $r3[panel_no];
         $q4 = mysql_query("SELECT object_id FROM object, module WHERE object.module_id = module.module_id AND confirmed = '0' AND panel_no = '$panel_no'");
         $count4 = mysql_num_rows($q4);
         print "<table width=90%>";
                  if ($count4 == 0){
                     print "<li><tr><td width=50%><span class='name'>Panel - $r3[panel_name]</span></td><td><span class=a>Status: Complete</span></td><td width=10%><a href=\"price.php?panel={$r3['panel_no']}\" target='blank'><img src='price.png' border=0/></a></td><td width=10%><a href=\"PanelView.php?panel={$r3['panel_no']}\" target='blank'><img src='view.gif' border=0/></a></td></tr></li>";
                  }
                  else {
                     
                     print "<li><tr><td width=50%><span class='name'>Panel - $r3[panel_name]</span></td><td><span class=b>Status: Modules Awaiting Approval</span></td><td width=10%><a href=\"PanelView.php?panel={$r3['panel_no']}\" target='blank'><img src='view.gif' border=0/></a></td></tr></li>";
                  }
                  print "</table>";
      }
      print "</ul>";  //close list3
   }
   
   print "</ul>";  //close list2
}
print "</ul>"; //close list1
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.