tracy Posted November 28, 2006 Share Posted November 28, 2006 If I have a table in MySQL and generate a web page with the contents displayed using PHP, how hard is it to link one item in each row, for example:say there is a lot of inventory displayed...item one description photoitem two description photoitem three description photo...you get the point...if the photo is clicked I would like to hyperlink that to another php generated page with full details and more photos of this item.I know I'd have to build the new page using PHP, no problem...it's the hyperlinking of the photo to said page that I don't know how to do. I would think it's just a simple line of code, much like http hyperlinks but I'm not sure. Any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/ Share on other sites More sharing options...
Jocka Posted November 28, 2006 Share Posted November 28, 2006 on the next PHP page you can call it by id or something (assuming u use id's on ur images). Make the urls come out when echoing from the database like so:while($row = mysql_fetch_array($query)){ echo "<a href='this.php?id=" . $row['id'] . "'>". $row['name'] ."</a>";}id being t he id and 'name' being the name of course. Depends on how u named ur rows.On this.php have something like:<?php$item_id = $_GET['id'];// GET INFO FROM DATABASE BY ID$query = mysql_query("SELECT * FROM table WHERE id='". $item_id ."'");?>You get the idea from there i hope. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/#findComment-131699 Share on other sites More sharing options...
tracy Posted November 28, 2006 Author Share Posted November 28, 2006 I am not sure what you mean by using id's with my images. I planned on saving them on the server as name.jpg for example. Could you explain this id issue more? Kind of new to PHP. Thanks. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/#findComment-131703 Share on other sites More sharing options...
Jocka Posted November 28, 2006 Share Posted November 28, 2006 are you saving the image information into the database? What exactly is the database information for?I was thinking you had a field in your database with image information. Something like:[code]TABLE `images` id | name | description | image_link 1 | test | this is a test | image.jpg[/code]If you do this then it would be easier. Just add the images to your database and you can even give them categories or whatever you'd like. The id would be "id" from the mysql database which would give the PHP script something to find the image by. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/#findComment-131710 Share on other sites More sharing options...
tracy Posted November 28, 2006 Author Share Posted November 28, 2006 Got it. Thanks. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/#findComment-131713 Share on other sites More sharing options...
Barand Posted November 28, 2006 Share Posted November 28, 2006 Each item in your product table should have a unique identifier. This could be a unique product code or, as is often used, an auto_incrementing row id field.Whichever you have in your product table is the value that should go in the link so you jnow which item to display in the next page. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/#findComment-131717 Share on other sites More sharing options...
tracy Posted November 28, 2006 Author Share Posted November 28, 2006 Thanks. I appreciate the help. Link to comment https://forums.phpfreaks.com/topic/28767-hyperlinks-in-phpmysql/#findComment-131718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.