Jump to content

Recommended Posts

Hello,

I have a php code that displays a list of links.

when a link is chosen it is to display data from

mysql database based on the "submission_id"

specified by the link chosen. This data would

then be displayed on a new "display.php" page.

But display.php code currently isn't working.

 

the code of the initial page:

    $result = mysql_query("SELECT submission_id, col_4 FROM $table ORDER BY submission_date DESC");
    if (!$result) {
        die("Query to show fields from table failed:".mysql_error());
    }

    while($row = mysql_fetch_array($result))
    {
      echo '<a href="Display.php?id='.$row['submission_id'].'">'.$row['col_4'].'</a>';
      echo "<br />";
    }
    mysql_free_result($result);

 

 

Display.php:

 

$id = (int) $_GET['id']; // since the submission ID is named "id" in the query string!

$sql = "SELECT * FROM $table WHERE submission_id=$id";
$result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql);
if(mysql_num_rows($result) == 1){
$row = mysql_fetch_assoc($sql);
//print out information
}else{
echo 'That record ID does not exist!';
}
?>

 

I don't see whats wrong with the display.php page code,

but its not displaying the data.

Can anyone see a problem with it?

 

 

Link to comment
https://forums.phpfreaks.com/topic/102388-solved-display-problem/
Share on other sites

I tried the following:

 

$id = (int) $_GET['id']; // since the submission ID is named "id" in the query string!

$sql = "SELECT * FROM $table WHERE submission_id=$id";
$result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql);
if(mysql_num_rows($result) == 1){
$row = mysql_fetch_assoc($sql);

echo $row['col_2'];
echo $row['col_3'];
echo $row['col_4'];
echo $row['col_5'];

}else{
echo 'That record ID does not exist!';
}
?>

 

However its still not displaying.

notice anything else missing?

 

thanks for all the help.

 

try

 


$id = mysql_real_escape_string(strip_tags($_GET['id'])); // since the submission ID is named "id" in the query string!

$sql = "SELECT * FROM $table WHERE submission_id=$id";
$result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql);
if(mysql_num_rows($result) == 1){
$row = mysql_fetch_array($sql);

echo $row[0];

}else{
echo 'That record ID does not exist!';
}
?>

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.