Jump to content

Dynamic URL Shopping.php?item=0001


Recommended Posts

 

 

I use a SQL database and a WHILE LOOP to display the contents of the database on the main page and am currently trying to incorporate a Facebook "like" button for each and every item on the page.

 

Currently every item listed in the database is displayed on Shopping.php I need the server to be able to create a page with a unique address for each item in the database so that the "like" buttons don't all link back to the Shopping.php page.

 

What I am imagining is something like "/Shopping.php?item=0001" that will link to a page dedicated to that one single item.

 

Thanks for your time.

 

Please if you could give a code how to do it , it would be great help

 

Link to comment
Share on other sites

if(isset($_GET['item']) && ctype_digit($_GET['item'])){
$item_id=$_GET['item'];
$sql50="SELECT * FROM $tbl_name WHERE item_id='$item_id'";
$result50=mysql_query($sql50);
while($row50=mysql_fetch_array($result50)){

//product display here
}
}

 

From that whenever you have ?item=item number in the URL you'll get a SQL Query for that product/item.

 

Link to comment
Share on other sites

well sounds to me like your thinking of some kind of template system which is what i do with all my sites! :)

one way u could go about doing that is making a layout in photoshop of what u want the site to look like and get it layed out in dreamweaver / whatever u use and then just query your database for row data that will populate information into your divs...

 

as far as the dynamic url goes that simply as u put it ...... ;D

pass a vairlbe through the url so that u can use that to query with like so :

start with a simple page (im assuming you already have some type of way u plan to create dynamic links right??..)
<?php
// query your database for all  the items  
// then store them into rows like this //$row_data['']
// then plug them in the links ull have like so:

<html>
<body>
<a href="shoping.php?item=<? php echo $row_data['id'] ?>">link to a item</a>
</body>
</html>

// no when those links are click :
say for example the url  said 1
site.com/shoping.php?item=1

that one reprsents $ID = $_Get['[b]item[/b]'] // witch would be 1
then query your database with that one example:
$sql = SELECT * FROM ITEMS WHERE ITEMS_ID = '$ID';
THEN STORE THOSE INTO MYSQL ROWS AND PLUG THEM IN WHERE U WANT ON YOUR SITE ...
HOPE THIS HELPS 

///////////////// U have been struck by Young Nate Da Great The Top Black CODER!/////////////////


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.