As a former VB6 programmer I rarely used classes, so I am not only new to OOP this is my first in PHP. I appreciate any input.
Thanks!
class jobs{
var $quote, $date, $qty, $price, $papid, $lth, $wth;
var $ink_ft = array();
var $ink_bk = array();
var $papName, $papType, $papWeight, $papColor;
function jobs($qt_no, $qty_index){
$this->quote = $qt_no;
$price_index = "fldPrice".$qty_index;
$qty_index = "fldQty".$qty_index;
$strSQL = "select fldDate, $qty_index, $price_index, fldGroupID, fldLth, fldWth,
fldInkFt1, fldInkFt2, fldInkFt3, fldInkFt4, fldInkFt5,
fldInkBk1, fldInkBk2, fldInkBk3, fldInkBk4, fldInkBk5
from tblQuotes where fldQtID = {$this->quote}";
$result = mysql_query($strSQL);
if ($result){
$row = mysql_fetch_assoc($result);
$this->date = $row['fldDate'];
$this->qty = $row[$qty_index];
$this->price = $row[$price_index];
$this->papid = $row['fldGroupID'];
$this->lth = $row['fldLth'];
$this->wth = $row['fldWth'];
for($i=1; $i<6; ++$i){
$strTmp = "fldInkFt".$i;
if($row[$strTmp] != '\0' || $row[$strTmp] != "")
$this->ink_ft[$i] = $row[$strTmp];
$strTmp = "fldInkBk".$i;
if($row[$strTmp] != '\0' || $row[$strTmp] != "")
$this->ink_bk[$i] = $row[$strTmp];
}
mysql_free_result($result);
}
else{
echo mysql_error();
}
}
function paper($papid){
$strSQL = "SELECT fldName, fldType, fldWeight, fldColor FROM
tblPaper WHERE fldGroup = $papid AND fldFirstRec = 1";
$result = mysql_query($strSQL);
if ($result){
$row = mysql_fetch_assoc($result);
$this->papName = $row['fldName'];
$this->papType = $row['fldType'];
$this->papWeight = $row['fldWeight'];
$this->papColor = $row['fldColor'];
}
else{
echo mysql_error();
}
}
}
function view_jobs(){
$memid = $_POST['member'];
$obj = array();
$job_id = array();
$qty = array();
$quote = array();
$i=0;
$strSQL = "SELECT tblJobs.fldJobID, tblJobs.fldQuoteNo,
fldQty FROM tblJobs WHERE tblJobs.fldMember = $memid";
mysql_connect("xxxxx", "xxxxx", "xxxxx");
mysql_select_db("xxxxxx");
$result = mysql_query($strSQL);
if($result){
//show all open jobs
while ($row = mysql_fetch_array ($result)){
$job_id[$i] = $row['fldJobID'];
$qty[$i] = ($row['fldQty'] + 1);
$quote[$i] = $row['fldQuoteNo'];
$obj[$quote[$i]] = new jobs($quote[$i], $qty[$i]);
$obj[$quote[$i]]->paper($obj[$quote[$i]]->papid);
print"{$obj[$quote[$i]]->date} {$obj[$quote[$i]]->qty} {$obj[$quote[$i]]->price}<br />";
print("front: \n");
foreach($obj[$quote[$i]]->ink_ft as $inkft){
print("$inkft\n");
}
print("<br />\n");
print("back:\n");
foreach($obj[$quote[$i]]->ink_bk as $inkbk){
print("$inkbk\n");
}
print("<br />\n");
print"Paper: {$obj[$quote[$i]]->papName} {$obj[$quote[$i]]->papType}
{$obj[$quote[$i]]->papWeight} {$obj[$quote[$i]]->papColor}<br />";
print("<br /><br />\n");
++$i;
}
mysql_free_result($result);
//destroy $obj
foreach($obj as $koObj){
unset($koObj);
}
//see if $obj is destroyed
print"test {$obj[$quote[$i]]->date}<br />";
}
else{
echo mysql_error();
}
mysql_close();
}