• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 310
  • Last Modified:

php html question

Hi
  I have a php page that displays 3 html tables of data. This question isnt related to php really..what i need is when the user clicks on the php url, it brings up the page with the 3 html tables scrolling vertically. So mainly what i'm looking for is how to scroll html tables. the tables should keep on scrolling until the user exists or goes to another link. The 3 tables are not related to each other in any way. I have written the page to display the 3 html data tables with a line break in between the tables. The main reason for this is we have a plasma screen here and we want the html data tables to scroll contineously vertically.
0
hegde123
Asked:
hegde123
  • 10
  • 9
1 Solution
 
lozlozCommented:
0
 
hegde123Author Commented:
looks kewl..have u tried it?...does it work for multiple tables in sequence?..or maybe i should put all 3 tables in 1 body and scroll..i think
0
 
lozlozCommented:
i haven't tried it but the page is a demo so that's all you need to see really :p

yeh putting the 3 tables on one page is the best idea i suppose

cheers,

loz
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hegde123Author Commented:
i've tried this ....two tables work fine..the third object is a graph though...when i put that in  it gives me a error saying "Warning: Cannot modify header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\poi.php:7) in C:\program files\apache group\apache\includes\jpgraph.php on line 6397";


i've done this graph using jpgraph and works fine whne used as a separate link..think the reason being that in jpgraph headers are defined . But because i need to use the headers again here as i have a tables within the body it complains...can you help?

i've attcahed the code:

<?php

include ("jpgraph1.php");
include ("jpgraph_bar.php");


echo "<html>
 <head>
 echo "</head>\n";

echo "<body>";

echo "<SCRIPT LANGUAGE=\"JavaScript\">
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit();
}
function scrollwindow(){
if (document.all)
temp=document.body.scrollTop;
else
temp=document.body.pageYOffset;
if (alt==0)
alt=1;
else
alt=0;
if (alt==0)
curpos1=temp;
else
curpos2=temp;
if (curpos1!=curpos2){
if (document.all)
currentpos=document.body.scrollTop+1;
else
currentpos=document.body.pageYOffset+1;
window.scroll(0,currentpos);
}
else{
currentpos=0;
window.scroll(0,currentpos);
}
}
function startit(){
setInterval(\"scrollwindow()\",50);
}
window.onload=initialize;
</script>";

       $sql = "SELECT MONTH_DAY,TO_CHAR(MONTH_DAY,'MON-DD') MONTH_DAY1,
                               AAP_INB,
                                 OWL_INB,
                                 AAP_FTM,
                                 OWL_FTM,
                                 AAP_NAINT,
                                 OWL_NAINT,
                                 AAP_OTHER,
  OWL_OTHER
       FROM SUB.CARRIER_TOLL_STATS
       ORDER BY MONTH_DAY ASC";

       $ora_sql = OCIParse($oracle_conn,$sql);

       ociexecute($ora_sql) or die("Couldn't execute sql query!");

       while (OCIFetch($ora_sql))
                  {
           $i++;

           $ssales[$i] =           OCIRESULT($ora_sql,'MONTH_DAY1');
           $scustomer[$i] =      OCIRESULT($ora_sql,'AAP_INB');
           $scustomer1[$i] =          OCIRESULT($ora_sql,'OWL_INB');
           $scustomer2[$i] =      OCIRESULT($ora_sql,'AAP_FTM');
           $scustomer3[$i] =          OCIRESULT($ora_sql,'OWL_FTM');
           $scustomer4[$i] =      OCIRESULT($ora_sql,'AAP_NAINT');
           $scustomer5[$i] =          OCIRESULT($ora_sql,'OWL_NAINT');
           $scustomer6[$i] =      OCIRESULT($ora_sql,'AAP_OTHER');
           $scustomer7[$i] =          OCIRESULT($ora_sql,'OWL_OTHER');

       }



// Create the basic graph
$graph = new Graph(1000,500,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(50,127,40,70);

// Adjust the position of the legend box
$graph->legend->Pos(0.01,0.01);

// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.3');

// Get localised version of the month names

$graph->xaxis->SetTickLabels($ssales);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->HideFirstTicklabel();


// Set a nice summer (in Stockholm) image
// $graph->SetBackgroundImage('stship.jpg',BGIMG_COPY);

// Set axis titles and fonts
//$graph->xaxis->title->Set('Year 2003');
//$graph->xaxis->SetTitle('Values for 2003','low');
//$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
//$graph->xaxis->title->SetColor('black');

$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL);
$graph->xaxis->SetColor('black');

$graph->yaxis->SetFont(FF_FONT1,FS_NORMAL);
$graph->yaxis->SetColor('black');

//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');

// Setup graph title
$graph->title->Set('DAILY MINUTES TOLLING (YEAR 2003)');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_FONT2,FS_BOLD,12);

