Jump to content

wchamber22

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by wchamber22

  1. Hi scoots, Good question. The first query (SELECT courseID, courseName, courseTYRS FROM courses) Thanks for your quick reply.
  2. Hello again freaks, When testing I noticed that the code as provided below only displays the first db result from my query. I need it to display all the db results. I know I am missing a single key ingredient, but can't put my finger on it after trying and trying. Code below: function coursesCode(){ if( !isset($_SESSION['user_id']) ){ echo '<table width="716" cellpadding="3" cellspacing="0" border="0"> <tr> <td width="250" bgcolor="#CCCCCC"><h4>COURSE NAME</h4></td> <td width="75" bgcolor="#CCCCCC"><h4>TEES</h4></td> <td width="100" bgcolor="#CCCCCC"><h4>YARDAGE</h4></td> <td width="75" bgcolor="#CCCCCC"><h4>RATING</h4></td> <td width="75" bgcolor="#CCCCCC"><h4>SLOPE</h4></td> <td bgcolor="#CCCCCC"><h4>CONDITION</h4></td> </tr>'; $sql = mysql_query("SELECT courseID, courseName, courseTYRS FROM courses") or die(mysql_error()); while($row = mysql_fetch_array($sql)){ $course_id = $row["courseID"]; $courseName = $row["courseName"]; $courseTYRS = $row["courseTYRS"]; echo '<tr> <td valign="top"><a href="coursedetails.php?courseID=' . $course_id . '"><strong>' . $courseName . '</strong></td> <td colspan="4"> <table width="325" cellpadding="3" cellspacing="0" border="0">'; $courseTYRSarray = explode(",", $courseTYRS); foreach ($courseTYRSarray as $key => $value){ $courseTee_Yardage_Rating_Slope = explode("-", $value); $courseTee = $courseTee_Yardage_Rating_Slope[0]; $courseYardage = $courseTee_Yardage_Rating_Slope[1]; $courseRating = $courseTee_Yardage_Rating_Slope[2]; $courseSlope = $courseTee_Yardage_Rating_Slope[3]; echo '<tr> <td width="75">' . $courseTee . '</td> <td width="100">' . $courseYardage . '</td> <td width="75">' . $courseRating . '</td> <td width="75">' . $courseSlope . '</td> </tr>'; } $sql2 = mysql_query("SELECT date FROM course_conditions WHERE courseID='$course_id' ORDER BY date DESC LIMIT 1") or die(mysql_error()); while($row2 = mysql_fetch_array($sql2)){ $date = $row2["date"]; } if(!$date){ $dateOutput = '<img src="images/minus.png"> N/A'; }else{ $dateOutput = '<img src="images/checkmark.png"> ' . $date . ''; } echo '</table> </td> <td valign="top">' . $dateOutput . '</td> </tr> <tr> <td colspan="6"> </td> </tr>'; } echo '</table>'; } } As always thanks in advance!
  3. Yo Mahngiel, Thanks for the help but I would like to drop all other decimal places WITHOUT rounding. For example, I want 3.4673930 to be 3.4 NOT 3.5 as the round() would do. So do you know how to only execute that code if i have a decimal, if not just skip it because I am assuming it would cause errors if the equation returned a whole number. Thanks
  4. Once again HELLO FREAKS, I have an equation calculating a users differential for an entered round below: $differential = ($totalScore - $courseRating) * 113 / $courseSlope For example, if I shot (wishful thinking) a 74 at a course with a rating of 70.3 and a course slope of 122. The equation would be (74 - 70.3) * 113 / 122 = 3.42704918. I want that to be 3.4 WITHOUT ROUNDING and believe I have done that with the following code: $differential = explode(".", $differential); $decimal = substr($differential[1],0,1); $differential = $differential[0].'.'.$decimal; My question is: How could I use and if else statement to ONLY run the above code if the number is a decimal on the off chance that the equation works out to be a whole number? FYI, my mysql column differential is a decimal (3,2) Thanks as always!
  5. Hello psycho and ignace, Thanks for your help. This code makes complete sense. I learned alot and think I can reuse some pricipals learned from this code in other areas of the site. FYI, psycho: you totally understood what I was trying to do. I am sure I will be back before I finish this site, Later.
  6. Hello Freaks, Sorry this will be a long-winded explaination, be prepared. I am hole-heartedly trying to create a golf index calculator. It works like this: A user must have a min of 5 rounds in order to have an index. The calculator will compute no more than a users last 20 rounds. Below is a chart of how it is calculated: Number of differentials used Rounds Entered Diferentials Used 5-6 Use the lowest differential 7-8 Use the 2 lowest differentials 9-10 Use the 3 lowest differentials 11-12 Use the 4 lowest 13-14 Use the 5 lowest 15-16 Use the 6 lowest 17 Use the 7 lowest 18 Use the 8 lowest 19 Use the 9 lowest 20 or more Use the 10 lowest (of the 20 most recent rounds) For instance, if I have entered 12 rounds, my index would be calculated by taking the 4 lowest differentials of those 12 rounds, adding those 4 differentials together and dividing by 4. Last example: If I have 32 rounds entered, my index would be calculated by taking the 10 lowest differentials FROM THE MOST RECENT 20 ROUNDS, adding those 10 differentials together and dividing by 10. My db table SCORES looks like this: scoreID userID (id of user that entered score) courseID (id of the course the round was played) date (date of the round) tee (what tee the user played from) score (users score) differential: Type:DECIMAL(3,2) (round differential - I was able to calculate this before inserting into the db) So far I haven't much doing, see below: $sql3 = mysql_query("SELECT differential FROM scores WHERE userID='$user_id' ORDER BY date DESC"); $score_count = mysql_num_rows($sql3); if($score_count <= 4){ $scoreMsg = 'You have ' . $score_count . ' of 5 rounds entered to complete your handicap index.'; }elseif($score_count == 5 || $score_count == 6){ $rsDiffs = mysql_fetch_array($sql3); $userIndex = min($rsDiffs); $scoreMsg = 'You have ' . $score_count . ' rounds entered<br/><br/> Your HANDICAP INDEX is now: ' . $userIndex .''; //This one I THINK I can use the MIN function because it uses the single lowest differential of the $rsDiffs array, WILL THIS WORK? }elseif($score_count == 7 || $score_count == { $rsDiffs = mysql_fetch_array($sql3); //$userIndex = This one will use the 2 lowest diffentials of the $rsDiffs array, SO HOW DO I NARROW THE $rsDiffs array TO THE LOWEST 2, ADD THE 2 TOGETHER AND DIVIDE BY 2? $scoreMsg = 'You have ' . $score_count . ' rounds entered<br/><br/> Your HANDICAP INDEX is now: ' . $userIndex .''; }elseif($score_count == 9 || $score_count == 10){ //Same as above BUT this one will use the 3 lowest of the 9 or 10 entered scores. }elseif($score_count == 11 || $score_count == 12){ //Same as above BUT this one will use the 4 lowest of the 11 or 12 entered scores. }elseif($score_count == 13 || $score_count == 14){ //Same as above BUT this one will use the 5 lowest of the 13 or 14 entered scores. }elseif($score_count == 15 || $score_count == 16){ //Same as above BUT this one will use the 6 lowest of the 15 or 16 entered scores. }elseif($score_count == 17){ //Same as above BUT this one will use the 7 lowest of the 17 entered scores. }elseif($score_count == 18){ //Same as above BUT this one will use the 8 lowest of the 18 entered scores. }elseif($score_count == 19){ //Same as above BUT this one will use the 9 lowest of the 19 entered scores. }elseif($score_count >= 20){ //This is where it really gets complicated IN MY MIND, this one will use the 10 lowest of 20 scores entered OR the 10 lowest of the 20 most recent rounds if $scores_count > 20. } Once again, sorry for the long-winded request! I think if I get some guidance on the first if(<=4), a middle if-else(==5 || ==6) and the final if-else(>=20) I will be able to figure out the rest. Any help would be much appreciated! Thanks Freaks.
  7. Thorpe is >= THE MAN, thanks, SOLVED!
  8. In case you forgot the error message is as follows: Fatal error: Call to undefined method FPDF::WordWrap() Thanks
  9. Kevin the line is as follows: $pdf -> WordWrap($text, $useDescTextWidth); This is the first call to the WordWrap function, I can fix the rest after we get this squared away! Thanks again.
  10. Hello KevinM1, I do instantiate a PDF object in my full script. It is very long so I cut and pasted the sections to limit the length. I will post the whole script now though. The WordWrap class extension is located at the top of the script just after the if $_GET condition. Several calls to the function are made toward the bottom of the script. Does the function need to be after the instantiation of a new(FDPF), maybe? Code Below: <?php if(isset($_GET['cmd']) && $_GET['cmd'] == "compilebook") { $sql = mysql_query("INSERT INTO books (memberID, plant_use, customerName, customerAddress, customerCity, customerState, customerZip, customerPhone, book_template) VALUES ('$memberID', '$plantUse', '$customerName', '$customerAddress', '$customerCity', '$customerState', '$customerZip', '$customerPhone', '$book_template')"); include_once "fpdf16/fpdf.php"; class PDF extends FPDF { function WordWrap(&$text, $maxwidth) { $text = trim($text); if ($text==='') return 0; $space = $this->GetStringWidth(' '); $lines = explode("\n", $text); $text = ''; $count = 0; foreach ($lines as $line) { $words = preg_split('/ +/', $line); $width = 0; foreach ($words as $word) { $wordwidth = $this->GetStringWidth($word); if ($wordwidth > $maxwidth) { // Word is too long, we cut it for($i=0; $i<strlen($word); $i++) { $wordwidth = $this->GetStringWidth(substr($word, $i, 1)); if($width + $wordwidth <= $maxwidth) { $width += $wordwidth; $text .= substr($word, $i, 1); } else { $width = $wordwidth; $text = rtrim($text)."\n".substr($word, $i, 1); $count++; } } } elseif($width + $wordwidth <= $maxwidth) { $width += $wordwidth + $space; $text .= $word.' '; } else { $width = $wordwidth + $space; $text = rtrim($text)."\n".$word.' '; $count++; } } $text = rtrim($text)."\n"; $count++; } $text = rtrim($text); return $count; } } $plantUse = rtrim($plantUse, ","); $plantID_str_array = explode(",", $plantUse); if ($book_template = "1") { //////MODERN BOOK STYLE/////////////////////////////////////////// //BUILD COVER PAGE ------------------------------------------- $textColor = array(100, 100, 100); $headerTextColor = array(50, 50, 50); $footerTextColor = array(16, 177, 77); $backgroundImageCover = "images/modern/coverbackground1.jpg"; $backgroundImageCoverXPos = 0; $backgroundImageCoverYPos = 0; $backgroundImageCoverWidth = 612; $backgroundImageCoverHeight = 792; $companyLogo = "memberFiles/$memberID/logo.jpg"; $logoCoverXPos = 41; $logoCoverYPos = 58; $logoCoverWidth = 65; //$logoCoverHeight = 65; $companyNameCoverXPos = 119; $companyNameCoverYPos = 58; $companyNameCoverWidth = 435; $companyNameCoverHeight = 20; $companyCityStateZip = '' . $companyCity . ', ' . $companyState . ' ' . $companyZip . ''; $companyPhone = 'Tel: ' . $companyPhone . ''; $companyWeb = 'Web: ' . $companyWeb . ''; //$companyInfoCoverXPos = 119; //$companyInfoCoverYPos = 78; $companyInfoCoverWidth = 300; $companyInfoCoverHeight = 12; $customerPhoto = "memberFiles/$memberID/$customerName/customerphoto.jpg"; $customerPhotoXPos = 225; $customerPhotoYPos = 328; //$customerPhotoWidth = 335; $customerPhotoHeight = 223; $customerNameCoverXPos = 225; $customerNameCoverYPos = 566; $customerNameCoverWidth = 335; $customerNameCoverHeight = 28; $customerCityStateZip = '' . $customerCity . ', ' . $customerState . ' ' . $customerZip . ''; $customerPhone = 'Tel: ' . $customerPhone . ''; //$customerInfoCoverXPos = 225; //$customerInfoCoverYPos = 614; $customerInfoCoverWidth = 335; $customerInfoCoverHeight = 12; $pdf = new FPDF('P', 'pt', 'Letter'); $pdf -> AddPage(); //Cover Background $pdf -> Image($backgroundImageCover, $backgroundImageCoverXPos, $backgroundImageCoverYPos, $backgroundImageCoverWidth, $backgroundImageCoverHeight); //Cover Company Logo $pdf -> Image($companyLogo, $logoCoverXPos, $logoCoverYPos, $logoCoverWidth); //Cover Company Name $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '18'); $pdf -> SetXY($companyNameCoverXPos, $companyNameCoverYPos); $pdf -> Cell($companyNameCoverWidth, $companyNameCoverHeight, $companyName); //Cover Company Info $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '12'); $pdf -> SetXY(119, 78); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyAddress); $pdf -> SetXY(119, 90); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyCityStateZip); $pdf -> SetXY(119, 102); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyPhone); $pdf -> SetXY(119, 114); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyWeb); //Cover Customer Photo $pdf -> Image($customerPhoto, $customerPhotoXPos, $customerPhotoYPos, '', $customerPhotoHeight); //Cover Customer Name $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '24'); $pdf -> SetXY($customerNameCoverXPos, $customerNameCoverYPos); $pdf -> Cell($customerNameCoverWidth, $customerNameCoverHeight, $customerName, 0, 0, 'R'); //Cover Customer Info $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '12'); $pdf -> SetXY(225, 614); $pdf -> Cell($customerInfoCoverWidth, $customerInfoCoverHeight, $customerAddress, 0, 0, 'R'); $pdf -> SetXY(225, 626); $pdf -> Cell($customerInfoCoverWidth, $customerInfoCoverHeight, $customerCityStateZip, 0, 0, 'R'); $pdf -> SetXY(225, 638); $pdf -> Cell($customerInfoCoverWidth, $customerInfoCoverHeight, $customerPhone, 0, 0, 'R'); // BUILD TOC PAGE-------------------------------------------------- // LIMIT 25 PAGES!!! $backgroundImageToc = "images/modern/tocbackground1.jpg"; $backgroundImageTocXPos = 0; $backgroundImageTocYPos = 0; $backgroundImageTocWidth = 612; $backgroundImageTocHeight = 792; $plantToc1XPos = 53; $plantToc1YPos = 250; $plantToc1Width = 315; $plantToc1Height = 18; $landscapeUseToc1XPos = 381; $landscapeUseToc1YPos = 250; $landscapeUseToc1Width = 105; $landscapeUseToc1Height = 18; $pageNumToc = "3"; $pageNumToc1XPos = 516; $pageNumToc1YPos = 250; $pageNumToc1Width = 60; $pageNumToc1Height = 18; $pdf -> AddPage(); //TOC Background Image $pdf -> Image($backgroundImageToc, $backgroundImageTocXPos, $backgroundImageTocYPos, $backgroundImageTocWidth, $backgroundImageTocHeight); $p = $plantToc1YPos; $l = $landscapeUseToc1YPos; $pn = $pageNumToc1YPos; $pni = $pageNumToc; foreach ($plantID_str_array as $key => $value) { $plantID_use_pair = explode("-", $value); $plantID = $plantID_use_pair[0]; $use = $plantID_use_pair[1]; $sql = "SELECT botanicalName FROM plants WHERE plantID='$plantID' LIMIT 1"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $botanicalName = $row["botanicalName"]; } //TOC Plant Botanical Name Column $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '11'); $pdf -> SetXY($plantToc1XPos, $p); $pdf -> Cell($plantToc1Width, $plantToc1Height, $botanicalName, 0, 0, 'L'); //TOC Landscape Use Column $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '11'); $pdf -> SetXY($landscapeUseToc1XPos, $l); $pdf -> Cell($landscapeUseToc1Width, $landscapeUseToc1Height, $use, 0, 0, 'L'); //TOC Page Number Column $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '11'); $pdf -> SetXY($pageNumToc1XPos, $pn); $pdf -> Cell($pageNumToc1Width, $pageNumToc1Height, $pni, 0, 0, 'C'); $p = $p + 18; $l = $l + 18; $pn = $pn + 18; $pni++; } //BUILD PLANT PAGES ----------------------------------------------- $logoXPos = 36; $logoYPos = 36; $logoWidth = 55; //$logoHeight = 55; $companyNameXPos = 95; $companyNameYPos = 38; $companyNameWidth = 471; $companyNameHeight = 14; $companyInfoWidth = 202; $companyInfoHeight = 10; $customerNameXPos = 389; $customerNameYPos = 52; $customerNameWidth = 187; $customerNameHeight = 11; $customerInfoWidth = 187; $customerInfoHeight = 10; $useImageBackground = "images/modern/use1.jpg"; //$useImageBackgroundXPos decided in Foreach loop $useImageBackgroundYPos = 100; $useImageBackgroundWidth = 108; $useImageBackgroundHeight = 108; $use1TextXPos = 46; $use1TextYPos = 111; $use1TextWidth = 88; $use1TextHeight = 12; $useDesc1TextXPos = 46; $useDesc1TextYPos = 131; $useDescTextWidth = 88; //$useDesc1TextHeight = 70; $use2TextXPos = 154; $use2TextYPos = 111; $use2TextWidth = 88; $use2TextHeight = 12; $useDesc2TextXPos = 154; $useDesc2TextYPos = 131; //$useDesc2TextWidth = 88; //$useDesc2TextHeight = 70; $use3TextXPos = 262; $use3TextYPos = 111; $use3TextWidth = 88; $use3TextHeight = 12; $useDesc3TextXPos = 262; $useDesc3TextYPos = 131; //$useDesc3TextWidth = 88; //$useDesc3TextHeight = 70; $use4TextXPos = 370; $use4TextYPos = 111; $use4TextWidth = 88; $use4TextHeight = 12; $useDesc4TextXPos = 370; $useDesc4TextYPos = 131; //$useDesc4TextWidth = 88; //$useDesc4TextHeight = 70; $use5TextXPos = 478; $use5TextYPos = 111; $use5TextWidth = 88; $use5TextHeight = 12; $useDesc5TextXPos = 478; $useDesc5TextYPos = 131; //$useDesc5TextWidth = 88; //$useDesc5TextHeight = 70; $backgroundImage = "images/modern/usebackground1.jpg"; $backgroundImageXPos = 0; $backgroundImageYPos = 0; $backgroundImageWidth = 612; $backgroundImageHeight = 792; //$image decided in Foreach Loop $imageXPos = 46; $imageYPos = 218; $imageWidth = 255; $imageHeight = 170; $imageDescHeader = "Image Description:"; $imageDescHeaderXPos = 56; $imageDescHeaderYPos = 398; $imageDescHeaderWidth = 235; $imageDescHeaderHeight = 10; //$imageDesc decided in Foreach Loop $imageDescXPos = 56; $imageDescYPos = 416; $imageDescWidth = 235; //$imageDescHeight = 246; $plantNamesHeaderBot = "Botanical Name:"; $plantNamesHeaderCom = "Common Name:"; $plantNamesHeaderWidth = 84; $plantNamesHeaderHeight = 16; $plantNamesWidth = 153; $plantNamesHeight = 16; $hardinessZonesHeader = "Hardiness Zones:"; $plantTypeHeader = "Plant Type:"; $heightHeader = "Plant Height:"; $spreadHeader = "Plant Spread:"; $flowerHeader = "Flower:"; $bloomTimeHeader = "Bloom Time:"; $foliageHeader = "Foliage:"; $fallColorHeader = "Fall Color:"; $fruitHeader = "Fruit:"; $barkHeader = "Bark:"; $lightReqHeader = "Light Req.:"; $soilHeader = "Soil:"; $growthHeader = "Growth Rate:"; $plantDetailsHeaderWidth = 84; $plantDetailsHeaderHeight = 15; $plantDetailsWidth = 153; $plantDetailsHeight = 15; $maintenanceHeader = "Maintenance Information:"; $maintenanceHeaderXPos = 321; $maintenanceHeaderYPos = 488; $maintenanceHeaderWidth = 235; $maintenanceHeaderHeight = 10; $trimmingHeader = "Trimming:"; $trimmingHeaderXPos = 321; $trimmingHeaderYPos = 506; $trimmingHeaderWidth = 63; $trimmingHeaderHeight = 12; $trimmingTextXPos = 384; $trimmingTextYPos = 506; $trimmingTextWidth = 172; //$trimmingTextHeight = 36; $fertilizationHeader = "Fertilization:"; $fertilizationHeaderXPos = 321; $fertilizationHeaderYPos = 548; $fertilizationHeaderWidth = 63; $fertilizationHeaderHeight = 12; $fertilizationTextXPos = 384; $fertilizationTextYPos = 548; $fertilizationTextWidth = 172; //$fertilizationTextHeight = 36; $otherHeader = "Other:"; $otherHeaderXPos = 321; $otherHeaderYPos = 591; $otherHeaderWidth = 63; $otherHeaderHeight = 12; $otherTextXPos = 384; $otherTextYPos = 591; $otherTextWidth = 172; //$otherTextHeight = 72; $pageNo = "3"; $pageNoXPos = 513; $pageNoYPos = 743; $pageNoWidth = 18; $pageNoHeight = 13; foreach ($plantID_str_array as $key => $value) { $plantID_use_pair = explode("-", $value); $plantID = $plantID_use_pair[0]; $use = $plantID_use_pair[1]; $sql = "SELECT * FROM plants WHERE plantID='$plantID' LIMIT 1"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $botanicalName = $row["botanicalName"]; $commonName = $row["commonName"]; $hardinessZones = $row["hardinessZones"]; $plantType = $row["plantType"]; $height = $row["height"]; $spread = $row["spread"]; $flower = $row["flower"]; $bloomTime = $row["bloomTime"]; $foliage = $row["foliage"]; $fallColor = $row["fallColor"]; $fruit = $row["fruit"]; $bark = $row["bark"]; $lightReq = $row["lightReq"]; $soil = $row["soil"]; $growth = $row["growth"]; $trimming = $row["trimming"]; $fertilization = $row["fertilization"]; $otherMaintenance = $row["otherMaintenance"]; $use1 = $row["use1"]; $use2 = $row["use2"]; $use3 = $row["use3"]; $use4 = $row["use4"]; $use5 = $row["use5"]; $useDesc1 = $row["useDesc1"]; $useDesc2 = $row["useDesc2"]; $useDesc3 = $row["useDesc3"]; $useDesc4 = $row["useDesc4"]; $useDesc5 = $row["useDesc5"]; $imageDesc1 = $row["imageDesc1"]; $imageDesc2 = $row["imageDesc2"]; $imageDesc3 = $row["imageDesc3"]; $imageDesc4 = $row["imageDesc4"]; $imageDesc5 = $row["imageDesc5"]; } if ($use == $use1) { $useImageBackgroundXPos = 36; $image = "images/plants/$botanicalName/LU-1.jpg"; $imageDesc = $imageDesc1; } elseif ($use == $use2) { $useImageBackgroundXPos = 144; $image = "images/plants/$botanicalName/LU-2.jpg"; $imageDesc = $imageDesc2; } elseif ($use == $use3) { $useImageBackgroundXPos = 252; $image = "images/plants/$botanicalName/LU-3.jpg"; $imageDesc = $imageDesc3; } elseif ($use == $use4) { $useImageBackgroundXPos = 360; $image = "images/plants/$botanicalName/LU-4.jpg"; $imageDesc = $imageDesc4; } elseif ($use == $use5) { $useImageBackgroundXPos =468; $image = "images/plants/$botanicalName/LU-5.jpg"; $imageDesc = $imageDesc5; } $pdf -> AddPage(); //Company Logo Header $pdf -> Image($companyLogo, $logoXPos, $logoYPos, $logoWidth, ''); //Company Name Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($companyNameXPos, $companyNameYPos); $pdf -> Cell($companyNameWidth, $companyNameHeight, $companyName, 0, 0, 'L'); //Company Info Header $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(95, 52); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyAddress, 0, 0, 'L'); $pdf -> SetXY(95, 62); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyCityStateZip, 0, 0, 'L'); $pdf -> SetXY(95, 72); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyPhone, 0, 0, 'L'); $pdf -> SetXY(95, 82); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyWeb, 0, 0, 'L'); //Customer Name Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '11'); $pdf -> SetXY($customerNameXPos, $customerNameYPos); $pdf -> Cell($customerNameWidth, $customerNameHeight, $customerName, 0, 0, 'L'); //Customer Info Header $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(389, 63); $pdf -> Cell($customerInfoWidth, $customerInfoHeight, $customerAddress, 0, 0, 'L'); $pdf -> SetXY(389, 73); $pdf -> Cell($customerInfoWidth, $customerInfoHeight, $customerCityStateZip, 0, 0, 'L'); $pdf -> SetXY(389, 83); $pdf -> Cell($customerInfoWidth, $customerInfoHeight, $customerPhone, 0, 0, 'L'); //Use Background Image (Dynamic from If Else) $pdf -> Image($useImageBackground, $useImageBackgroundXPos, $useImageBackgroundYPos, $useImageBackgroundWidth, $useImageBackgroundHeight); //Use 1 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use1TextXPos, $use1TextYPos); $pdf -> Cell($use1TextWidth, $use1TextHeight, $use1, 0, 0, 'L'); //Use 1 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc1TextXPos, $useDesc1TextYPos); $text = $useDesc1; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 2 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use2TextXPos, $use2TextYPos); $pdf -> Cell($use2TextWidth, $use2TextHeight, $use2, 0, 0, 'L'); //Use 2 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc2TextXPos, $useDesc2TextYPos); $text = $useDesc2; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 3 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use3TextXPos, $use3TextYPos); $pdf -> Cell($use3TextWidth, $use3TextHeight, $use3, 0, 0, 'L'); //Use 3 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc3TextXPos, $useDesc3TextYPos); $text = $useDesc3; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 4 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use4TextXPos, $use4TextYPos); $pdf -> Cell($use4TextWidth, $use4TextHeight, $use4, 0, 0, 'L'); //Use 4 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc4TextXPos, $useDesc4TextYPos); $text = $useDesc4; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 5 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use5TextXPos, $use5TextYPos); $pdf -> Cell($use5TextWidth, $use5TextHeight, $use5, 0, 0, 'L'); //Use 5 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc5TextXPos, $useDesc5TextYPos); $text = $useDesc5; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Page Background Image $pdf -> Image($backgroundImage, $backgroundImageXPos, $backgroundImageYPos, $backgroundImageWidth, $backgroundImageHeight); //Plant Image (Dynamic from If Else) $pdf -> Image($image, $imageXPos, $imageYPos, $imageWidth, $imageHeight); //Image Desc Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '11'); $pdf -> SetXY($imageDescHeaderXPos, $imageDescHeaderYPos); $pdf -> Cell($imageDescHeaderWidth, $imageDescHeaderHeight, $imageDescHeader, 0, 0, 'L'); //Image Desc (Dynamic from If Else) $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($imageDescXPos, $imageDescYPos); $text = $imageDesc; $pdf -> WordWrap($text, $imageDescWidth); $pdf -> Write(10, $text); //Plant Names Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY(321, 228); $pdf -> Cell($plantNamesHeaderWidth, $plantNamesHeaderHeight, $plantNamesHeaderBot, 0, 0, 'L'); $pdf -> SetXY(321, 244); $pdf -> Cell($plantNamesHeaderWidth, $plantNamesHeaderHeight, $plantNamesHeaderCom, 0, 0, 'L'); //Plant Names $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(405, 228); $pdf -> Cell($plantNamesWidth, $plantNamesHeight, $botanicalName, 0, 0, 'L'); $pdf -> SetXY(405, 244); $pdf -> Cell($plantNamesWidth, $plantNamesHeight, $commonName, 0, 0, 'L'); //Plant Details Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY(321, 261); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $hardinessZonesHeader, 0, 0, 'L'); $pdf -> SetXY(321, 276); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $plantTypeHeader, 0, 0, 'L'); $pdf -> SetXY(321, 291); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $heightHeader, 0, 0, 'L'); $pdf -> SetXY(321, 306); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $spreadHeader, 0, 0, 'L'); $pdf -> SetXY(321, 321); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $flowerHeader, 0, 0, 'L'); $pdf -> SetXY(321, 336); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $bloomTimeHeader, 0, 0, 'L'); $pdf -> SetXY(321, 351); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $foliageHeader, 0, 0, 'L'); $pdf -> SetXY(321, 366); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $fallColorHeader, 0, 0, 'L'); $pdf -> SetXY(321, 381); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $fruitHeader, 0, 0, 'L'); $pdf -> SetXY(321, 396); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $barkHeader, 0, 0, 'L'); $pdf -> SetXY(321, 411); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $lightReqHeader, 0, 0, 'L'); $pdf -> SetXY(321, 426); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $soilHeader, 0, 0, 'L'); $pdf -> SetXY(321, 441); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $growthHeader, 0, 0, 'L'); //Plant Details $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(405, 261); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $hardinessZones, 0, 0, 'L'); $pdf -> SetXY(405, 276); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $plantType, 0, 0, 'L'); $pdf -> SetXY(405, 291); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $height, 0, 0, 'L'); $pdf -> SetXY(405, 306); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $spread, 0, 0, 'L'); $pdf -> SetXY(405, 321); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $flower, 0, 0, 'L'); $pdf -> SetXY(405, 336); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $bloomTime, 0, 0, 'L'); $pdf -> SetXY(405, 351); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $foliage, 0, 0, 'L'); $pdf -> SetXY(405, 366); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $fallColor, 0, 0, 'L'); $pdf -> SetXY(405, 381); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $fruit, 0, 0, 'L'); $pdf -> SetXY(405, 396); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $bark, 0, 0, 'L'); $pdf -> SetXY(405, 411); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $lightReq, 0, 0, 'L'); $pdf -> SetXY(405, 426); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $soil, 0, 0, 'L'); $pdf -> SetXY(405, 441); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $growth, 0, 0, 'L'); //Maintenance Info Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '11'); $pdf -> SetXY($maintenanceHeaderXPos, $maintenanceHeaderYPos); $pdf -> Cell($maintenanceHeaderWidth, $maintenanceHeaderHeight, $maintenanceHeader, 0, 0, 'L'); //Trimming Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY($trimmingHeaderXPos, $trimmingHeaderYPos); $pdf -> Cell($trimmingHeaderWidth, $trimmingHeaderHeight, $trimmingHeader, 0, 0, 'L'); //Trimming $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($trimmingTextXPos, $trimmingTextYPos); $text = $trimming; $pdf -> WordWrap($text, $trimmingTextWidth); $pdf -> Write(10, $text); //Fertilization Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY($fertilizationHeaderXPos, $fertilizationHeaderYPos); $pdf -> Cell($fertilizationHeaderWidth, $fertilizationHeaderHeight, $fertilizationHeader, 0, 0, 'L'); //Fertilization $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($fertilizationTextXPos, $fertilizationTextYPos); $text = $fertilization; $pdf -> WordWrap($text, $fertilizationTextWidth); $pdf -> Write(10, $text); //Other Maintenance Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY($otherHeaderXPos, $otherHeaderYPos); $pdf -> Cell($otherHeaderWidth, $otherHeaderHeight, $otherHeader, 0, 0, 'L'); //Other Maintenance $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($otherTextXPos, $otherTextYPos); $text = $otherMaintenance; $pdf -> WordWrap($text, $otherTextWidth); $pdf -> Write(10, $text); //Page Number Footer $pdf -> SetTextColor($footerTextColor[0], $footerTextColor[1], $footerTextColor[2]); $pdf -> SetFont('Arial', '', '8'); $pdf -> SetXY($pageNoXPos, $pageNoYPos); $pdf -> Cell($pageNoWidth, $pageNoHeight, $pageNo, 0, 0, 'R'); $pageNo++; } //OUTPUT PDF $pdf -> Output("$customerName.pdf", "I"); unset($_SESSION["book_array"]); unset($_SESSION["plantUse"]); unset($_SESSION["customerName"]); unset($_SESSION["customerAddress"]); unset($_SESSION["customerCity"]); unset($_SESSION["customerState"]); unset($_SESSION["customerZip"]); unset($_SESSION["customerPhone"]); unset($_SESSION["book_template"]); } elseif ($book_template = "2") { //////FLORAL BOOK STYLE/////////////////////////////////////////// //BUILD COVER PAGE ------------------------------------------- //BUILD TOC PAGE ------------------------------------------- //BUILD PLANT PAGES ------------------------------------------- } elseif ($book_template == "3") { //////NOTES BOOK STYLE/////////////////////////////////////////// //BUILD COVER PAGE ------------------------------------------- //BUILD TOC PAGE ------------------------------------------- //BUILD PLANT PAGES ------------------------------------------- } } ?>
  11. Hello freaks, I am using the FPDF class to generate PDF's on the fly, and I needed a way to generate multiline (flowing) text with specific widths. I found this FPDF extension function from FPDF's website, but can't seem to call it properly. I recieve an undefined function error! The function with in my script is as follows: <?php include_once "fpdf16/fpdf.php"; class PDF extends FPDF { function WordWrap(&$text, $maxwidth) { $text = trim($text); if ($text==='') return 0; $space = $this->GetStringWidth(' '); $lines = explode("\n", $text); $text = ''; $count = 0; foreach ($lines as $line) { $words = preg_split('/ +/', $line); $width = 0; foreach ($words as $word) { $wordwidth = $this->GetStringWidth($word); if ($wordwidth > $maxwidth) { // Word is too long, we cut it for($i=0; $i<strlen($word); $i++) { $wordwidth = $this->GetStringWidth(substr($word, $i, 1)); if($width + $wordwidth <= $maxwidth) { $width += $wordwidth; $text .= substr($word, $i, 1); } else { $width = $wordwidth; $text = rtrim($text)."\n".substr($word, $i, 1); $count++; } } } elseif($width + $wordwidth <= $maxwidth) { $width += $wordwidth + $space; $text .= $word.' '; } else { $width = $wordwidth + $space; $text = rtrim($text)."\n".$word.' '; $count++; } } $text = rtrim($text)."\n"; $count++; } $text = rtrim($text); return $count; } } ?> My call to this function with in my script is as follows: <?php $text = $useDesc1; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); ?> Does anyone have a reccommendations as to why this is happening? Thanks in advance.
  12. Yeah Kicken that was it, now I feel really dumb. Anyway thanks again. Kicken >= THE MAN!
  13. Can anyone help me with this, I have been working all day with no success. I am too new to php grasp this concept, sorry. Thanks in advance!
  14. Thanks Kicken, I believe I am on the right track after exploring the usort function. Below is what I have come up with thus far, but am still not getting the alphabetical ordered results as I wish. $bookArray = $_SESSION["book_array"]; function botanicalCmp ($a, $b) { if ($a['botanicalName'] == $b['botanicalName']) return 0; if ($a['botanicalName'] < $b['botanicalName']) return -1; return 1; } usort($bookArray, 'botanicalCmp'); Here is my entire output code, with a little more help I know I can get this, thanks in advance. <?php $bookOutput = ""; //$plant_use_array = ''; if (!isset($_SESSION["book_array"]) || count($_SESSION["book_array"]) < 1) { $bookOutput = '<tr><td colspan="4"><h6>Your Book is EMPTY!</h6></td></tr>'; } else { $bookArray = $_SESSION["book_array"]; function botanicalCmp ($a, $b) { if ($a['botanicalName'] == $b['botanicalName']) return 0; if ($a['botanicalName'] < $b['botanicalName']) return -1; return 1; } usort($bookArray, 'botanicalCmp'); // Start the For Each loop $i = 0; foreach ($_SESSION["book_array"] as $each_item) { $plantID = $each_item['plantID']; $botanicalName = $each_item['botanicalName']; $botanicalName = stripslashes($botanicalName); $commonName = $each_item['commonName']; $commonName = stripslashes($commonName); $use = $each_item['use']; //$x = $i + 1; // Dynamic table row assembly $bookOutput .= "<tr>"; $bookOutput .= '<td><a href="plant_details.php?plantID=' . $plantID . '" id="bodyLink">' . $botanicalName . '</a></td>'; $bookOutput .= '<td>' . $commonName . '</td>'; $bookOutput .= '<td><strong>' . $use . '</strong></td>'; $bookOutput .= '<td><form action="book.php" method="post"><input name="removeBtn" type="submit" value="Remove"/><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; $bookOutput .= '</tr>'; $i++; } } ?>
  15. Hi freaks, Got a simple one for ya, I THINK? I have a multi-array that resembles this.. $_SESSION["book_array"] = array(0 => array("plantID" => $plantID, "botanicalName" => $botanicalName, "commonName" => $commonName, "use" => $use)); I would like to sort it by the botanicalName key of the inner array before I call the forech loop that renders the display so that after it renders the table the items will be seen alphabetically, code below.. <?php $bookOutput = ""; //$plant_use_array = ''; if (!isset($_SESSION["book_array"]) || count($_SESSION["book_array"]) < 1) { $bookOutput = '<tr><td colspan="4"><h6>Your Book is EMPTY!</h6></td></tr>'; } else { // Start the For Each loop $i = 0; foreach ($_SESSION["book_array"] as $each_item) { $plantID = $each_item['plantID']; $botanicalName = $each_item['botanicalName']; $botanicalName = stripslashes($botanicalName); $commonName = $each_item['commonName']; $commonName = stripslashes($commonName); $use = $each_item['use']; //$x = $i + 1; // Dynamic table row assembly $bookOutput .= "<tr>"; $bookOutput .= '<td><a href="plant_details.php?plantID=' . $plantID . '" id="bodyLink">' . $botanicalName . '</a></td>'; $bookOutput .= '<td>' . $commonName . '</td>'; $bookOutput .= '<td><strong>' . $use . '</strong></td>'; $bookOutput .= '<td><form action="book.php" method="post"><input name="removeBtn" type="submit" value="Remove"/><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; $bookOutput .= '</tr>'; $i++; } } ?> Any help would be much appreciated! Thanks in advance.
  16. Thanks to you too Psycho! Everyone here has been so helpful, and it is much appreciated!
  17. Sasa >= THE MAN Thanks! I think it is working, as I only have three rows in my db as of now. Looks like i was missing some array logic. Thanks again.
  18. Yo ManiacDan, I like the split into three tables option! How do I put 1/3 of the results in one dataset, a 1/3 of the results in another, and 1/3 in another? Could you direct me to an example of such. Thanks!
  19. Hello freaks, Got a task here which is displaying correctly (I believe). I only have 3 data entries in the db right now. Like I said (I think) the display of the code below yields the right layout but it repeats the first db entry over and over. I got the display to work correctly like this: 1 2 3 4 5 6 7 8 9 I am trying to get this display result (so it is more eligable for the end user!) 1 4 7 2 5 8 3 6 9 Thanks in advance! CODE <?php include_once "connect_to_mysql.php"; $cols = 3; $result = mysql_query("SELECT plantID, botanicalName FROM plants ORDER BY botanicalName"); $numrows = mysql_num_rows($result); $rows_per_col = ceil($numrows / $cols); $c = 1; $r = 1; while ($row = mysql_fetch_array($result)) { $plantID = $row["plantID"]; $botanicalName = $row["botanicalName"]; if ($r == $rows_per_col) { $c++; $r = 1; } else { $r++; } } $dyn_table = '<table width="750" cellpadding="0" cellspacing="0" border="0">'; for ($r = 1; $r <= $rows_per_col; $r++) { $dyn_table .= '<tr>'; for ($c = 1; $c <= $cols; $c++) { $dyn_table .= '<td><a href="plant_details.php?plantID = ' . $plantID . '" id="plantLink">' . $botanicalName . '</a></td>'; } $dyn_table .= '</tr>'; } $dyn_table .= '</table>'; ?>
  20. Thank you ALL, When I switched the singles to doubles and all was well. I am pretty new to this, but am infinately better than when I started, thanks to these forums!
  21. Hello freaks, I am currently creating a member system that will place a default handle image into a newly registered members file. I have used the mkdir function create the directory successfully based on the members ID, but I can't get the copy function to work. Code: mkdir("memberFiles/$memberID", 0755); $old = 'images/defaultlogo.jpg'; $new = 'memberFiles/$memberID/logo.jpg'; copy($old, $new); Error Message: Warning: copy(memberFiles/$memberID/logo.jpg) [function.copy]: failed to open stream: No such file or directory Lastly, this folder is created to store members files.
  22. Hi all, I have been running into a couple of errors messages that I have not been able to debug (below): 1. Undefined var Use1 2. mysql_num_rows(): supplied argument is not a valid MySQL result resource My code is as follows: <?php // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php $results = ""; if(isset($_GET['PlantID'])) { include_once "scripts/connect_to_mysql.php"; $PlantID = $_GET['PlantID']; $sql = mysql_query("SELECT * FROM plants WHERE PlantID='$PlantID'"); $plantCount = mysql_num_rows($sql); if($plantCount > 0) { while ($row = mysql_fetch_assoc($sql)) { $PlantID = $row["PlantID"]; $BotanicalName = $row["BotanicalName"]; $CommonName = $row["CommonName"]; $HardinessZones = $row["HardinessZones"]; $Type = $row["Type"]; $Height = $row["Height"]; $Spread = $row["Spread"]; $Flower = $row["Flower"]; $BloomTime = $row["BloomTime"]; $Foliage = $row["Foliage"]; $FallColor = $row["FallColor"]; $Fruit = $row["Fruit"]; $Light = $row["Light"]; $Soil = $row["Soil"]; $Growth = $row["Growth"]; $Trimming = $row["Trimming"]; $Fertilization = $row["Fertilization"]; $OtherMaintenance = $row["OtherMaintenance"]; $Use1 = $row["Use1"]; $Use2 = $row["Use2"]; $Use3 = $row["Use3"]; $Use4 = $row["Use4"]; $Use5 = $row["Use5"]; $UseDesc1 = $row["UseDesc1"]; $UseDesc2 = $row["UseDesc2"]; $UseDesc3 = $row["UseDesc3"]; $UseDesc4 = $row["UseDesc4"]; $UseDesc5 = $row["UseDesc5"]; $Image1 = $row["Image1"]; $Image2 = $row["Image2"]; $Image3 = $row["Image3"]; $Image4 = $row["Image4"]; $Image5 = $row["Image5"]; $ImageDesc1 = $row["ImageDesc1"]; $ImageDesc2 = $row["ImageDesc2"]; $ImageDesc3 = $row["ImageDesc3"]; $ImageDesc4 = $row["ImageDesc4"]; $ImageDesc5 = $row["ImageDesc5"]; } } else { $results = "<h1>No Data to Run this Page!</h1>"; } } ?> <?php session_start(); // See if they are a logged in member by checking Session data $toplinks = ""; $booklinks = ""; if (isset($_SESSION['memberID'])) { $memberID = $_SESSION['memberID']; $username = $_SESSION['username']; $toplinks = '<a href="memberaccount.php?id=' . $memberID . '">Welcome, ' . $username . '!</a> | <a href="memberaccount.php?id=' . $memberID . '">My Account</a> | <a href="book.php">Your Plant Book</a> | <a href="logout.php">Log Out</a>'; $booklinks = '<form name="add_to_book" method="post" action="plantdetails.php"> <input name="memberID" type="hidden" value="' . $memberID . '" /> <input name="PlantID" type="hidden" value="' . $PlantID . '" /> <input name="BotanicalName" type="hidden" value="' . $BotanicalName . '" /> <input name="CommonName" type="hidden" value="' . $CommonName . '" /> <input name="Use" type="hidden" value="' . $Use1 . '" /> <input name="add_to_book_btn" type="submit" value="Add ' . $BotanicalName . ' (' . $Use1 . ') to Your Book!" /> </form>'; } else { $toplinks = '<a href="join.php">Join Now</a> | <a href="login.php">Login</a>'; $booklinks = '<h1>You must be logged in to Add Plant Pages and Create Plant Books! <img src="images/AddtoBook.gif" border="0" /></h1>'; } ?> <?php $errorMsg = ""; if(isset($_POST['memberID'])) { include_once "scripts/connect_to_mysql.php"; $memberIDtemp = $_POST['memberID']; $PlantID = $_POST['PlantID']; $BotanicalName = $_POST['BotanicalName']; $CommonName = $_POST['CommonName']; $Use = $_POST['Use']; $sqlCheck = mysql_query("SELECT * FROM book_temp WHERE PlantID='$PlantID' AND Use='$Use'"); $plantCountCheck = mysql_num_rows($sqlCheck); if($plantCountCheck > 0) { $errorMsg = "<h1>This Plant and Landscape Use is already in Your Book! Please select another Plant or Landscape Use.</h1>"; } else { mysql_query("INSERT INTO book_temp (memberID, PlantID, BotanicalName, CommonName, Use) VALUES ('$memberIDtemp', '$PlantID', '$BotanicalName', '$CommonName', '$Use')"); header("location: book.php"); exit(); } } ?> The particular errors are on the following lines: <input name="Use" type="hidden" value="' . $Use1 . '" /> <input name="add_to_book_btn" type="submit" value="Add ' . $BotanicalName . ' (' . $Use1 . ') to Your Book!" /> $plantCountCheck = mysql_num_rows($sqlCheck); Any help would be superb, Thanks in advance! Bill C.
  23. Hi Zurev, I tried the LIKE statement as you described and still no success, again here is my SQL to this point. $sql = mysql_query("SELECT PlantID, CommonName FROM plants WHERE BotanicalName LIKE '%$BotanicalName%' OR CommonName LIKE '%$CommonName%' OR Use1='$Use' OR Use2='$Use' OR Use3='$Use' OR Use4='$Use' OR Use5='$Use' ORDER BY CommonName"); This sql statement now returns ALL the fields in the database when searching for anything. Thanks, again.
  24. Hi gents, This will be an easy one for you all! I have a sql select statement and everything functions fine as is, BUT I would like to give users more freedom. Using this sql statement the results only return if the user types the Botanical Name or Common Name of a particular plant exactly as it is spelled in the database: $sql = mysql_query("SELECT PlantID, CommonName FROM plants WHERE BotanicalName='$BotanicalName' OR CommonName='$CommonName' OR Use1='$Use' OR Use2='$Use' OR Use3='$Use' OR Use4='$Use' OR Use5='$Use' ORDER BY CommonName"); What if the user doesn't know the species of a plant and only it's genus or the user only knows Maple tree and not which particular one they are looking for: For example: Plant in Database = Brandywine Red Maple User Search would have to be exactly that "Brandywine Red Maple" for a result to return Ideally I would like the user to be able to type in "Maple" and ALL Maples return Let me know if you need more info
  25. Hi, I have successfully implemented a master details page with the results aligned in columns linking to a details page. I wish to maintain the recordID passed from the master details page and make the dynamic text, which reads Shade A tree that is capable of..... in the attached screen shot a link to another details page referencing the same recordID. The detailspage2.php would look the same as the screenshot except the Shade text and description below will be highlighted, which I can do, there will be a new image and a new image description. All other dynmaic elements on the page will remain the same. I tried to simply save as my detailspage.php to detailspage2.php and create a link to detailspage2.php. It linked to detailspage2.php but none of the record info showed up in their respective table cells. I have all the names desc's, images, etc setup in a table in my database. Please let me know what code and other info you need to help me out with this procedure. Thanks. [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.