Have dynamic content span across pages in php - php

I have the following code that dynamically loads items in an invoice. I am looking for a way to adds excess items to a new page, and so on. I would like to limit the # of items on a page to a set amount, say 15 items. Is there a way to do this in php? The code below is within a document that uses dompdf to appear in pages form
foreach ( $invoice['InvoiceDetail'] as $key=>$item){
$html .= '<tr style="border-bottom: 1px solid #ccc; line-height: 15px;">';
$itemNo = isset($item['product_id']) ? $item['product_id'] : '';
$itemName = isset($item['productName']) ? $item['productName']: '';
$price = isset($item['price']) ? invoiceNumFormat($item['price']): '';
$quantity = isset($item['quantity']) ? $item['quantity'] : '';
$total = invoiceNumFormat( $item['price']*$item['quantity']);
$html .= '<td style="text-align: left"><h5>'.$itemNo.'</h5></td>';
$html .= '<td style="text-align: left">'.$itemName.'</td>';
$html .= '<td style="text-align: left">'.$price.'</td>';
$html .= '<td style="text-align: left" width="10px">'.$quantity.'</td>';
$html .= '<td style="text-align: right">'.$total.'</td>';
$html .= '</tr>';
}

For your particular situation you could just indicate to dompdf to break the page, something along the lines of:
$itemCount = 0;
foreach ( $invoice['InvoiceDetail'] as $key=>$item){
$itemCount++;
$html .= '<tr style="border-bottom: 1px solid #ccc; line-height: 15px;">';
/* snip */
if ($itemCount % 20 == 0) {
$html .= '<tr><td><div style="page-break-before: always;"></div></td></tr>';
}
$html .= '<td style="text-align: left"><h5>'.$itemNo.'</h5></td>';
$html .= '<td style="text-align: left">'.$itemName.'</td>';
$html .= '<td style="text-align: left">'.$price.'</td>';
$html .= '<td style="text-align: left" width="10px">'.$quantity.'</td>';
$html .= '<td style="text-align: right">'.$total.'</td>';
$html .= '</tr>';
}
Dompdf does not yet recognize page break styling on table rows/cells. Otherwise it would make more sense to place the styling there.

Does this help?
<?php
$per_page = 20;
if ( $pagenum < 2 || !$pagenum ) {
$limit_start = 0;
} else {
$limit_start = (( $pagenum -1 ) * $per_page);
}
$sql = "select foo, bar, baz from table where $conditions limit $limit_start, $per_page";
$db->query( $sql ); //or whatever your method is
// while statement to get data into $invoice array
//foreach statement to display it
//pagination links

Related

PHP creating hidden hyperlinks on pages

