Jump to content

seadonkey

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

seadonkey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello there, I am trying to recreate a HTML website on a WordPress website. On the current website we pull a php file from the directory that lists brands for different catrogies. http://www.nongmosho...d-and-seed.html We use the following script <!--?php <br ?--> <?php include('../lib/IphoneDataRenderer.php');?> <?php echo $IphoneDataRenderer->getAdsForBrandId();?> <!--?php } ?--> <?php $IphoneDataRenderer listBrandsForCategory(); ?> and it works fine for the website above. However, when I add this code within our WP website we don't get any information (I did add the /lib/iphoneDataRenderer.php files and folders). Please message me your rate and any questions you have and I'll be in touch. The php file I am pulling contains the following code: <?php include('../lib/IphoneService.php'); include('../brands/config.php'); define('AD_FOLDER', $_SERVER['DOCUMENT_ROOT'] . "/brands/logos/" ); class IphoneDataRenderer { private $showOnlyVerified = true; public $categoryIdByPageArray; public function IphoneDataRenderer() { /* $categoryArray = array(); $categories = $service->getProdCategories(); foreach ($categories as $category) { $categoryArray[$category->id] = $category->name; */ $this->categoryIdByPageArray = array( '/brands/alternative-dairy-products.html' => 1, '/brands/baby-food-and-infant-formula.html' => 2, '/brands/beverages.html' => 3, '/brands/body-care-products.html' => 4, '/brands/breads-and-baked-good.html' => 5, '/brands/candy-chocolate-and-sweeteners.html' => 6, '/brands/cereal-and-breakfast-foods.html' => 7, '/brands/condiments-oils-dressings-and-spreads.html' => 8, '/brands/dairy-products.html' => 9, '/brands/feed-and-seed.html' => 10, '/brands/fruits-and-vegetables.html' => 13, '/brands/grains-beans-and-flour.html' => 15, '/brands/herbs-spices-and-other-ingredients.html' => 16, '/brands/meat-fish-and-eggs.html' => 17, '/brands/mercantile.html' => 18, '/brands/packaged-frozen-meals.html' => 19, '/brands/pasta.html' => 20, '/brands/pet-products.html' => 21, '/brands/snack-foods-and-bars.html' => 22, '/brands/soups-and-sauces.html' => 23, '/brands/tofu-tempeh-and-alternative-meat-products.html' => 24, '/brands/vitamins-and-supplements.html' => 25, '/brands/wholesale-ingredients.html' => 26 ); } private function stripUnverified($productList) { $returnArray = array(); foreach($productList as $product) { if ($product->pVerified == 1) array_push($returnArray, $product); } return $returnArray; } public function getAllProductsForBrandId() { $service = new IphoneService(); if (isset($_GET['bid'])) { $brandId = $_GET['bid']; $productList = $service->GetProducts('', $brandId); if ($this->showOnlyVerified) $productList = $this->stripUnverified($productList); return $productList; } else { return array(); } } /* * This function determines the proper category by looking at the name of * the file that is including it. A little brittle, but better than having to * change 20 files each time. */ public function listBrandsForCategory() { $service = new IphoneService(); if (isset($this->categoryIdByPageArray[$_SERVER['PHP_SELF']])) { $categoryId = $this->categoryIdByPageArray[$_SERVER['PHP_SELF']]; if (isset($_GET['bid']) && is_numeric($_GET['bid'])) { $brandId = $_GET['bid']; $productList = $service->GetProducts($categoryId, $brandId); // the service appears to do an "or" rather than an "and". $resultList = array(); foreach($productList as $product) { if (($product->brandID == $brandId) && ($product->catID == $categoryId)) array_push($resultList, $product); } $this->renderProductList($resultList, true); } else { $productsByCatId = $service->GetProducts($categoryId); $brandArray = array(); foreach($productsByCatId as $product) { if (!isset($brandArray[$product->brandID])) { $brandArray[$product->brandID] = new Brand($product->brandID, $product->brandName, $product->brandLogo, $product->catID); } } // we're going to assume that there's a "sort by name" on the remote service. $this->renderBrandList($brandArray); } } else { echo "<!-- I don't know what category to display. Please see /lib/IphoneDataRenderer.php. -->"; } } public function getAdsForBrandId($brandId = '', $brandName = '') { if ($brandId == '') { // then get from GET parameter if (isset($_GET['bid']) && is_numeric($_GET['bid'])) { $brandId = $_GET['bid']; } } global $brandLinkArray; $logoLink = ''; if (isset($brandLinkArray[$brandId])) { $logoLink = $brandLinkArray[$brandId]; $logoFile = AD_FOLDER . "$brandId.jpg"; if (file_exists($logoFile)) { return "<a href='$logoLink' title='$brandName' target='_new'><img src='/brands/logos/$brandId.jpg' alt='$brandName' style='margin-top: 8px;' border='0' /></a>"; } } } public function renderProductList($products, $limitByCat = false) { global $brandLinkArray; if (count($products) < 1) { echo "No products for this brand and category."; return; } $sample = $products[0]; if ($limitByCat) { $linkToProductPage = "/brands/all-products-for-brand.html?bid={$sample->brandID}"; $logoLink = $linkToProductPage; if (isset($brandLinkArray[$sample->brandID])) { $logoLink = $brandLinkArray[$sample->brandID]; } echo "<a href='$logoLink' title='{$sample->brandName}' target='_new'>"; echo "<img src='{$sample->brandLogo}' alt='{$sample->brandName}' width='130' border='0' style='float: left; margin-right: 15px;'>"; echo "</a>"; echo "<h2 style='margin: 0; color: #414F26;'>$sample->brandName</h2>"; echo "<h3 style='margin:5px 0 0 0;'><a href='$linkToProductPage' title='{$sample->brandName}'>Show all products from "; echo "{$sample->brandName}</a></h3>"; echo "« <a href='javascript: history.back();'>Back</a></h3><br/>"; } else { echo "<h3 style='margin: 0; color: #414F26;'>Showing all products</h3>"; echo "<h3 style='margin:5px 0 0 0;'>« <a href='javascript: history.back();'>Back</a></h3>"; } echo "<ul class='prodlist' style='list-style: none; clear: both;'>"; $i = 0; foreach($products as $product) { if (!$this->showOnlyVerified || ($product->pVerified == 1)) { $i++; echo "<li style='line-height: 24px; vertical-align: middle; margin-bottom: 4px;'>"; if ($product->pVerified == 1) echo "<a href='http://www.nongmoproject.org/consumers/understanding-our-seal/' title='This product has been verified. Click for more information.'><img src='/images/bullet-verified.gif' alt='Verified' style='vertical-align: top; margin-right: 5px;' border='0'/></a>"; echo $product->name; echo "</li>"; } } if ($i == 0) echo "<li>There are no products that have been verified at this time, though some products are enrolled in the Product Verification Program and may be verified soon. Please check back!</li>"; echo "</ul>"; } public function renderBrandList($brands) { if (count($brands) < 1) { echo "No brands for this category."; return; } //echo "<table cellpadding=10>"; echo "<ul>"; foreach($brands as $brand) { $link = "?bid={$brand->id}"; echo "<li>"; echo "<a href='$link' title='See all products for this brand'>{$brand->name}</a>"; echo "</li>"; //echo "<tr>"; //echo "<td><a href='$link' title='See all products for this brand'><img src='{$brand->logo}' alt='{$brand->name}' border='0' /></a></td>"; //echo "<td><a href='$link' title='See all products for this brand'>{$brand->name}</a></td>"; //echo "</tr>"; } //echo "</table>"; echo "</ul>"; } public function showDescription() { if (isset($_GET['bid']) && is_numeric($_GET['bid'])) { return false; } else { return true; } } public function renderKey() { if (isset($_GET['bid']) && is_numeric($_GET['bid'])) { ?> <img src="/images/bullet-verified.gif"> Indicates that the product has been verified as fully compliant to the Non-GMO Project Standard. For more information please <a href="../non-gmo-project-seal.html">click here.</a> <p>If a product you like is not listed here, feel free to <a href="http://www.nongmoproject.org/take-action/make-a-product-verification-request/" target="_blank">request product verification</a>. Your request will be sent to the company to let them know you would like to see that product verified as Non-GMO. </p> <?php } else { ?> The brands featured above are enrolled in the the Non-GMO Project Standard. <br /> For more information please <a href="../non-gmo-project-enrollment.html" >click here.</a> <p>If a product you like is not listed here, feel free to <a href="http://www.nongmoproject.org/take-action/make-a-product-verification-request/" target="_blank">request product verification</a>. Your request will be sent to the company to let them know you would like to see that product verified as Non-GMO. </p> <?php } } } class Brand { public $id; public $name; public $logo; public $catId; public function Brand($id, $name, $logo, $catId) { $this->id = $id; $this->name = $name; $this->logo = $logo; // possibly not really needed $this->catId = $catId; } } $IphoneDataRenderer = new IphoneDataRenderer(); ?>
  2. Thanks Warlock, I did a few brief Google search and didn't find anything too clear. Have you developed/included custom php files in WP before? I'm willing to pay a developer to complete this task. Many thanks
  3. Sorry the correct URL is: http://www.nongmoshoppingguide.com/brands/feed-and-seed.html
  4. Hello there, I am trying to recreate a HTML website on a WordPress website. On the current website we pull a php file from the directory that lists brands for different catrogies. http://www.nongmoshoppingguide.com/brands/feed-and-seed.html We use the following script <!--?php <br ?--> <?php include('../lib/IphoneDataRenderer.php');?> <?php echo $IphoneDataRenderer->getAdsForBrandId();?> <!--?php } ?--> <?php $IphoneDataRenderer listBrandsForCategory(); ?> and it works fine for the website above. However, when I add this code within our WP website we don't get any information (I did add the /lib/iphoneDataRenderer.php files and folders). Could you help me understand what I am doing wrong? Many thanks!
  5. This is just a front end very basic hit counter I am working on <?php class HitCounter { /* $fileName - the name of the text file that contains the current number of hits.*/ private $fileName = ""; /* This construct holds the text file that contains the number of hits*/ function __construct($file) { $this->fileName = $file; } /*reads the contents of the text file specified in $fileName and returns the value*/ public function getCounter() { $newValue = $this.getCounter(); $newValue++; } /*this will add the number to the file */ public function setCounter($counter) { file_put_contents($fileName, $counter); } /*This will get the current counter numbe rand will updated it for each new hit it gets. */ public function updateCounter() { $this->getCounter(); $this->setCounter($newValue); } } ?> When I try to run it I am getting Fatal error: Call to undefined function getcounter() in /home/academyw/public_html/rudolph/lab12/HitCounterClass.php on line 16 and was wondering if you could point me in the right direction or see what I am doing wrong.
  6. I am looking for tutorials/key words to search for, for this project. What I am finding is guestbooks that have full database/sql. I simply just want a basic 101 to php guestbook that just shows the new programmer the basics of arrays and files and was wondering if anyone happened to know of a good tutorial/line of code that would point me in the right direction. Thanks What I would like to learn to do is create a web site to register users for an event. There will be a form that will allow a user to enter first name, last name, and email address and link to a page that will display all the registrants.
  7. What I am working on is making a guest book to where I write the valuables(name/last/email) to the guest list if it does not exist yet. My problem is with getting the information into the guest book to write. For the sort, instead of using fopen and fgets, use file() to read the whole file into an array, say $GuestBookArray. Then you can sort by saying sort($GuestBookArray); Then use a for loop to loop through the array and print the elements. As a noobie I am trying to figure out how to understand the file function and how to do this. it should be file(filename[, use_include_path]) so for this part would it look like file(guestbook.txt. , "a"[, use_include_path]) (would the include path be the $GuestBookArray? Then the loop part is tossing me for a loop. ??? Any suggestions would be great
  8. I am getting 4 warning messages about this Warning: Wrong parameter count for fwrite() in /home/academyw/public_html/rudolph/SignTheGuestBook.php on line 33 Warning: sort() expects parameter 1 to be array, resource given in /home/academyw/public_html/rudolph/SignTheGuestBook.php on line 38 Warning: fwrite(): 3 is not a valid stream resource in /home/academyw/public_html/rudolph/SignTheGuestBook.php on line 40 Warning: fclose(): 3 is not a valid stream resource in /home/academyw/public_html/rudolph/SignTheGuestBook.php on line 43 <?php $NameExists =FALSE; if (file_exists("guest_book.txt") && filesize("guest_book.txt")> 0) { $GuestArray =file("guest_book.txt"); for($i=0; $i<count($GuestArray); ++$i){ $CurMessage = explode("~", $GuestArray[$i]); if(in_array(addslashes($LastName), $CurMessage)){ $NameExists =true; break; } } } if($NameExists) echo "<p>That name currently exists, please try again!</p>"; else { $GuestBook =fopen ("guest_book.txt" , "a"); fwrite($GuestBook); fclose ($GuestBook); stripslashes($Name) . " <br />"; stripslashes($LastName) . " <br />"; stripslashes($Email) . " <br />"; sort($GuestBook, SORT_STRING); if (is_writable("guest_book.txt")) { if (fwrite( $GuestBook, $Name . "," . $LastName . ",". $Email . "\n")) echo "<p>Thank you for signing our guest book! </p>"; fclose($GuestBook); } } ?> What I am trying to do is check to see if the user already enter in his/her name, to delete dup names and to sort names. Any suggestions on what is wrong would be great
  9. Array ( [0] => dfd,dfd,dfdd [1] => rudolph,michelle,testemail!@yahoo.com [2] => day,amy,sdfds [3] => as,day,ere [4] => as,day,ere [5] => test,test,test [6] => test,test,test [7] => cc,cc,cc [8] => cc,cc,cc ) so its still seeing the repeats
  10. More or less I am unable to figure out the proper code for using an array to create a guest book. What I need to do is not allow the same name to be used again and that sorts the book by name and removes duplicate names. I went to http://us.php.net/array_unique and did read up on it and tried to put it to the test. A sample of what I have come with so far with an array for this is // Collect information $FirstName = addslashes($_GET['first_name']); $LastName = addslashes($_GET['last_name']); $Email = addslashes($_GET['email_address']); // Load file into Array $GuestFile = file('guest_book.txt'); // Remove duplicates $GuestFile = array_unique($GuestFile); // Sort the collect information area sort($GuestFile, SORT_STRING); // Open the guest book to write too $GuestBook =fopen ("guest_book.txt","a"); The whole script does work but the problem is that it is not removing the dup and is sorting my the last name, not the first. Any sugguestions would be great.
  11. gotcha, I knew it was something very simple however there is also a problem with my foreach <?php $Count = 0; while ($Count < 100){ $Numbers[] = $Count; ++$Count; foreach ($Count as $CurNum) echo"<p>$CurNum</p>"; } ?> I am getting a Invalid argument supplied for foreach() I am assuming I am getting that error because I attempting to us a foreach with $CurNum that is not an array? Or have I completely missed the boat.
  12. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>While Logic</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $Count = 0; while ($Count > 100){ $Numbers[] = $Count; ++$Count; foreach ($Count as $CurNum) echo"<p>$CurNum</p>"; ?> </body> </html> I am unable to debug an error that is looking me in the face. Its a simple print the numbers 1-100 as long as the number is above zero.
×
×
  • 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.