hoponhiggo Posted July 12, 2011 Share Posted July 12, 2011 Hi Guys I have some code which works fine at the minute, but i want to expand on it so that it opens more information. The following code displays the information for all my rows in a database. <?php //get results from db $sql = "SELECT * FROM Games ORDER BY gametitle"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0) die("No records found"); // loop through the results returned by your query while($data = mysql_fetch_assoc($res)) { $title=$data['gametitle']; $cover=$data['cover']; $gameid=$data['gameid']; // directory for images $dir="coverart"; ?> What i want is for each record to then be a link to open more information, specific to that row. I know that i can use anchor tags to turn a record into a link <a href="Reviews.php?gameid=<?php echo $gameid ?>"><?php echo $title ?></a> but i dont know how i can change it to only display the extra info for the selected row? Sorry if this doesnt make sense. Please let me know if more info is needed. Can anybody please help? Quote Link to comment https://forums.phpfreaks.com/topic/241789-more-info-to-open-in-new-page/ Share on other sites More sharing options...
ScotDiddle Posted July 12, 2011 Share Posted July 12, 2011 hoponhiggo, This is a perfect example of where AJAX will come in handy. I recommend the JQuery AJAX interface (http://api.jquery.com/jQuery.ajax/) Scot L. Diddle, Richmond VA Quote Link to comment https://forums.phpfreaks.com/topic/241789-more-info-to-open-in-new-page/#findComment-1241749 Share on other sites More sharing options...
hoponhiggo Posted July 12, 2011 Author Share Posted July 12, 2011 Is there no way to do this in PHP? I have been trying to learn PHP for a few weeks now and dont really want to stray too far off topic with AJAX and Jquery just yet. Quote Link to comment https://forums.phpfreaks.com/topic/241789-more-info-to-open-in-new-page/#findComment-1241840 Share on other sites More sharing options...
premiso Posted July 12, 2011 Share Posted July 12, 2011 PHP is server side. Either way, AJAX or JS or HTML you still need to code that anchor link to work and get the extra data you need. You could perhaps pass a parameter called "extra" inside the link so on the Reviews.php, you see if $_GET['extra'] has been set, if it has then you just display the extra data. So yea, it shouldn't be too complicated, you just have to code it. If you want it to be fancy and styled and flow better, well AJAX / JS would be the way to go. If you just want to open a new window, the link you have is fine, you just have to code the Reviews to display what you want displayed. Quote Link to comment https://forums.phpfreaks.com/topic/241789-more-info-to-open-in-new-page/#findComment-1241870 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.