I have a custom component being used on a Joomla 3.9 site.
The below code creates hyperlinks with proper anchors ( for 2 pages ) from a database and works OK except that it's also creating irrelevant hidden links.
You can only see the href links if you view the source of the page.
i.e.
What can I try here to make sure the code doesn't create these hidden links?
else:
JFactory::getDocument()->addStyleDeclaration('#media (max-width:540px){table.all-regions tr td{width: 100% !important;display: inline-block !important;text-align: center !important;}}');
$regionsList = '';
$regionsList .= '<table class="all-regions">';
$regions = $this->get('regions');
for($i = 0;$i <= count($regions); $i+=3):
$regionsList .= '<tr>';
$regionsList .= '<td style="width: 1%;padding: 9px; line-height: 24px;">'.$regions[$i]->region_name.'</td>';
$regionsList .= '<td style="width: 1%;padding: 9px; line-height: 24px;">'.$regions[$i+1]->region_name.'</td>';
$regionsList .= '<td style="width: 1%;padding: 9px; line-height: 24px;">'.$regions[$i+2]->region_name.'</td>';
$regionsList .= '</tr>';
endfor;
$regionsList .= '</table>';
$text = JString::str_ireplace('{%regions_list%}', $regionsList, $this->article->text);
$this->setBreadcrumbs(
array(
'country'
)
);
endif;
echo $text;
Details that may or may not help:
One page shows 3 hidden links and the other 2 hidden links. The hidden links point to the same page I'm currently on. The page with 3 hidden links is showing 3 even columns of links while the one with 2 hidden links has one row with 5 links and the other 2 rows with 4 links
There are better ways to do this whole thing, but without rewriting the code, you need to see if those elements are set and aren't empty or else you will get empty anchors:
if(!empty($regions[$i]->region_name)) {
$regionsList .= '<td style="width: 1%;padding: 9px; line-height: 24px;">'.$regions[$i]->region_name.'</td>';
}
if(!empty($regions[$i+1]->region_name)) {
$regionsList .= '<td style="width: 1%;padding: 9px; line-height: 24px;">'.$regions[$i+1]->region_name.'</td>';
}
if(!empty($regions[$i+2]->region_name)) {
$regionsList .= '<td style="width: 1%;padding: 9px; line-height: 24px;">'.$regions[$i+2]->region_name.'</td>';
}
As #AbraCadaver hinted, your code could use some DRYing out and some polishing up.
Differing from Abra's suggested resolution, it is important to consistently output the same number of cells in each row of the html table for valid html markup. If there is no region data at a particular index, just print an empty cell.
Rather than repeating the same cell markup text and inserting manually incremented indexes, use a cell template string and a for() loop.
I also recommend moving all your styling to the css declaration and referencing .all-regions td.
Suggested rewrite (not tested)
$html = '<table class="all-regions">';
$cellTemplate = '<td style="width: 1%; padding: 9px; line-height: 24px;">%s</td>';
$regions = $this->get('regions');
foreach (array_chunk($regions, 3) as $chunk) {
$html .= '<tr>';
for ($i = 0; $i < 3; ++$i) {
if (!isset($chunk[$i])) {
$html .= '<td></td>';
} else {
$html .= sprintf(
$cellTemplate,
JUri::root(),
$country
strtolower(str_replace(' ', '-', $chunk[$i]->region_name)),
$chunk[$i]->region_name
);
}
}
$html .= '</tr>';
}
$html .= '</table>';
$text = JString::str_ireplace('{%regions_list%}', $html, $this->article->text);
$this->setBreadcrumbs(['country']);

Fetch more data inside foreach

