Jump to content

robgood

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

robgood's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, just started to try and get my head round oop and am getting a bit confused. Have set up a display method which is basically a template for all my html and menus. The display method, in turn, makes a call to DisplayLeftContent(). DisplayLeftContent() outputs a sub menu, some html etc and also $this->leftcontentforpage if it has been set. This works fine until I tried to set the left content using another method from another class. So i have my basic layout working and decide that i want to set the leftcontent to display a table of any new orders that have come in. (see class order below). So i created a GetAllOrders() method below to pull the info from the database and used it in my script to set the left content. Now the method does its job and outputs the data, but it does not add it to the corrrect position on the page. It just ouputs the data at the top of the page, before all the other html, and pushes the rest of the site down. Now if i return the data instead of echoing it inserts into the right place but only returns the first row of the table. I'm guessing it's something to do with assinging multiple echo statments to the $leftcontentforpage attribute. Hope someone can set me on the right path on this one? When i want to My page script <?php session_start(); require('lib/class_lib.php'); $neworders = new order(); $page = new page('Orders'); $page->leftcontentforpage = $neworders->GetAllOrders(3); $page->Display(); ?> I have only left in the relevant code to the problem. My Class library class page { var $leftcontentforpage; public function DisplayLeftContent() { echo '<div id="leftnav">'; echo '<img src="images/'.$this->currentpage.'header.jpg">'; $this->DisplaySubMenu(); echo "$this->leftcontentforpage"; echo '</div>'; } public function DisplayLeftContent() { echo '<div id="leftnav">'; echo '<img src="images/'.$this->currentpage.'header.jpg">'; $this->DisplaySubMenu(); echo "$this->leftcontentforpage"; echo '</div>'; } } class order { var $orderstatus; public function GetAllOrders($orderstatus) { $this->orderstatus = $orderstatus; $dbh = new PDO('mysql:host=111.111.111.111;dbname=mydbname', username, password); $sql = "SELECT id, surname, deliverydate FROM buyer, orders WHERE id=buyerid AND orderstatus=$this->orderstatus"; foreach($dbh->query($sql) as $row) { $id = $row['id']; $surname = $row['surname']; $deliverydate = $row['deliverydate']; $orderstatus = $row['orderstatus']; echo "<tr><td>$id</td><td>$surname</td><td>$deliverydate</td><td><a href='exploreorder.php?orderid=$id'><img src='images/anyclues.png'/></a></td></tr>"; } } }
  2. Solved, basically the i was getting un-serialized data from the api which i presumed was an array. I got the serialized resource instead and did following $timetotals = unserialize(trim($timetotals));
  3. Getting un-serialised PHP from a API use http GET $timetotals = file_get_contents($timetotals); the results when print_r($timetotals) gives... Array ( [0] => Array ( [value] => 5880 ) ) I am trying to extract the number 5880 into a variable $value have tried lots of things including below...but can't seem to get it work foreach($timetotals as $key =>$array) { foreach($array as $secondkey=>$value) { echo "<p>$value</p>"; } } Any help would be appreciated
  4. Hi everyone. Hope you can help. I have two arrays e.g. $1st = array('1string','2string','3string','4string','5string','6string'); $2nd = array('value1','value2','value3','value4','value5','value6'); I would like to use these two arrays to create a single associative array. e.g. $associative = array('1string'=>'value1','2string'=>'value2','3string'=>'value3','4string'=>'value4','5string'=>'value5','6string'=>'value6'); any help would be most appreciated :-)
  5. thanks, i have no clues about ajax so i am going to go with the meta refresh to another page option, as it's a multi purpose page, so presumably it would delay the page loading for each action, rather than just the last step. It's a series of forms.
  6. looks alright to me. ever considered using jquery thickbox? http://jquery.com/demo/thickbox/
  7. hi, I am looking to delay a script from running for about 8 seconds and display an animated gift load image while the delay is running. This is just for a bit of fun really to give the illusion that something is processing in the background . Is there any way in php to do this?
  8. Just in case anyone else finds this post and has the same problem I used impolde() on array and passed in form and then explode() to change back into array on receiving page. Use serialize() and unserialize() for multidimensional arrays. good link here - http://www.faqts.com/knowledge_base/view.phtml/aid/119
  9. just tried it and it didn't work....I mean between two different websites (www.mywebsite1.com and www.my-secure-payment-page-on-another-url.com)? Want to pass the contents of the basket to this page. Obviously easier to do in a sessions rather than sending in a hidden form field? Basically, it's is my webhosts shared secured ssl page. Thanks for your help.
  10. Hi, just a quick question. Can i use sessions to send values between two different URL's or will i have to send variables across in a form? thanks for your help
  11. I'm using PHP Version 5.2.2 on Windows/apache on my local computer and my remote host is using PHP Version 4.4.1 on linux/apache. here is session output for sessions on remote: Session Support enabled Registered save handlers files user Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 100 100 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /home/phpsessions /home/phpsessions session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid Off Off
  12. I was in exactly your position about 4 months ago.... I have a total of 5 php and mysql books. The one i'd definitely would go for is "Build your own database driven website using PHP & Mysql 3rd edition' by kevin yank (sitepoint.com). Although it's far from comprehensive, it will explain, in easy to understand language, how to build a e-commerce site including CMS and simple shopping cart (It dosen't explain anything else). You can directly use the examples in the book for your own site. After that, id recommend 'PHP 5 and MYSQL Bible' or 'PHP and MYSQL web development third edition.' The kevin yank book will get you up and running quickly and you can use forums to fill in the gaps! good luck
  13. Strange, as it works on my local machine. The addons stay in the basket where as on remote version they disappear when the page is refreshed or you navigate away from basket page and then back to it. Really racking my brains. anymore ideas ???
  14. and here is the form that submits the data if it helps <form action="basket.php" method="post"> <?php $addon = @mysql_query("SELECT DISTINCT id, refnum, name FROM addon, addonsubmenucat WHERE id=addonid AND catid=2 LIMIT 0, 4"); while ($addons = mysql_fetch_array($addon)) { $addonid = $addons['id']; $addonname = $addons['name']; $addonrefnum = $addons['refnum']; echo "<label>$addonname</label><input type='checkbox' name='addon[]' value='$addonid'>\n"; } ?> <?php $addon = @mysql_query("SELECT DISTINCT id, refnum FROM addon, addonsubmenucat WHERE id=addonid AND catid=2 LIMIT 0, 4"); while ($addons = mysql_fetch_array($addon)) { $addonrefnum = $addons['refnum']; echo "<td align='center'><img src='thumbnailpictures/$addonrefnum.gif'>\n"; } ?> <input type="hidden" name="bid" value="<?php echo "$id" ;?>" /> <input type="submit" id="buybutton" value="Add to basket" /> thanks
×
×
  • 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.