PDA

View Full Version : hyperlinks for a shop


Wicked Mental
05-12-2008, 03:05 PM
basically I am creating a shop to sell some products. I have listed my products on the page, but I am having some trouble with linking them to go to like their own page to go an buy the item.

I need to get it so that no matter what order the items are in it will link them to their own page with the price and other information.

Which will have information which is in the database of:

item name,
descrption,
price

etcetc

so no matter what item it is it will print the dedicated info of the item out..

i'm sure you can sort of get the jist of it...

i'm looking for some snippet of code which can do this or something to help me... i am completely new.

Fumigator
05-12-2008, 04:24 PM
Typically you will add a query string to your link. The query string is the stuff after the file path in the URL, looks something like ?item=12345&qty=2. Every item link really points to the same script, the only difference is the query string contains the unique key to your items table.

Then in the script that displays the details for an item, access the query string (For example, PHP uses an array called $_GET you can use for this) to get the unique key for the item, select the detailed info from your table and display it.

Wicked Mental
05-12-2008, 09:43 PM
my database has been setup like this:

mysql> select * from product_info;
+------------+-------------------+---------------+
| product_id | product_name | product_price |
+------------+-------------------+---------------+
| 01 | Manchester United | 29.99 |
| 03 | Arsenal | 29.99 |
| 02 | Liverpool | 29.99 |
| 04 | Chelsea | 29.99 |
+------------+-------------------+---------------+


I have my products page setup which displays the product_name, how can I get it hyperlink the product_name which then goes to a page which displayed product_price among other information I will add after I have the basics done...

I think this will mean that my product_name will be my primary key?

Fumigator
05-12-2008, 10:24 PM
Did you understand my post? Because the answer's still the same. Put the product ID in the query string and then on the product detail page select the row from your table using that ID.

Wicked Mental
05-12-2008, 10:28 PM
I didn't no, I googled query string but everything seems advanced. I am learning this for University and don't understand very much if anything at all...

I am still non the wiser... can you post some of the 'code' so I can try and reasearch... the only other thing I can think of doing is echoing a buy now image and create a page with all the details on but this is a lot more work and not what I was asked to do...

My page so far is just this

Team Name:

Manchester United
Liverpool
Chelsea
Arsenal

What I want is

Team Name:

Manchester United (#)
Liverpool (#)
Chelsea (#)
Arsenal (#)

When the link is clicked it will go to the same page and display

Team Name Price

Manchester United 29.99 Buy Now

But if the order of the list changes then the links much still be the same etc...

bazz
05-13-2008, 12:18 AM
I dont fully understand your question.

I am not sure if your trouble is that you haven't been able to make a hyperlink or if you haven't been able to send the values from one page to the other.

Please post your code for the relevant part.

bazz

Wicked Mental
05-13-2008, 12:24 AM
I have my values printed on the products.php page, but I need it so that when the product_name is clicked (therefore needs to be hyperlinked somehow) then it will display more information of that product such as price etc etc...

i am just needing a way to hyperlink the pages with a may which will work no matter what order the pages are in. for example if i choose to sort the products on the products.php page alphabetically then the way that they are linked will not effect the further information that is given etc.

i cannot put it any simpler... there HAS to be a way for a checkout to work its just knowing how.

someone out there knows and i need your help!

bazz
05-13-2008, 12:34 AM
we are trying but we are blind.

Since you say you need to hyperlink one page to another have you got the word for your link writtewn like this in your page


<a href="url_to_link_to?param=this&amp;param2=that">Manchester United</a>

? signifies the beginning of the query string, which will contain the values that you need to send to the second page.

so to clarify your question is it hyperlinking that you are stuck on or sending of params?
bazz

Wicked Mental
05-13-2008, 12:38 AM
i have yet to even hyperlink anything, I am just gonna give up on this piece of coursework and admit defeat with a fail. i am questioning the coursework to even think that what is asked is possible?

as someone with no knowledge of php i would of imagined a logical system to do this... maybe in time...

but thanks everyone who took the time to reply and try and help..

Fumigator
05-13-2008, 07:25 AM
I understand your frustration. This internet technology can be pretty daunting. I'm wonder do you not have an instructor you can ask questions of? Have him illustrate what a query string is on a whiteboard-- someone face to face can help you understand the concepts much better than a written message.

bazz
05-13-2008, 02:14 PM
frustration has, for me, been part of the process.

What you want to do sounds possible since it sounds like you want just a shopping cart.

whether the coursework has progreessed far enough to let you achieve it within the set time frame, that isn't clear.

I would suggest that, if this is something you want to do as a career - and not just as part of a course - then keep searching CF and google because some guys around here ahve done just that and achieved what it sounds like you want.

Probably took them longer but I bet they have a much better hang of what they are involved with, than had they simply followed instructions - which by their very nature, limit the individual to the extent of the instructions.

sidenote: I always have understood that teaching was best done, where the student was encouraged throughout the course. I hope it hasn't changed such that WM has or is losing interest.

i would have imagined a logical system to do this..
There is a structured (if not logical), way to achieve this. BUt you seem not to have had the information/tutoring to empower you to achieve this task. Maybe this was a test of something else and the 'project' was just the vehicle?



hth

bazz

technica
05-14-2008, 08:33 AM
You can create a hyperlink while fetching the records from the table for e.g.

Select '<a href="productpage.asp?produciid="+ Product_id + '>' + Product_Name + '</a>' as Link, product price from product_info;

This query will give you the procut name having link to them.

The above query may contain some syntax errors , but I just tried to give you some basic idea of how you can implement a link to product name in the select query itself.

I have dome this many times in sql server, hope this works well with MYSQL also.

Best of luck. Let me know if more help required.