Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/241789-more-info-to-open-in-new-page/
Share on other sites

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

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.

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.