Can SSI include handle variables?

Hi I have the following code

<tbody id="Summary">
<tr><td>237</td>
<td>165</td>
<td>undefined</td>
<td>41</td>
<td>undefined</td>
<td>33</td>
<td>undefined</td>
<td>0</td>
<td>5.64</td>
<td>undefined</td>
</tr>
</tbody>

And i Want to use those numbers for example 237 in this document

<div id="overview">

<table class="tableOverview">

<tr>
<td>
Testcases
</td>

<td>
testcases OK
</td>
<td>
testcases (Was)
</td>
<td>
testcases OK(Was)
</td>
</tr>


<tr>
<td>
[B]237[/B]
</td>
<td id="testcasesoverview">

<div class="bar_high" style="width: [B]((165/237)*100)[/B]%;" TITLE=[B]((165/237)*100)[/B]"%"> 
[B]((165/237)*100)[/B]"%"</div>

</td>



</tr>

</table>
</div>

The reason for this is that currently i am generating a lot of diffrent tbodys contaning diffrent numbers so therefore i can’t just copy and paste from the body, instead i want it to be done automaticly.

In other words im generating alot of summarys to have in my “overview”.
And this overview is also to appear in as many html sites as there are overview. So my thought were to have the Overview div as a SSI and stores variables to read from many summary’s.

So my queastion is, is it possible to have SSI’s(Server side include’s) where you can have variables in them?
How is this done?

How can I set a path in the SSI to where the folder containing all the summarys are?

I know that this thread might be posted in wrong place, but admin feel free to move to apropiate place :slight_smile:

I don’t know how you would do it with SSI (or if it’s even possible), but you could something like the following PHP:


<?php
if (!isset($_GET['runId']) || !is_numeric($_GET['runId']) || !file_exists($file = 'testRuns\	estRun'.$_GET['runId'].'\\Sumary.html'))
  die ('Invalid (or no) runId supplied');
$file = file_get_contents($file);
preg_match('~<tbody id="Summary">\\s+<tr><td>(\\d+)</td>\\s+<td>(\\d+)</td>~', $file, $pres);
$percentage = ($pres[1]/$pres[2]) * 100;
?>
<div id="overview">

<table class="tableOverview">

<tr>
<td>
Testcases
</td>

<td>
testcases OK
</td>
<td>
testcases (Was)
</td>
<td>
testcases OK(Was)
</td>
</tr>


<tr>
<td>
<?php echo $pres[1]; ?>
</td>
<td id="testcasesoverview">

<div class="bar_high" style="width: <?php echo round($percentage, 0); ?>%;" title="<?php $percentage; ?>%"> 
<?php echo $percentage; ?>%
</div>

</td>



</tr>

</table>
</div>

If you call this file overview.php, you can get the results for run 47 by including / calling overview.php?runId=47

:slight_smile:

Right so I include the file

<!--#include file="testruns\\include\\overview.php?runId=47 -->

You don’t think I can call the overview.php?runId=47 Using this method?

Say that I want to include this overview.php in an ordinary html page?

What are the exact syntax for calling it from example index.html?

Like this?

"<td colspan="5"><?php include('overview.php?runId=47');?></td>

No, I think that would work, I just don’t think that toying around with variables and calculations in SSI would work :slight_smile:

Wow thanks.

So say that I want a ceartain number, etc 237 on linenumber 2 on the following line

<tr><td>237</td>

in html file located in example folder “testRuns\ estRun45\Sumary.html”. How do I get it using php? im only interested in the number, not the html code :slight_smile:

Say also that you have other testruns contanined in other folders, for example

“testRuns\ estRun46\Sumary.html” and “testRuns\ estRun47\Sumary.html” etc. and also each testrun folder are containing an index.shtml

for example “testRuns\ estRun46\index.shtml” and “testRuns\ estRun47\index.shtml”

I want the overview.shtml to read the numbers from the summary.html file as the index.shtml is contained in.

So for example

If “testRuns/testRun46/index.shtml” does the following

"<!--#include file="testruns\\include\\overview.shtml" --> "

I want the “testruns\include\overview.shtml” to use the “testRuns/testRun46/summary.html” as a source file.

Im new at php as you might notice, but I hope somebody out there has a clue of what im talking about and can get me in the right direction :slight_smile:

Or you could global a variable and include a common file then use that data to refer to parts of your code dynamically.

No, it’s in the write place, and yes, you can with PHP

<?
require "get_summary.php?folder=summary_1";
?>

With PHP you can also use includes like this…

<?
if(requestFolder=="summary_1") require "summary_1.html";
?>