// Create the three var series we will combine
$bplot1 = new BarPlot($scustomer);
$bplot2 = new BarPlot($scustomer1);
$bplot3 = new BarPlot($scustomer2);
$bplot4 = new BarPlot($scustomer3);
$bplot5 = new BarPlot($scustomer4);
$bplot6 = new BarPlot($scustomer5);
$bplot7 = new BarPlot($scustomer6);
$bplot8 = new BarPlot($scustomer7);




// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('orange@0.4');
$bplot2->SetFillColor('brown@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
$bplot4->SetFillColor('black@0.4');
$bplot5->SetFillColor('red@0.4');
$bplot6->SetFillColor('pink@0.4');
$bplot7->SetFillColor('yellow@0.4');
$bplot8->SetFillColor('blue@0.4');


// Setup legends
$bplot1->SetLegend('AAP Inbound');
$bplot2->SetLegend('OPT Inbound');
$bplot3->SetLegend('AAP FTM');
$bplot4->SetLegend('OPT FTM');
$bplot5->SetLegend('AAP Nat/Int');
$bplot6->SetLegend('OPT Nat/Int');
$bplot7->SetLegend('AAP Other');
$bplot8->SetLegend('OPT Other');





// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$bplot4->SetShadow('black@0.4');
$bplot5->SetShadow('black@0.4');
$bplot6->SetShadow('black@0.4');
$bplot7->SetShadow('black@0.4');
$bplot8->SetShadow('black@0.4');

$gbarplot = new AccBarPlot(array($bplot1,$bplot2,$bplot3,$bplot4,$bplot5,$bplot6,$bplot7,$bplot8));
$gbarplot->SetWidth(0.6);
//$gbarplot->value ->Show();
//$graph ->yaxis->scale-> SetGrace(20);
$graph->Add($gbarplot);

$graph->Stroke();

include "oracle_disconnect.inc.php";




echo "</body>
</html>";
?>
0
 
lozlozCommented:
hi,

what page is that? because i don't see two tables there. also what the headers it's trying to output on line 6397? and where's jpgraph.php being included from, since it isn't on this page

cheers,

loz
0
 
hegde123Author Commented:
included tham now...

<?php

include ("jpgraph.php");
include ("jpgraph_bar.php");


echo "<html>
 <head>
 echo "</head>\n";

echo "<body>";

echo "<SCRIPT LANGUAGE=\"JavaScript\">
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit();
}
function scrollwindow(){
if (document.all)
temp=document.body.scrollTop;
else
temp=document.body.pageYOffset;
if (alt==0)
alt=1;
else
alt=0;
if (alt==0)
curpos1=temp;
else
curpos2=temp;
if (curpos1!=curpos2){
if (document.all)
currentpos=document.body.scrollTop+1;
else
currentpos=document.body.pageYOffset+1;
window.scroll(0,currentpos);
}
else{
currentpos=0;
window.scroll(0,currentpos);
}
}
function startit(){
setInterval(\"scrollwindow()\",50);
}
window.onload=initialize;
</script>";


$sql ="
SELECT
l.descr STATIONERY_TYPE, NVL(ROUND(A4.AMT),0) AMT5, NVL(ROUND(A3.AMT),0) AMT1,
NVL(ROUND(A1.AMT),0) AMT2, NVL(ROUND(A2.AMT),0) AMT3,
NVL(ROUND(A3.AMT),0) + NVL(ROUND(A1.AMT),0) + NVL(ROUND(A2.AMT),0) + NVL(ROUND(A4.AMT),0) AMT4,
NVL(ROUND(A5.AMT),0) AMT6,
ROUND((NVL(ROUND(A4.AMT),0)*100)/NVL(ROUND(A5.AMT),0),1) AMT7
  FROM
       sub.ALL_LOSS t,jan.LOOKUP l
       where t.id=l.id
       and l.id=3";



                                                    $ora_sql = OCIParse($oracle_conn,$sql);
                          ociexecute($ora_sql);

{



                       echo "<table align=\"center\" cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"50%\">
                           <tr bgcolor=\"#CE1E6B\">
                           <td align=\"center\"><b class=\"c9\">Name  </b></td>
                           <td align=\"center\"><b class=\"c9\">a1  </b></td>
                           <td align=\"center\"><b class=\"c9\">a2  </b></td>
                           <td align=\"center\"><b class=\"c9\">a3  </b></td>
                           <td align=\"center\"><b class=\"c9\">a4  </b></td>
                           <td align=\"center\"><b class=\"c9\">TOTAL  </b></td>
                          </tr>";


                          while (OCIFetch($ora_sql))
                              {
                               $i++;
                              $sname = OCIRESULT($ora_sql,'STATIONERY_TYPE');
                              $cname = OCIRESULT($ora_sql,'AMT1');
                              $cname1 = OCIRESULT($ora_sql,'AMT2');
                              $cname2 = OCIRESULT($ora_sql,'AMT3');
                              $cname3 = OCIRESULT($ora_sql,'AMT4');
                              $cname4 = OCIRESULT($ora_sql,'AMT5');
                              $cname5 = OCIRESULT($ora_sql,'AMT6');
                              $cname6 = OCIRESULT($ora_sql,'AMT7');


                               echo "<tr bgcolor=\"$bgcolor\">
                                           <td valign=\"top\"><b>$sname</b></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s4&stat=$sname\"><b>$$cname4</b></a></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s1&stat=$sname\"><b>$$cname</b></a></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s2&stat=$sname\"><b>$$cname1</b></a></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s3&stat=$sname\"><b>$$cname2</b></a></td>
                                           <td valign=\"top\" align=\"right\"><b>$$cname3</b></td>
                               </tr>";


                              }

}











echo "</table><br><br>";


$sql ="
SELECT
l.descr STATIONERY_TYPE, NVL(ROUND(A4.AMT),0) AMT5, NVL(ROUND(A3.AMT),0) AMT1,
NVL(ROUND(A1.AMT),0) AMT2, NVL(ROUND(A2.AMT),0) AMT3,
NVL(ROUND(A3.AMT),0) + NVL(ROUND(A1.AMT),0) + NVL(ROUND(A2.AMT),0) + NVL(ROUND(A4.AMT),0) AMT4,
NVL(ROUND(A5.AMT),0) AMT6,
ROUND((NVL(ROUND(A4.AMT),0)*100)/NVL(ROUND(A5.AMT),0),1) AMT7
  FROM
       sub.ALL_LOSS t,jan.LOOKUP l
       where t.id=l.id
       and l.id=2";



                                                    $ora_sql = OCIParse($oracle_conn,$sql);
                          ociexecute($ora_sql);

{



                       echo "<table align=\"center\" cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"50%\">
                           <tr bgcolor=\"#CE1E6B\">
                           <td align=\"center\"><b class=\"c9\">Name  </b></td>
                           <td align=\"center\"><b class=\"c9\">a1  </b></td>
                           <td align=\"center\"><b class=\"c9\">a2  </b></td>
                           <td align=\"center\"><b class=\"c9\">a3  </b></td>
                           <td align=\"center\"><b class=\"c9\">a4  </b></td>
                           <td align=\"center\"><b class=\"c9\">TOTAL  </b></td>
                          </tr>";


                          while (OCIFetch($ora_sql))
                              {
                               $i++;
                              $sname = OCIRESULT($ora_sql,'STATIONERY_TYPE');
                              $cname = OCIRESULT($ora_sql,'AMT1');
                              $cname1 = OCIRESULT($ora_sql,'AMT2');
                              $cname2 = OCIRESULT($ora_sql,'AMT3');
                              $cname3 = OCIRESULT($ora_sql,'AMT4');
                              $cname4 = OCIRESULT($ora_sql,'AMT5');
                              $cname5 = OCIRESULT($ora_sql,'AMT6');
                              $cname6 = OCIRESULT($ora_sql,'AMT7');


                               echo "<tr bgcolor=\"$bgcolor\">
                                           <td valign=\"top\"><b>$sname</b></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s4&stat=$sname\"><b>$$cname4</b></a></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s1&stat=$sname\"><b>$$cname</b></a></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s2&stat=$sname\"><b>$$cname1</b></a></td>
                                           <td valign=\"top\" align=\"right\"><a href=\"/tamd.php?loss4=Y&s1=$s3&stat=$sname\"><b>$$cname2</b></a></td>
                                           <td valign=\"top\" align=\"right\"><b>$$cname3</b></td>
                               </tr>";


                              }

}











echo "</table><br><br>";


      $sql = "SELECT MONTH_DAY,TO_CHAR(MONTH_DAY,'MON-DD') MONTH_DAY1,
                          AAP_INB,
                            OWL_INB,
                            AAP_FTM,
                            OWL_FTM,
                            AAP_NAINT,
                            OWL_NAINT,
                            AAP_OTHER,
  OWL_OTHER
      FROM SUB.CARRIER_TOLL_STATS
      ORDER BY MONTH_DAY ASC";

      $ora_sql = OCIParse($oracle_conn,$sql);

      ociexecute($ora_sql) or die("Couldn't execute sql query!");

      while (OCIFetch($ora_sql))
                {
          $i++;

          $ssales[$i] =           OCIRESULT($ora_sql,'MONTH_DAY1');
          $scustomer[$i] =      OCIRESULT($ora_sql,'AAP_INB');
          $scustomer1[$i] =          OCIRESULT($ora_sql,'OWL_INB');
          $scustomer2[$i] =      OCIRESULT($ora_sql,'AAP_FTM');
          $scustomer3[$i] =          OCIRESULT($ora_sql,'OWL_FTM');
          $scustomer4[$i] =      OCIRESULT($ora_sql,'AAP_NAINT');
          $scustomer5[$i] =          OCIRESULT($ora_sql,'OWL_NAINT');
          $scustomer6[$i] =      OCIRESULT($ora_sql,'AAP_OTHER');
          $scustomer7[$i] =          OCIRESULT($ora_sql,'OWL_OTHER');

      }



// Create the basic graph
$graph = new Graph(1000,500,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(50,127,40,70);

// Adjust the position of the legend box
$graph->legend->Pos(0.01,0.01);

// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.3');

// Get localised version of the month names

$graph->xaxis->SetTickLabels($ssales);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->HideFirstTicklabel();


// Set a nice summer (in Stockholm) image
// $graph->SetBackgroundImage('stship.jpg',BGIMG_COPY);

// Set axis titles and fonts
//$graph->xaxis->title->Set('Year 2003');
//$graph->xaxis->SetTitle('Values for 2003','low');
//$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
//$graph->xaxis->title->SetColor('black');

$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL);
$graph->xaxis->SetColor('black');

$graph->yaxis->SetFont(FF_FONT1,FS_NORMAL);
$graph->yaxis->SetColor('black');

//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('white@0.5');

// Setup graph title
$graph->title->Set('DAILY MINUTES TOLLING (YEAR 2003)');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_FONT2,FS_BOLD,12);

