PHP Output into Table, 2 Items Per Row

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zan03
Forum Newbie
Posts: 6
Joined: Sun Apr 11, 2010 4:32 pm

PHP Output into Table, 2 Items Per Row

Post by Zan03 »

Hi there, hope you can help here.

I want to output my list of items from my database into a table, but display the items in this order:

1. Quote 7. Invoices
2. Before Pictures 8. After Pictures
3. Upgrades
4. Specifications
5. Unit Layout
6. Pricelist


At the momement I am outputting 1 product per row.

e.g.

"Item1"
"Item2"
"Item3" etc

Here is the php code I have got (I didn't write it so it look Foreign to me).

Anyone have an idea?:

Code: Select all

<?php
//////////////////////////////////////////////////////////////////////////////
//Filename: list_quotes.php
//Author: 
//Last Changed:
//Modified By: 
//Modified By: 
//
//This page shows the quote for an apartment and provides links to relevant
// pictures
//////////////////////////////////////////////////////////////////////////////

session_start();
if(!isset($_SESSION['user'])) header( "Location: index.php" );

$bbg = false;
//$bfl = false;
//$bln = false;

if(isset($_GET['building'])){$_SESSION['building'] = $_GET['building']; $bbg = true;}
$building = $_SESSION['building'];

if(isset($_GET['floor'])){$_SESSION['floor'] = $_GET['floor']; $bbg = false;}
$floor = $_SESSION['floor'];

if(isset($_GET['line'])){$_SESSION['line'] = $_GET['line']; $bbg = false;}
$line = $_SESSION['line'];

?>

<html>
<head>
<title>Title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Company details">
<link rel="stylesheet" type="text/css" href="daleri-single.css" title=" Company name  " media="screen,projection"/>

<p class="toptabs">
    <a class="toptab active" href="javascript:history.back(1)" >Back</a><span class="hide"> | </span>
    <a class="toptab" href="http://park.thebynggroup.com/contact.php">Contact Us</a><span class="hide"> | </span>
    </p>

<div id="maincontent">


    <td>
       <td rowspan='2' colspan='3'>
      <p align='left'><i><font face='Century Gothic' size='2'> </font></i></p>
      <p><font face='Century Gothic' size='2'>


<?php

if($bbg) {
    include("$building/index.html");
}
else {

$buildingPath = $building . "/"  ;
$PrettyBuilding = str_replace("_"," ",$building);

if ($floor=="Penthouse")
  {
  $filePath = $building . "/" . $floor . "/Unit " . $line . "/"  ;
  }
else
  {
  $filePath = $building . "/FL " . substr("00".trim($floor),-2) . "/Unit " . $line . "/"  ;
  }

/*     <p>Filepath: <?php echo $filePath;?></p> */

?>


<title> Byng <?php echo $PrettyBuilding; ?></title>
    </head>

<body>
<body bgcolor="#ECE9D8">
<p align="left"><font face="Century Gothic" size="7"> 
 <?php echo $PrettyBuilding;?> </font></p>

 <p align="left"><font face="Century Gothic" size="5"> 
Floor: <?php echo $floor;?> Unit:<?php echo $line;?>
 </font></p>


<p align="left"><font face="Century Gothic" size="4"> 
<?php
//See if there are any quotes

$QuoteCount = 1;
$QuoteArray = array();


    $QuoteArray = glob($filePath."Quote*.*");

  if (1==sizeof($QuoteArray)) 
  {
         echo "<p><a href='$QuoteArray[0]'>Quote</a></p>";
     }
     else if (1<=sizeof($QuoteArray)) 
        {
           echo "<p>Quotes:</p>";
        for($i=1;$i<=sizeof($QuoteArray);$i++)
        {
            echo "<p><a href='$QuoteArray[$i]'>Quote$i</a></p>";
        }
    }


//See if there are any photos

?>
<p>Before Pictures</p>
<?php


$picCount = 1;
$picArray = array();

// the next line is a hack to not show thumbs files that populate directories when people look at them.

    $picArray = glob($filePath . "/Pictures/*.{jpg,gif,png,JPG,GIF,PNG,jpeg,JPEG}",GLOB_BRACE);
    if (sizeof($picArray)>0)
{
    ?>
       <ol>
     <?php
                for($i=0;$i<sizeof($picArray);$i++)
                {
                ?>
           <li><a href="<?php echo $picArray[$i];?>"><?php echo basename($picArray[$i]);?> </a></li>
                <?php
                }
    ?>       </ol>
<?php  }
?>
    


    
<?php


//See if there are any Upgrades for this line

if (file_exists($building . "/Line" . $line . ".pdf"))
{
?>
           <p><a href="<?php echo $building. "/Line" . $line . ".pdf";?>">Upgrades</a></p>
        <?php
        }


//See if there is a specifications files

if (file_exists($building . "/" . "Specifications.pdf"))
{
?>
           <p><a href="<?php echo $building;?>/Specifications.pdf">Specifications</a></p>
        <?php
        }

//See if there is a unit floor plan layout
    
if (file_exists($building . "/FP" . $line . ".jpg"))
{
?>
           <p><a href="<?php echo $building . "/FP" . $line . ".jpg";?>">Unit Layout</a></p>
        <?php
        }



//See if there is a pricelist
    
if (file_exists($building . "/" . "Pricelist.pdf"))
{
?>
           <p><a href="<?php echo $building;?>/Pricelist.pdf">Pricelist</a></p>

        <?php
        }
        
$invoiceCount = 1;
$invoiceArray = array();

// If there are any after pictures in a special subdirectory, show them here. 

    $invoiceArray = glob($filePath . "/{I,i}nvoice*.pdf",GLOB_BRACE);
    if (sizeof($invoiceArray)>0)
{
    ?>
       <p>Invoices</p>
       <ol>
     <?php
                for($i=0;$i<sizeof($invoiceArray);$i++)
                {
                ?>
           <li><a href="<?php echo $invoiceArray[$i];?>"><?php echo basename($invoiceArray[$i]);?> </a></li>
                <?php
                }
    }
    ?>       </ol>
    
<?php
       
    }

?>

<p>After Pictures</p>

<?php
$afterpicCount = 1;
$afterpicArray = array();

// If there are any after pictures in a special subdirectory, show them here. 

    $afterpicArray = glob($filePath . "/After Pictures/*.{jpg,gif,png,JPG,GIF,PNG,jpeg,JPEG}",GLOB_BRACE);
    if (sizeof($afterpicArray)>0)
{
    ?>
       <ol>
     <?php
                for($i=0;$i<sizeof($afterpicArray);$i++)
                {
                ?>
           <li><a href="<?php echo $afterpicArray[$i];?>"><?php echo basename($afterpicArray[$i]);?> </a></li>
                <?php
                }
    ?>       </ol>
    
<?php

    }

?>



 </font></p>
      <p>
</td>
     </tr>
<br>

</p>
            </td>
          </tr>
        </table>
        <p>&nbsp;</p>
        </div>
    </td>
  <tr valign="top"><!-- row 8 -->
    <td colspan="4">
  
</table>
</body>
</html>




Zan03
Forum Newbie
Posts: 6
Joined: Sun Apr 11, 2010 4:32 pm

Re: PHP Output into Table, 2 Items Per Row

Post by Zan03 »

Any suggestions?

Thanks,

Zanna
Post Reply