Jump to content
Larry Ullman's Book Forums

Lou

Members
  • Posts

    97
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Lou

  1. Mod Rewrite is pretty great. You can change all your .php pages, like register.php, to just register. I'm going to mess around with it tonight and get a feel for how it works.
  2. Let me try to write this in some kind of psuedo code. 1 On my pages link the individual blog posts with their title, like articles/row(from database)/title-of-post (from the database row), not just details.php?article_id 2 Create a rewrite rule that matches the link (articles/whatever ever comes after it), stores the row and title in a variable like $1 and $2, then run details.php?article_id=$1. I guess I only need the article id then. 3 The details.php script executes like before, but the user sees the pretty URL, not the mess with the query string
  3. Reading your stuff Hartley, makes me realize this has too many layers of abtraction for me to ever completely understand.To really make a complete and useful website you've got to be a master, and all of these master details aren't covered in any one book (or ten books) and only a small percentage could ever understand it anyway.
  4. I think I see now. the details.php script still runs whenever the regular expression for the link is matched.
  5. Okay I went back to read some. Stupid me. I'm thinking that the links have to be details.php?article_id=2 instead of just inserting the title of the post into the link like Hartley showed me. I don't know why I thought the first way was the only way. Probably because in one of the books I'm reading they do it that way, and instead of trying to solve the issue in a different way I stayed rigid in the original link format. Another question though. If I change the links to the blog posts to the article id/name of blog post format, what happens to details.php that originally handled whatever post I pulled up, let it be article_id 1, 2, 3, 4, 5, or 100? How would I get to the details.php page if the link is already the name of the article?
  6. Still confused but getting there. Say you have your details.php page and it's showing article 2. details.php?article_id=2 You do your rewrite rule to change the url to articles/my-article-title, taking the info from details.php?article_id=2. I still don't get how you get the title of the article into that new URL. Where does it come from? It seems to be going in the wrong order. How does your regular expression pull the title out if the link is article_id=2?
  7. Makes more sense now Hartley. Thanks for taking the time.Thanks also Buttercream.
  8. And whether to use PDO, MySQLIi, it's crazy. All those options and you basically just insert, update, delete and select information.
  9. I am building a dating site. Figured I'd start simple, but the few things I don't understand have stopped me from completing it thus far. Clean URLs for the blog section (mod rewrite) Database structure (user table, profile table, etc). I find it really hard to figure out what's going into the database and specific tables. I know how to make a user's image gallery, but how do you let them define a main photo? do you put that main photo in their profile table, or just in the photos table? Can you define a main photo by say, a 0 or 1 in the photos table, or always keep their main photo in their profile table? If you store sessions in a database using procedural mysql (Larry writes the six functions in the advanced book), can you connect to the database for other tasks using PDO or object oriented? I can get distances between users from my zip code database, but how would I implement users from other countries? i see on other dating sites they let users sign up from different countries and territories. do you have to determine distances for those users as well, and if so, how? Or should I just keep the site USA only? See I have these weird questions one needs to actually complete a site but is rarely covered in any book.
  10. I understand one thing better. Sites don't actually have the directory structure they appear to have... like Yahoo. It's just mod rewrites.
  11. I think I'm confused because the rewrite rule part always has blog.php?t=title&a=article_id. Is that the part that's going to be the new URL? I don't see specifically where the new URL is going to be the title of the blog post. I see you're using the regex's parenthesis and assigning them $1 and $2 but I don't see where this comes into play to assign the new URL.
  12. I'm going to look at the E-Commerce book, I have that one as well. Never got to the second project in that book, so if the mod_rewrites section is there, that's why I missed it.
  13. No I haven't completed any site yet. I've been reading PHP, MySQL, HTML5 books for 3 years and haven't come close to completing a real site yet. I have every one of Larry's books except this new Advanced one. I can code, but I lack a plan for putting it all together. Basically, it's a database problem.
  14. I don't see how this RewriteRule works. I'd like the title of the blog post to be part of the URL of the blog post, I don't want the URL to be article_id=2. It looks like these rules make sure the URL is in the format I don't want. Can you explain each line?
  15. Hehe... I'm going to study this more tomorrow. I am tired and nothing is making sense. I'm sure we can figure it out. And I will buy the new edition of the book soon as well.
  16. I can already process clean URLs. You just set an index page inside the folder and in your controller use include depending on the action taken and you can maintain a clean URL at all times, say yoursite.com/register INSTEAD of register.php.
  17. I don't get it. 1. If you're dynamically pulling say the first 5 blog posts from the database into your blog.php page, how would the links already be the titles of the blog posts? 2 One of the links on the main blog page would be say.... details.php?article.id=2. You click the link and you're on the details.php page and the query string pulls all the info from the database for the article requested 3 When working with mod rewrites, would the links on the main blog page still be say article_id=2, then when you click the link, the mod_rewrite rules take effect and you're redirected to a different link that's the title of your blog post? 4 I just don't see where the link would get the title of the blog post I don't even know the right question to ask right now.
  18. Still confused. I only got up to making sure the rewrite engine is on and redirecting to my index page when a user goes to a page that doesn't exist. I'm using this site by the way. http://blog.webilix.com/2012/10/implement-seo-friendly-urls-with-mod_rewrite/ I'm using xampp by the way, not ZendServer anymore. ZendServer was okay but I couldn't test any SSL with it.
  19. I'll definitely have to check out the book then. It's just so confusing, but it is an advanced topic. I know how to make clean URLs by putting an index page inside each directory, but using the blog post for the page title has alluded me this far. Amazing how every book tells you most of what you need, but there are several important things always left out that you NEED to make a complete site.
  20. Does it cover changing a page from yoursite.com/blog.php?article_id=2 to yoursite.com/title-of-blog-post/ ? I'm looking all over google and every explanation is confusing and not what I'm looking for.
  21. Which book covers it Hartley? You said you don't think the new edition covers it, but you think this book does? Huh?
  22. Do I have to learn the black art of mod rewrite and does this new version of the advanced book cover it?
  23. I don't think this answered my question. How do I make the URL the name of the post isntead of article_id=2? When you select an article from the main blog page, you're taken to a details.php page that displays the blog post you selected. I want that page's URL to be the name of the post and NOT article_id=2
  24. Back again... I'm putting this in the advanced section. I'm not sure if this is covered in the new book (I have the previous edition) or not. Say you have a blog page with a few articles. The user clicks on an article and goes to a page with the complete blog post. The title of the page includes the query string for the article, like details.php?article_id=2. How would you make the title of the individual blog post page something like this-is-the-title-of-the-blog-post instead of details.php?article_id=2? Thanks a bunch for anyone who can clue me in.
  25. Wow, what an explanation. I have read about 10 php books and struggled to read what you wrote. :-) I don't usually code with an index.php that's a master switch (MVC style). Has Larry adopted this style for this new Advanced book? I'll have to buy the book and read this material, it sounds interesting. I enjoyed the previous Advanced book, but haven't read that one in awhile since it's set up differently than his other PHP books.
×
×
  • Create New...