ofmyst Posted August 16, 2008 Share Posted August 16, 2008 I asked previously but the problem was not resolved, mainly I think because I could not understand the concept well enough to follow the logic. Here is what I am trying to do. Perhaps if I can understand the logic of the commands I will be able to get it right. I have a mysql database (called paintings) and a table within (called tinkers) with an inventory of paintings. In the fileds are ID (1 - , [id] the address for the JPG [image tn], the link to the file that give more information and a larger version of the image [link], the address for the larger image [image], the title [title], medium[medium] and size . The file that calls up the database to show the array of paintings is tinker.php. This page works fine. If the viewer would like to see an enlargement with further information the link is called view.php. This is where my problem comes. I cannot get the link to pull the information for that particular painting into the new page. I believe the link would be view.php?id=1, etc. but do I put the link in as <a href="view.php"> and the rest pulls itself, or do I put it in as <a href="view.php?id=1">. Also, when I put in the code: mysql_select_db("paintings", $con); $id = (int) $_GET['id']; $result = mysql_query("SELECT * FROM tinkers WHERE id=$id"); The WHERE part yields a blank page for me. Also, in addition to getting the coding right for the tinker.php page I am not sure what instructions are put in the view.php page. Perhaps if I could have a simple example or a brief explanation of the concept it will help me move forward. Thank you very much! Link to comment https://forums.phpfreaks.com/topic/119985-solved-php-mysql-pulling-data-and-opening-new-file-trying-to-understand-concept/ Share on other sites More sharing options...
JD* Posted August 18, 2008 Share Posted August 18, 2008 When you code the link for your view.php page, you want to put it in as you stated (<a href="view.php?id=#">) On your view.php page, your code should look like this: mysql_select_db("paintings", $con); $result = mysql_query("SELECT * FROM tinkers WHERE id='".$_GET['id']."'") or die(mysql_error()); That should get your query working correctly. Link to comment https://forums.phpfreaks.com/topic/119985-solved-php-mysql-pulling-data-and-opening-new-file-trying-to-understand-concept/#findComment-618847 Share on other sites More sharing options...
ofmyst Posted August 19, 2008 Author Share Posted August 19, 2008 Thank you so much for answering. Okay, that helped me alot with the concept and my links are working just fine now. However, my view.php page is still blank. When I do a view source it is empty (other than the html & body, etc tags). The address is correct at the top. Any thoughts? View.php code is: <?php $con = mysql_connect(""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("paintings", $con); $result = mysql_query("SELECT * FROM tinkers WHERE id='".$_GET['id']."'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $row['Title'] . "<br>\n". $row['Medium'] . "<br>\n". $row['Size'] . "<br>\n"; } mysql_close($con); ?> My main page if it helps is: www.sharondross.com/images/tinker/tinker.php Link to comment https://forums.phpfreaks.com/topic/119985-solved-php-mysql-pulling-data-and-opening-new-file-trying-to-understand-concept/#findComment-619705 Share on other sites More sharing options...
ofmyst Posted August 19, 2008 Author Share Posted August 19, 2008 Ah, I just saw myself I lost my echo line. It works great. Thank you so much! Link to comment https://forums.phpfreaks.com/topic/119985-solved-php-mysql-pulling-data-and-opening-new-file-trying-to-understand-concept/#findComment-619715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.