Jump to content

[SOLVED] Pass an id to another file - quick question


Aureole

Recommended Posts

Real quick question.

 

On my news page I have a link to the full story and then the short story below.

 

The link to the full story is news/viewfull.php?id=something

 

Now what I need to do is make it so if the id=5 in the url it will query the database and get the fullstory that has an id of 5.

 

Does that make sense?

 

Is it something like...

 

<?php
if (isset($_GET['id'])) {

$theid = $_GET['id'];

$query = "SELECT fullstory FROM news WHERE id=$theid";

// Etc....
?>

 

// Connect to db etc.

 

 

I have this and it isn't working...

 

<?php

if (isset($_GET['id']))
    {
    $theid = $_GET['id'];

    DEFINE ('DB_USER', '********');
    DEFINE ('DB_PASSWORD', '********');
    DEFINE ('DB_HOST', 'localhost');
    DEFINE ('DB_NAME', '********');

    $connectme = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
@mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error() );

    $query = "SELECT full FROM news WHERE id='$theid'";
    $result = @mysql_query($query) or die(mysql_error());

    while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
        {
        echo "{row['full']}";
      }
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.