cleary1981 Posted December 9, 2008 Share Posted December 9, 2008 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 ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted December 9, 2008 Share Posted December 9, 2008 <?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 ?> Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted December 9, 2008 Author Share Posted December 9, 2008 do I not have to make a change to the javascript function too? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted December 9, 2008 Share Posted December 9, 2008 yeah: function checkpanels(proj_id) { //check that all panels belonging to this project have been priced } Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted December 9, 2008 Author Share Posted December 9, 2008 Thanks thats just what I needed 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.