Jump to content
Larry Ullman's Book Forums

1cookie

Members
  • Posts

    24
  • Joined

  • Last visited

1cookie's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. No, there is no mention of edit_page.page but, like I said edit_page.php IS mentioned. From page 311: <h1><span><?php echo $page-> getDateAdded(); ?></span><?php echo $page->getTitle(); ?></h1> <?php echo $page->getContent(); ?> <?php if ($user && $user-> canEditPage($page)) { echo '<p><a href="edit_page. php?id='. $page->getId() . '">EDIT</a></p>'; } ?> and from the scripts: <!-- # page.html - Script 9.10 --> <section class="fullWidth"> <article> <h1><span><?php echo $page->getDateAdded(); ?></span><?php echo $page->getTitle(); ?></h1> <?php echo $page->getContent(); ?> <?php if ($user && $user->canEditPage($page)) { echo '<p><a href="edit_page.php?id=' . $page->getId() . '">EDIT</a></p>'; } ?> </article> </section> Last time I checked, it *wasn't* there!
  2. hi And thanks for the great book. Is it me, or is the edit_page.php file missing from the Chapter 9 scripts?
  3. You're right, it's staring me right in the face. URL params is a better way me thinks. Do you mean like a bootstrap (index.php) file for instance? Similar to: if (isset($_GET['p'])) { $p = $_GET['p']; } elseif (isset($_POST['p'])) { // Forms $p = $_POST['p']; } else { $p = NULL; } switch ($p) { case 'price': $page = new Price; break; case 'size': $page = new Size; break; case 'colour': $page = new Colour; break; default: $page = new Main; break; } // switch. if (!is_object( $page)) { $page = new Main; } include('./includes/header.html'); $page->load(); include('./includes/footer.html'); as an example. looking at the larger websites, they use URLs like: http://www.example.com/men/jeans#catalogId=10001&lid=//productsuniverse/en_GB/product_online%3DY/categories%3C{productsuniverse_18664}/categories%3C{productsuniverse_18664_18546}/categories%3C{productsuniverse_18664_18546_18551_ms}&ps=default&sfn=CATEGORIES&sfv=Bootcut&storeId=10001 Just for the record, I'm not looking to code the next Magento site here (I'm not nearly clever enough), it's the small scale stuff that I'm learing with to start with. That sounds interesting, I look forward to that. I'm doing this in my spare time in between work hours so forgive the pauses; although its going around in my head most of the time . For the URLs - If we were talking about frameworks we'd be talking about routes no doubt. I'm not looking to implement a framework though. I am looking to code it as a collection of objects or OOP however.
  4. thanks. Yes, I could scratch the prices table maybe you have a point. A price should be in the Product table. I'm more comfortable with the singular term 'Product' as opposed to 'Products'. I'm going to stick with categories and products as separate entities. One category can have multiple products and a single product belongs in one category: one to many. Not sure about stock yet, mulling that over. For me I really want to be able to search on: category, designer, price, size and colour and so am torn between the stored procedure call and database model. My Stored Procedure SP may be similar to: DELIMITER $$ CREATE PROCEDURE select_products(type VARCHAR(40), cat TINYINT) BEGIN IF type = 'category' THEN SELECT ... FROM product AS p INNER JOIN category AS c ON p.id=c.category_id WHERE c.category_id=cat AND stock>0 ORDER by name ASC; ELSEIF type = 'designer' THEN SELECT FROM product AS p INNER JOIN designer AS d ON p.id=d.designer_id WHERE designer_id=cat AND stock>0 ORDER by date_created DESC; ELSEIF type = 'colour' THEN SELECT FROM product AS p INNER JOIN colour AS col ON p.id=col.colour_id WHERE colour_id=cat AND stock>0 ORDER by DESC; ELSEIF type = 'size' THEN ... END IF; END$$ DELIMITER ; unchecked draft of course. I would then have multiple forms in the front end to get the users interaction, filtering my SP results by any of the variables mentioned. <select name="price"> <option value="19.99">19.99</option> <option value="29.99">29.99</option> <option value="39.99">39.99</option> <option value="49.99">49.99</option> </select> <select name="colour"> <option value="red">red</option> <option value="stonewash">stonewash</option> <option value="tan">tan</option> </select> <select name="size"> <option value="32L">32L</option> <option value="33M">33M</option> <option value="34S">34S</option> </select> This is just off the top of my head. Good comments so far; thanks again for the help.
  5. Indeed. And I acknowlege that. That's the idea of open source you share ideas collaboratively. I didn't say I'm struggling to understand or didn't get something. Although examples in the book are pretty rigorous from the start they're well taught by the author. That's not to say they couldn't become more difficult pretty quickly. For instance, in my denim jeanshop example, my revised products table may look like: -- ----------------------------------------------------- -- Table `default_schema`.`products` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `default_schema`.`products` ( `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT , `category_id` TINYINT(3) UNSIGNED NOT NULL , `size_id` TINYINT(3) UNSIGNED NOT NULL , `colour_id` TINYINT(3) UNSIGNED NOT NULL , `designer_id` TINYINT(3) UNSIGNED NOT NULL , `price_id` TINYINT(3) UNSIGNED NOT NULL , `name` VARCHAR(60) NOT NULL , `description` TINYTEXT NULL DEFAULT NULL , `image` VARCHAR(45) NOT NULL , `price` DECIMAL(5,2) UNSIGNED NOT NULL , `stock` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' , `date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `categories_id` TINYINT(3) UNSIGNED NOT NULL , `designers_id` TINYINT(3) UNSIGNED NOT NULL , `prices_id` TINYINT(3) UNSIGNED NOT NULL , PRIMARY KEY (`id`) , INDEX `category_id` (`category_id` ASC) , INDEX `fk_products_categories` (`categories_id` ASC) , INDEX `fk_products_designers1` (`designers_id` ASC) , INDEX `fk_products_prices1` (`prices_id` ASC) ) ENGINE = MyISAM DEFAULT CHARACTER SET = utf8; as you can see, we have a lot more foreign keys here for starters. This would make the stored procedures more complex for sure. But alas I'm not trying to get into a flex your muscles dialogue here, more peoples opinions or insights really.
  6. hi Interesting book especially the stored procedures. I'd be interested to hear from anyone who is interested in extending or generalising the database; thus creating more variables to search upon. After all, not all of us want to sell coffee do we? I'm especially interested in filters or searching by specific categories see: http://acookson.org/wp-content/uploads/2013/01/shop-screenshot.png for an example of what's on my mind. In my fictitional jeans shop example, I was playing around with MySQL workbench to come up with some possibilities for an ER diagram: http://acookson.org/wp-content/uploads/2013/01/ecommerce3.png It's totally at prototype stage and was looking for some inspiration really; maybe an on-going discussion around this topic. best wishes Andrew
  7. It's a SELECT... UNION...SELECT query (procedure) You only have to define sku 'once' hence the omission.
  8. Boolean given - you passed FALSE (more likely NULL) into the stored procedure (query) when you should have passed a mysqli_result. Check the stored procedure for syntax errors.
  9. If your using Linux, I found this to be a very good tutorial: https://www.linux.com/learn/tutorials/392099:creating-self-signed-ssl-certificates-for-apache-on-linux
  10. thanks. What I have learnt is that if you want SSL encryption on ones localhost machine then it's going to involve creating your own digital certificates.
  11. Indeed, that's my understanding. I'm using WAMP, but have access to Ubuntu (LAMP) also. sure...
  12. hi I'm just at page 282, chapter 10. Now you can test the checkout.php process. If you fill out the form incorrectly, it will be displayed again (Figure 10.13). If you fill it out correctly, you'll be sent to billing.php, which will be written next. I can't get to checkout.php over https on my localserver? https://localhost/coffeeLatte/checkout.php?session=c3e7255a9ec227b4c73b39af5c726792 Is this as expected?
  13. Too many variables for a definitive answer, that makes sense. I was being ambitious with 1000 sale items and 3000 users; that's nearly Amazon material! I suppose the best way to find out would be to deploy it, then watch the .log files for bottlenecks as the site evolves. Thanks for the insight.
×
×
  • Create New...