So I need to fetch data such as section, item names and subtotal of every section from my database and get the grand total of all the items.
I stumble upon the code below and modify it to my requirements.
The code works perfectly but I need to display more data like Item description, Qty, Price, status and so on.
The code below works and have no problem whatsoever but i need more data (description, qty, price and so on) to display in my table but I can't figure out how to do it.
The data I need to display is also in the same row where projectscostbreakdown_areaname, projectscostbreakdown_itemname and projectscostbreakdown_totalcost are.
<?php
$projectsid = $_GET['projectrfpid'];
$itemdeleted = 1;
$itemfirstothers = 'OTHERS';
$query = $conn->prepare('SELECT projectscostbreakdown_id,
projectscostbreakdown_projectid,
projectscostbreakdown_areaname,
projectscostbreakdown_itemname,
projectscostbreakdown_itemdescription,
projectscostbreakdown_qty,
projectscostbreakdown_costpiece,
projectscostbreakdown_budgeted,
projectscostbreakdown_totalcost,
projectscostbreakdown_note,
projectscostbreakdown_addedby,
projectscostbreakdown_addeddate,
projectscostbreakdown_deleted,
projectscostbreakdown_lastedit,
projectscostbreakdown_lasteditby
FROM projectscostbreakdown WHERE projectscostbreakdown_projectid=:projectsid && projectscostbreakdown_deleted=:itemdeleted ORDER BY projectscostbreakdown_areaname=:itemfirstothers, projectscostbreakdown_areaname ASC, projectscostbreakdown_id DESC');
$query->bindParam(':projectsid', $projectsid, PDO::PARAM_INT);
$query->bindParam(':itemdeleted', $itemdeleted, PDO::PARAM_INT);
$query->bindParam(':itemfirstothers', $itemfirstothers, PDO::PARAM_INT);
$query->execute();
$data = array();
$data2 = array();
$numbering = 0; //for item count
$count = 1; //counter use for background color
while ( $row2 = $query->fetch() ) {
if ( empty($data[ $row2['projectscostbreakdown_areaname'] ]) ) {
$data[ $row2['projectscostbreakdown_areaname'] ]= array();
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
if ( empty( $data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ] ) ) {
$data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ] = array();
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
$data[ $row2['projectscostbreakdown_areaname'] ][ $row2['projectscostbreakdown_itemname'] ][] = $row2['projectscostbreakdown_totalcost'];
$data2[ $row2['projectscostbreakdown_itemdescription'] ][ $row2['projectscostbreakdown_qty'] ]= array();
}
print '<table width="100%" border="0"><tbody>';
$totalSum = 0;
foreach ( $data as $area => $item ) {
print '<tr style="background-color: white;"><td colspan="7" style="text-align: left;"><br /><br /><b><u>'. $area .'</u></b></td></tr>';
print '<tr style="background-color: #AAAAAA; text-align: center;">
<td width="20%""><b>Item name</b></td>
<td width="30%"><b>Description</b></td>
<td width="5%"><b>Qty.</b></td>
<td width="10%"><b>Cost/Piece</b></td>
<td width="10%"><b>Subtotal</b></td>
<td width="10%"><b>Budget</b></td>
<td width="15%"><b>Note /<br / >Entered by</b></td>
</tr>';
$totalArea = 0;
foreach ( $item as $item => $totalcost ) {
//while ( $data = $query->fetch() ) {
$numbering++;
$count++;
$class = ($count%2 == 0)? 'white': '#CCCCCC';
$sum = array_sum( $totalcost );
print '<tr style="background-color: '.$class.'">';
print '<td style="vertical-align: top; text-align: left;">'. $numbering .'. '. $item . '</td>';
print '<td style="vertical-align: top; text-align: left;">';
print_r($data2);
print '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;">'. number_format($sum, 2,'.', ',') . '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: left;"></td>';
print '</tr>';
$totalArea += $sum;
}
print '<tr style="background-color: lightgray; text-align: right;" ><td colspan="6">Section Total: </td><td>'. number_format($totalArea, 2,'.', ',') . '</td></tr>';
$totalSum += $totalArea;
}
print '<tr style="background-color: lightblue; text-align: right;" ><td colspan="6"><b>Grand Total: </b></td><td><b>'. number_format($totalSum, 2,'.', ',') . '</b></td></tr>';
echo '</tbody>
</table>';
?>
UPDATE
The output looks like this right now.
I need to include Description and Qty in the output but cant figure how to be done.
Section1
Item Name-----Description-----Qty-----Subtotal
item 1---------------------------------------------1000
item 2---------------------------------------------2000
----------------------------------Section Total: 3000
Section2
Item Name-----Description-----Qty-----Subtotal
item 3---------------------------------------------1000
----------------------------------Section Total: 1000
------------------------------------Grand Total: 4000
Complete code (more structured, fixed bugs):
<?php
$projectsid = $_GET['projectrfpid'];
$itemdeleted = 1;
$itemfirstothers = 'OTHERS';
$query = $conn->prepare('SELECT projectscostbreakdown_id,
projectscostbreakdown_projectid,
projectscostbreakdown_areaname,
projectscostbreakdown_itemname,
projectscostbreakdown_itemdescription,
projectscostbreakdown_qty,
projectscostbreakdown_costpiece,
projectscostbreakdown_budgeted,
projectscostbreakdown_totalcost,
projectscostbreakdown_note,
projectscostbreakdown_addedby,
projectscostbreakdown_addeddate,
projectscostbreakdown_deleted,
projectscostbreakdown_lastedit,
projectscostbreakdown_lasteditby
FROM projectscostbreakdown WHERE projectscostbreakdown_projectid=:projectsid && projectscostbreakdown_deleted=:itemdeleted ORDER BY projectscostbreakdown_areaname=:itemfirstothers, projectscostbreakdown_areaname ASC, projectscostbreakdown_id DESC');
$query->bindParam(':projectsid', $projectsid, PDO::PARAM_INT);
$query->bindParam(':itemdeleted', $itemdeleted, PDO::PARAM_INT);
$query->bindParam(':itemfirstothers', $itemfirstothers, PDO::PARAM_INT);
$query->execute();
$data = array();
$data2 = array();
$numbering = 0; //for item count
$count = 1; //counter use for background color
$itemData = $query->fetchAll();
$query->execute();
while ($row2 = $query->fetch()) {
if (empty($data[$row2['projectscostbreakdown_areaname']]) ) {
$data[$row2['projectscostbreakdown_areaname']]= array();
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']] = array();
}
if (empty($data[$row2['projectscostbreakdown_areaname']][$row2['projectscostbreakdown_itemname']])) {
$data[$row2['projectscostbreakdown_areaname']][ $row2['projectscostbreakdown_itemname']] = array();
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']]= array();
}
$data[$row2['projectscostbreakdown_areaname']][$row2['projectscostbreakdown_itemname']][] = $row2['projectscostbreakdown_totalcost'];
$data2[$row2['projectscostbreakdown_itemdescription']][$row2['projectscostbreakdown_qty']] = array();
}
print '<table width="100%" border="0"><tbody>';
$totalSum = 0;
foreach ( $data as $area => $item ) {
print '<tr style="background-color: white;"><td colspan="7" style="text-align: left;"><br /><br /><b><u>'. $area .'</u></b></td></tr>';
print '<tr style="background-color: #AAAAAA; text-align: center;">
<td width="20%""><b>Item name</b></td>
<td width="30%"><b>Description</b></td>
<td width="5%"><b>Qty.</b></td>
<td width="10%"><b>Cost/Piece</b></td>
<td width="10%"><b>Subtotal</b></td>
<td width="10%"><b>Budget</b></td>
<td width="15%"><b>Note /<br / >Entered by</b></td>
</tr>';
$totalArea = 0;
foreach ( $item as $item => $totalcost ) {
$count++;
echo $numbering.' ';
$class = ($count % 2 == 0) ? 'white' : '#CCCCCC';
$sum = array_sum($totalcost);
print '<tr style="background-color: '.$class.'">';
print '<td style="vertical-align: top; text-align: left;">'. $numbering .'. '. $item . '</td>';
print '<td style="vertical-align: top; text-align: left;">'.$itemData[$numbering]['projectscostbreakdown_itemdescription'].'</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: right;">'. number_format($sum, 2,'.', ',') . '</td>';
print '<td style="vertical-align: top; text-align: right;"></td>';
print '<td style="vertical-align: top; text-align: left;"></td>';
print '</tr>';
$numbering++;
$totalArea += $sum;
}
print '<tr style="background-color: lightgray; text-align: right;" ><td colspan="6">Section Total: </td><td>'. number_format($totalArea, 2,'.', ',') . '</td></tr>';
$totalSum += $totalArea;
}
print '<tr style="background-color: lightblue; text-align: right;" ><td colspan="6"><b>Grand Total: </b></td><td><b>'. number_format($totalSum, 2,'.', ',') . '</b></td></tr>';
echo '</tbody></table>';
?>
Basically, what I did (which might not be the best option but I couldn't think anything better) was I used $itemData = $query->fetchAll(); after executing $query->execute();. Now if we leave everything the same, table will be empty since pointer is at the last element. Therefore, we must execute again the same query by writing an additional $query->execute(); right after $itemData = $query->fetchAll();.
Now we have basically the same thing as in your example but with one additional variable $itemData with all information about items. To bring out description, quantity, etc. now we can use $itemData[$numbering]['projectscostbreakdown_itemdescription'] where $numbering stands for array's index number.

Define a variable in a function php [duplicate]

This question already has an answer here:
Notice : Undefined variable when concatenating
(1 answer)
Closed 7 years ago.
I have a function as below but I get warning for $tab variable that says it is not defined. How can I define it and not receive this warning anymore?
<?php
/*** suggested articles as random ***/
function doArticle_suggested_small_horizontall($articleid,$title,$photo,$parentid,$catid,$altdescription) {
$tab .= "<table width=150 cellspacing=5 style=border: 1px solid #0066ff align=right>\n";
$tab .= "<tr>\n";
$tab .= "<td align=center bgcolor=#ffffff><a href='../artandculture/adetails.php?articleid=$articleid&parentid=$parentid&catid=$catid'>
<img src='../images/simage/$photo' border='0' alt='$altdescription'></a></td>\n";
$tab .= "</tr>\n";
$tab .= "<tr align=right width=150 height=80 border=0 style=border: 1px solid #ffffff>\n";
$tab .= "<td width=110 align=right dir='rtl' border=0 style=border: 1px solid #ffffff ><p class=articletitlenounderline><a href='../artandculture/adetails.php?articleid=$articleid&parentid=$parentid&catid=$catid'><strong>$title </strong></p></a></td>\n";
$tab .= "</tr>\n";
$tab .= "</table> <p> <hr class='hr99' ></hr></p>";
return $tab;
}
$tab = "";
?>
You need to define $tab at the beginning of the function.
replace $tab .= "<table width=15 ....
with $tab = "<table width=15....
Or you could just add $tab = ""; as the first line of the function, now you are defining it outside the function which you should remove.
Define $tab,
$tab = [...];
Then you need to do .= on the variable. The variable does not exist where you start using it.
".=" is telling PHP to add a string to an existing variable. PHP cannot add the string if there is no existing variable.
// Add this before your first $tab .=
$tab = NULL;
Move $tab to the start of the function in order for the concatenation to properly work:
Instead of this in the end:
$tab = "";
Do this:
<?php
/////////////////////suggested articles as random /////////////////////////
function doArticle_suggested_small_horizontall($articleid,$title,$photo,$parentid,$catid,$altdescription) {
$tab = "";
$tab .= "<table width=150 cellspacing=5 style=border: 1px solid #0066ff align=right>\n";
$tab .= "<tr>\n";
$tab .= "<td align=center bgcolor=#ffffff><a href='../artandculture/adetails.php?articleid=$articleid&parentid=$parentid&catid=$catid'>
<img src='../images/simage/$photo' border='0' alt='$altdescription'></a></td>\n";
$tab .= "</tr>\n";
$tab .= "<tr align=right width=150 height=80 border=0 style=border: 1px solid #ffffff>\n";
$tab .= "<td width=110 align=right dir='rtl' border=0 style=border: 1px solid #ffffff ><p class=articletitlenounderline><a href='../artandculture/adetails.php?articleid=$articleid&parentid=$parentid&catid=$catid'><strong>$title </strong></p></a></td>\n";
$tab .= "</tr>\n";
$tab .= "</table> <p> <hr class='hr99' ></hr></p>";
return $tab;
}
?>
In addition to the other answers, if you already have something assigned to $tab and want to append it from function, you must either send it in as an argument to the function or add the function output
function example( $tab, $something = false ) {
$tab .= ', added this in example function';
return $tab;
}
$tab = 'Original content';
echo example( $tab ); // Output: Original content, added this in example function
function example2( $something = false ) {
return ', added this in example2 function';
}
$tab = 'Original content 2';
$tab .= example2();
echo $tab: // Output: Original content 2, added this in example2 function

Table max 3 <td> loop in other tr

How to make it like only 3 offers in row NOW I have one row and all offer is in one line I just want to to show max 3 td in tr and loop.
if(count($offer_list['item']) > 0)
{
$main_content .= '<table cellspacing="2" cellpadding="2" width=30>';
foreach($offer_list['item'] as $item)
{
$main_content .= '<td class="shop">
<a class="shop" style="display: block;" href="/shop/item/id/'.$item['id'].'">
<center><img src="item_images/'.$item['item_id'].'.gif"><br><font color="white"><b>'.$item['name'].'</font></b><font color="red"> <b> '.$item['points'].' points</font></b>';
if(!$logged)
{
$main_content .= '<p><b>[Login to buy]</b>';
}
else
{
$main_content .= '<br><b><font size=1 color="white">Your points balance is: '.$user_premium_points;
$main_content .= '<br><font color="white"> <fieldset class="shop"><legend>DESCRIPTION</legend>'.$item['description'].'</fieldset></font><br><font color="white"><b> [Click to buy] </b></font></form> </a></center></td>';
}
$main_content .= '';
}
$main_content .= '</tr></table>';
}
$row_count = 1;
$main_content .= '<table cellspacing="2" cellpadding="2" width=30>';
foreach($offer_list['item'] as $item) {
// Check, if we are at position "1". If so, start new row
if ($row_count === 1) { $main_content .= '<tr>'; }
$main_content .= '<td class="shop"><a class="shop" style="display: block;" href="/shop/item/id/'.$item['id'].'">
<center><img src="item_images/'.$item['item_id'].'.gif"><br><font color="white"><b>'.$item['name'].'</font></b><font color="red"> <b> '.$item['points'].' points</font></b>';
if(!$logged) {
$main_content .= '<p><b>[Login to buy]</b>';
}
else {
$main_content .= '<br><b><font size=1 color="white">Your points balance is: '.$user_premium_points;
$main_content .= '<br><font color="white"> <fieldset class="shop"><legend>DESCRIPTION</legend>'.$item['description'].'</fieldset></font><br><font color="white"><b> [Click to buy] </b></font></form> </a></center></td>';
}
// Check, if we we are at position "3". If so, end row. (set position back to 1)
// Otherwise increase position with one level.
if ($row_count === 3) {
$row_count = 1;
$main_content .= '</tr>';
}
else {
$row_count++;
}
} // end foreach
// This is code for filling the "blank" table cells, if you don't have exactly some item count / 3 = 0
if ($row_count !== 3) {
for ($i=0; $i<=(3-$row_count); $i++) {
$main_content .= '<td> </td>';
}
$main_content .= '</tr>';
}
$main_content .= '</table>';
PS: <center> is deprecated or more to say not valid HTML anymore.

Using jquery to hide and show php dynamicly created content "Search Results"

I have a table that displays my search results, and pending if a user has a function open I want to only display 5 results per row, and the same if they have it closed I want to show 7 results. This is working fine, but the issue I am having is when I toggle the function the div is hidden or shows but the PHP content that was dynamically created is still visible. I know that the div hides or shows pending the function because I wrote static text in the dynamically create divs and pending the function the text is shown or hidden.
Question: How to hide the php content as well?
PHP content =
/*BIG*/
//begin new row
if($result_incBig == $beginRowBig){
$b .= '<tr>';
//row color
$row_color = ($color_incBig % 2) ? 'tdAltRow_A' : 'tdAltRow_B';
if($i == ($num_qk-1)){
$secondRowClass = 'tdAltRow_noBorder';
}else{
$secondRowClass = 'tdAltRow';
}
//increment the color of the row
++$color_incBig;
}
$b .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom">';
$b .= '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
$b .= '<tr>';
$b .= '<td align="center" style="height:80px; padding:4px; vertical-align:middle;">'.$appendLinkBegin.$companyPic.$appendLinkEnd.'</td>';
$b .= '</tr>';
$b .= '<tr>';
$b .= '<td align="center" style="height:35px; padding:2px; vertical-align:bottom;">'.$appendLinkBegin.'<b>'.$company_name.'</b>'.$addSpace.'<br />'.$num2.' '.$resultText.$appendLinkEnd.'</td>';
$b .= '</tr>';
$b .= '</table>';
$b .= '</td>';
//end row if out of results or reached max num for row
if($result_incBig == $endRowBig){
$b .= '</tr>';
$result_incBig = 0;
}else if(($i+1) == $num_qk){
if($result_incBig < $endRowBig){
for($e=0;$e<=($endRowBig-$result_incBig);++$e){
$b .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom"><!--space--></td>';
}
$b .= '</tr>';
$result_incBig = 0;
}
}
//increment inc
++$result_incBig;
/*END BIG*/
/*SMALL*/
//begin new row
if($result_incSmall == $beginRowSmall){
$s .= '<tr>';
//row color
$row_color = ($color_incSmall % 2) ? 'tdAltRow_A' : 'tdAltRow_B';
if($i == ($num_qk-1)){
$secondRowClass = 'tdAltRow_noBorder';
}else{
$secondRowClass = 'tdAltRow';
}
//increment the color of the row
++$color_incSmall;
}
$s .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom">';
$s .= '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
$s .= '<tr>';
$s .= '<td align="center" style="height:80px; padding:4px; vertical-align:middle;">'.$appendLinkBegin.$companyPic.$appendLinkEnd.'</td>';
$s .= '</tr>';
$s .= '<tr>';
$s .= '<td align="center" style="height:35px; padding:2px; vertical-align:bottom;">'.$appendLinkBegin.'<b>'.$company_name.'</b>'.$addSpace.'<br />'.$num2.' '.$resultText.$appendLinkEnd.'</td>';
$s .= '</tr>';
$s .= '</table>';
$s .= '</td>';
//end row if out of results or reached max num for row
if($result_incSmall == $endRowSmall){
$s .= '</tr>';
$result_incSmall = 0;
}else if(($i+1) == $num_qk){
if($result_incSmall < $endRowSmall){
for($e=0;$e<=($endRowSmall-$result_incSmall);++$e){
$s .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom"><!--space--></td>';
}
$s .= '</tr>';
$result_incSmall = 0;
}
}
//increment inc
++$result_incSmall;
/*END SMALL*/
}
//display table
if($where == ''){
$b = '<input type="hidden" name="numberRes" id="numberRes" value="No Results" />';
$s = '<input type="hidden" name="numberRes" id="numberRes" value="No Results" />';
}
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
//results
echo '<div class="rowFillBig">big7Results'.$b.'</div>';
echo '<div class="rowFillSmall" style="display:none;">small5Results'.$s.'</div>';
echo '</table>';
The Jquery function:
$(function () {
$('#tab_1').click(function(){
$('#tab_vid').toggle();
if ($("#mainContentRF").width() == 825){
$("#mainContentRF").width(1180);
$("audio").width(800);
//if viewing the full screen pause video
<?php if($viewingVideo > ''){ ?>
video = $('.videoplayer').get(0);
video.pause();
<?php } ?>
<!--hide small-->
$(".rowFillSmall").css("display", "none");
<!--show big-->
$(".rowFillBig").css("display", "inline");
}else{
$("#mainContentRF").width(825);
$("audio").width(500);
<!--show small-->
$(".rowFillSmall").css("display", "inline");
<!--hide big-->
$(".rowFillBig").css("display", "none");
}
<!--if tab was left open dont close it-->
<?php if($acc_openValue_1 == '99'){ ?>
})
<?php }else{ ?>
}).click();
<?php } ?>
});
If I can be more clear please let me know. Basically the div and any content inside should hide when asked to, and show when asked.
Place the div's on the outside of the table like this.
echo '<div class="rowFillBig">';
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
//results
echo $b;
echo '</table>';
echo '</div>';
echo '<div class="rowFillSmall" style="display:none;">';
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
//results
echo $s;
echo '</table>';
echo '</div>';

Categories