Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Location
    Northumberland UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trying to anchor in PHP

    Hi Folks

    I'm trying to make life a little easier but not sure if it's possible. I have a php file/web page with products on in divs: The first div below contains some code (highlighted in blue) which points to a single product and opens in it's own web page which works but means I have a web page for every product (500 +). What I would like to be able to do (highlighted in red the second div) is somehow have one webpage containing all products (or at least have them in sections) but be able to have an anchor id to the particular product. If this is possible how then would I anchor to the product in the product web page?

    Code:
    <div class="cat-box">
    <a href="index.php?page=archangelicbook" onfocus="if(this.blur)this.blur();"><img class="catimage" src="../images/archangelicbook.jpg">
    <h2>Archangelic Book of Ritual & Prayer</h2></a>	
    </div>
    
    <div class="cat-box">
    <a href="index.php?page=angelproductsid=001" onfocus="if(this.blur)this.blur();"><img class="catimage" src="../images/archangeliccards.jpg">	
    <h2>Archangelic Deck</h2></a>	
    </div>
    All pages are loaded into the index.php which contains the div below:

    Code:
    <div id="middle">
    
    <?php include('php/' . $_GET['page'] . '.php'); ?>
    
    <?php
    	$page = $_GET['page'];
    	if (!empty($page)) {
    		$page .= 'php/'.'.php';
    		include($page);
    	}
    	else {
    		include('php/home.php');
    	}
    ?>
    
    </div>
    I'm new to PHP and trying to learn as I go along any help would be greatefully received.

    many thanks

    Andrew

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,296
    Thanks
    13
    Thanked 345 Times in 341 Posts
    something like index.php?page=angelproducts#id001 (where id001 is the name/id of the anchor)?

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Location
    Northumberland UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your reply. It almost worked. I have 3 divs in the angelproduct file and it brings them all through but I only want the one related to the specific id. Any ideas how I can stop them all appearing.

    Code:
    <div id="001" class="product-box">
    <h1>001 - £<SCRIPT LANGUAGE="JavaScript" SRC="http://www.remoteprice.com/data.asp?storeid=33321&itemcode=erbm16&type=1"></script></h1>
    <div class="cart-details">
    <img class="prodimage" src="../images/erbm16.jpg"></div>
    
    <div id="002" class="product-box">
    <h1>002 - £<SCRIPT LANGUAGE="JavaScript" SRC="http://www.remoteprice.com/data.asp?storeid=33321&itemcode=erbm16&type=1"></script></h1>
    <div class="cart-details">
    <img class="prodimage" src="../images/erbm16.jpg</div>
    
    
    <div id="003" class="product-box">
    <h1>003 - £<SCRIPT LANGUAGE="JavaScript" SRC="http://www.remoteprice.com/data.asp?storeid=33321&itemcode=erbm16&type=1"></script></h1>
    <div class="cart-details">
    <img class="prodimage" src="../images/erbm16.jpg</div>

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,296
    Thanks
    13
    Thanked 345 Times in 341 Posts
    then only insert the one with the appropriate id.

    PS. IDs must not start with a digit.

  • #5
    New to the CF scene
    Join Date
    Jan 2010
    Location
    Northumberland UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These are my menu links:
    Code:
    <div class="cat-box">
    <a href="index.php?page=angelprods#id001" <h2>001</h2></a>	
    </div>
    
    <div class="cat-box">
    <a href="index.php?page=angelprods#id002" <h2>002</h2></a>	
    </div>
    
    <div class="cat-box">
    <a href="index.php?page=angelprods#id003" <h2>003</h2></a>		
    </div>
    and this is the angelprods php

    Code:
    <div id="id001" class="product-box">
    <h1>Product 001</h1>
    </div>
    
    <div id="id002" class="product-box">
    <h1>Product 001</h1>
    </div>
    
    <div id="id003" class="product-box">
    <h1>Product 001</h1>
    </div>
    I was trying to avoid creating a webpage per product by pulling through just the relevant data from one file. Do you know if there is a better method to do this?

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,296
    Thanks
    13
    Thanked 345 Times in 341 Posts
    actually, I would create a separate page for every product, though that’s my personal preference.

    you could also choose to store the information in XML files (if it’s not too complex info) and fetch it from there or you could of course use a database.
    Last edited by Dormilich; 01-30-2010 at 12:43 PM.

  • #7
    New to the CF scene
    Join Date
    Jan 2010
    Location
    Northumberland UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks for your time and help.

  • #8
    New to the CF scene
    Join Date
    Jan 2010
    Location
    Northumberland UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved

    Hi There.

    I've used the switch/case functionality and it works a treat.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •