PHP Classes

File: catalog.php

Recommend this page to a friend!
  Classes of Huda M Elmatsani   Data Displayer   catalog.php   Download  
File: catalog.php
Role: Example script
Content type: text/plain
Description: example: catalog
Class: Data Displayer
Display MySQL query result data in various formats
Author: By
Last change:
Date: 20 years ago
Size: 2,923 bytes
 

Contents

Class file image Download
<style type="text/css">
<!--
.style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #FF0000;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
</script>
<?
function caps($str) {
    return
strtoupper($str);
}

function
currency($num) {
   
$num = "$&nbsp;".number_format($num,2,'.',',');
    return
$num;
}



include(
"datadisplayer.php");

$catalog = new datadisplayer;
$catalog->set_db ("localhost","user","password","eproshop");
$catalog->set_rs ("SELECT prodID,prodtitle,proddesc,prodimage,prodprice FROM products");
$catalog->set_page ($_REQUEST[page],10);
$catalog->set_data();

$catalog->set_tbl ("catalogue",array("border"=>"0","cellspacing"=>"0","cellpadding"=>"5","width"=>"500"));

/* prepare table */
$catalog->set_tbl_cols (array("code","name","desc","price"));
$catalog->set_tbl_colprop ("code",array("width"=>"60"));
$catalog->set_tbl_colalias ("desc","Product Description");

$catalog->set_tbl_header (array("bgcolor"=>"#CCCCCC","height"=>"30","style"=>"font-family: Arial, Helvetica; text-decoration:none;font-size:12"));
$catalog->set_tbl_rows (array("valign"=>"top","style"=>"font-family: Arial, Helvetica; text-decoration:none;font-size:11"));
$catalog->set_tbl_rowshade (array("#D0D0E8","#DEDEEF"));
$catalog->set_tbl_rowfade (array("#DDF0FF"));
$catalog->set_tbl_liner (array("bgcolor"=>"#006699","height"=>"1"));

/* manipulate data */
$catalog->set_function ("var_2","currency",array("prodprice"));
$catalog->set_image ("img_1","prodimage","images/thumbnails",array("width"=>"80","height"=>"80","border"=>"0"));
$catalog->set_link ("link_1","http://www.justdummy.com/product.php?classid=prodID","prodtitle");
$catalog->set_link ("link_2","javascript:popUpWindow('images/prodimage',0,0,200,200)","img_1");

/* apply styles */
$catalog->set_style ("prodID","font-family: Arial, Helvetica; text-decoration:none");
$catalog->set_style ("link_1","font-size:11;text-decoration:none");


$layout_img = "
<table width=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"100\" >{link_1}</th>
  </tr>
  <tr>
    <td width=\"100\" >{link_2}</th>
  </tr>
</table>"
;

/* placements */
$catalog->assign(array("code" => "prodID",
                     
"desc" => "proddesc",
                     
"price" => "var_2"));

$catalog->assign_template(array("name" => $layout_img));

echo
$catalog->get_result();


?>