Jump to content

l3rodey

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by l3rodey

  1. Hi Guys, I have a URL that looks like this: www.example.com/category.php?cat_slug=whiskey/single-malt this shows up everything works fine... I have a htaccess file that is this: RewriteRule ^([0-9a-z-/-A-Z_-]+)?$ category.php?cat_slug=$1 [NC,L] This doesn't work but yet the product does... RewriteRule ^([0-9a-z-/-A-Z_-]+)/([0-9a-zA-Z_-]+)?$ product.php?cat_slug=$1&prod_slug=$2 [NC,L] Which looks like this www.example.com/whiskey/single-malt/haig-club-clubman-70cl once rewritten. The top example doesn't work though which should rewrite to www.example.com/whiskey/single-malt Why would the second one work but not the first one? Please don't get too technical here, I found the code online 2 years ago and have used it ever since. I don't actually understand what it does or why it does what it does, it just works... I know if I put it into a folder like shop/ so RewriteRule ^shop/([0-9a-z-/-A-Z_-]+)?$ category.php?cat_slug=$1 [NC,L] it will work, but for this website I don't want that... Please help me
  2. Thanks, I will look at this and see what I can find but how do I display data? I have the query setup as this: $query = " SELECT p.name , p.slug as prodslug , c.slug as catslug FROM FROM products p INNER JOIN categories c ON p.category_id = c.category_id WHERE p.status='1' AND p.featured='1' ORDER BY p.product_id LIMIT 12 "; if ($result = $liquor->query($query)) { while ($row = $result->fetch_assoc()) { ?> <li><a href="./<?php echo $row->catslug ?>/<?php echo $row->prodslug; ?>"><?php echo $row->name; ?></a></li> <?php } $result->free(); } ?> but nothing shows? what am I doing wrong with the displaying of data?
  3. Hey thanks man! and I am echoing how? <php echo $featured->prodslug; ?> is that correct is that how I echo it? And I am using mysql clearly what is the mysqli option? ( I'm super behind clearly ) just trying to learn.
  4. Hi guys, I am not very good with Joins, and thus I do things what most of you will call discusting. I already know this so go easy. Can someone help me with a join? I have googled it but don't understand as it's not my db. This is what I do. <?php $featuredProducts = mysql_query("SELECT * FROM products WHERE status='1' AND featured='1' ORDER BY product_id ASC LIMIT 12", $liquor); while ($featured = mysql_fetch_object($featuredProducts)) { $category = mysql_query("SELECT * FROM categories WHERE category_id=$featured->category_id LIMIT 1", $liquor); while ($cat = mysql_fetch_object($category)) { $slug = $cat->slug; } mysql_free_result($category); ?> <li><a href="./<?php echo $slug ?>/<?php echo $featured->slug; ?>"><?php echo $featured->name; ?></a></li> <?php } mysql_free_result($featuredProducts); ?> I need to build a URL so I need to know the category slug which is in the db, so I do another lookup make a valuable and use it... but I know you can do a join here and make this so much tidier. Can someone please show me how a join would make the above query proper?
  5. Thanks but this does not answer my question the slugs I am fine with that's great but reading inside the h2 then going back and editing that exact h2 is where I am stuck. I can make a slug that is fine but I am not sure how to read in php what is inside the h2 (then I will slug it) then edit the h2 that the text is in... This is where I'm stuck
  6. Hi Jacques, The PHP file that actually does the compression of HTML actually is a caching tool to cache it more so then compress it. The reason it compresses is to store a smaller cache file on our server more than anything else. It was not an SEO Strategy as such more of a speed issue. The auto-generated ID's is for Anchoring, Our site contains more than 300,000 pages and we are wanting to add a nice following side-bar that has the H2 elements on it and when clicked takes you to where you want to go. I know there is other methods of this but this is the way I wanted to go. I cannot go back and edit 300,000 pages to add the id manually so a PHP script is best.
  7. Hi everyone, Just had a quick question, ( I am not hard-core programmer just know my way around ). I have some PHP that runs in the back of my site that deletes stuff from my html before rendering, Like line breaks and comments to render smaller HTML it uses preg_replace() and str_replace() to do so. What I am wanting to do is something which I feel should be possible but need to know how. I have a <h2>This is the title</h2> On my page and I want to add the following and make it looks like this: <h2 id="this-is-the-title">This is the title</h2> I worked for hours this morning trying to work it out but failed to do anything all I can do is id="1" and + 1 every time and this is not what I want I want it to read the h2 and replace special char and spaces with -. Is there a way of doing this? Here is a couple of my preg_replaces and str_replaces already thee. $start_buffer = preg_replace('/" style=/', '"style=', $start_buffer); $start_buffer = preg_replace('/" class=/', '"class=', $start_buffer); $start_buffer = str_replace("; }", "}", $start_buffer); $start_buffer = str_replace("{ ", "{", $start_buffer); As you can see all this is really doing is removing spaces that are not required. Any help what so ever will be greatly appreciated.
×
×
  • 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.