// Create the three var series we will combine
$bplot1 = new BarPlot($scustomer);
$bplot2 = new BarPlot($scustomer1);
$bplot3 = new BarPlot($scustomer2);
$bplot4 = new BarPlot($scustomer3);
$bplot5 = new BarPlot($scustomer4);
$bplot6 = new BarPlot($scustomer5);
$bplot7 = new BarPlot($scustomer6);
$bplot8 = new BarPlot($scustomer7);




// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('orange@0.4');
$bplot2->SetFillColor('brown@0.4');
$bplot3->SetFillColor('darkgreen@0.4');
$bplot4->SetFillColor('black@0.4');
$bplot5->SetFillColor('red@0.4');
$bplot6->SetFillColor('pink@0.4');
$bplot7->SetFillColor('yellow@0.4');
$bplot8->SetFillColor('blue@0.4');


// Setup legends
$bplot1->SetLegend('AAP Inbound');
$bplot2->SetLegend('OPT Inbound');
$bplot3->SetLegend('AAP FTM');
$bplot4->SetLegend('OPT FTM');
$bplot5->SetLegend('AAP Nat/Int');
$bplot6->SetLegend('OPT Nat/Int');
$bplot7->SetLegend('AAP Other');
$bplot8->SetLegend('OPT Other');





// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('black@0.4');
$bplot2->SetShadow('black@0.4');
$bplot3->SetShadow('black@0.4');
$bplot4->SetShadow('black@0.4');
$bplot5->SetShadow('black@0.4');
$bplot6->SetShadow('black@0.4');
$bplot7->SetShadow('black@0.4');
$bplot8->SetShadow('black@0.4');

$gbarplot = new AccBarPlot(array($bplot1,$bplot2,$bplot3,$bplot4,$bplot5,$bplot6,$bplot7,$bplot8));
$gbarplot->SetWidth(0.6);
//$gbarplot->value ->Show();
//$graph ->yaxis->scale-> SetGrace(20);
$graph->Add($gbarplot);

$graph->Stroke();

include "oracle_disconnect.inc.php";




echo "</body>
</html>";
?>
0
 
hegde123Author Commented:
i think the problam lies i sending 2 header types which i dont think jpgraph allows..because i'm sendingplain text first for the 2 tables and then within jpgraph.php it defines image header types..it falls over..how do i get around that?
0
 
lozlozCommented:
what's line 6397 of jpgraph.php and are you sure there's no whitespace before <?php at the top of the page? since you're including the file as the first thing you do, there's no reason for the headers to be interefered with

cheers,

loz
0
 
hegde123Author Commented:
this is line 6397

    function Headers() {
      if ($this->expired) {
          header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
          header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
          header("Cache-Control: no-cache, must-revalidate");
          header("Pragma: no-cache");
      }
       header("Content-type: image/$this->img_format");
    }
