[email protected] Posted June 20, 2011 Share Posted June 20, 2011 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 https://forums.phpfreaks.com/topic/239851-dynamic-url-shoppingphpitem0001/ Share on other sites More sharing options...
HDFilmMaker2112 Posted June 20, 2011 Share Posted June 20, 2011 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 https://forums.phpfreaks.com/topic/239851-dynamic-url-shoppingphpitem0001/#findComment-1232078 Share on other sites More sharing options...
YoungNate_Black_coder Posted June 20, 2011 Share Posted June 20, 2011 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 ...... 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 https://forums.phpfreaks.com/topic/239851-dynamic-url-shoppingphpitem0001/#findComment-1232081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.