0
 
lozlozCommented:
aren't you meant to call the script by doing <img src="jpgraph.php"> in that case?

loz
0
 
hegde123Author Commented:
yep..no space before <?php

Is it because headers are defined in jpgraph and if you notice i have headers defined again later in the 6 th line of my file?
0
 
hegde123Author Commented:
no..cause jpgraph.php is an include file to generate graphs in php
0
 
lozlozCommented:
those are different types of headers. the jpgraph errors are to do with HTTP headers - you can't define these after any HTML content has been output (i.e. blank spaces, echo/print functions). the head of your document is HTML and so not relevant

is this jpgraph script usually meant to be used on its own? because if it's sending out those headers it's saying "read me as an image file". thats what leads me to believe you should be using it as part of an img tag. however i see you have a class called Graph, so i assume that is being defined in jpgraph.php?

loz
0
 
hegde123Author Commented:
thats right...it is defined in jpgraph.php..i undertsand what you're saying now..maybe what i should do a than create the graph as a png image and then just call it as a img src and then use my normal headers after that
0
 
lozlozCommented:
you mean create an image using a graphics package? if it's meant to be dynamic, there won't be much point in doing that. if you move all the code that defines how your graph should be presented by changing properties and calling methods of the class into the include file then use my <img src="jpgraph.php"> way of calling it, it shouldwork properly

loz
0
 
hegde123Author Commented:
the graph is updated just once a day actually ..doesnt have to be dynamic..the select statetment takes it froma  temporary table...so if i create the image that time once a day and then use img src to the image it should work fine..right..?
0
 
lozlozCommented:
well you don't really want to be creating a new image every day, that's avoiding the problem rather than solving it

can you put this jpgraph file up on a server with a txt extension somewhere so i can see how it works.. pastin 6000 lines here isn't really desirable

cheers,

loz
0
 
hegde123Author Commented:
can you reference a php file in a img src though?
0
 
lozlozCommented:
yes using <img src="file.php"> is used for dynamically writing images

loz
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now