Jump to content

Recommended Posts

Wow...OK...here is my problem:

 

On the main page of my site, I have an article that will display 3 sentences (I haven't figured out how to do that yet...) and at the bottom it has a link to article.php?article_id=#. My problem is that when I go there, it will say:

Resource id #5

 

Here is my code for article.php

<?php
include("config.php");

if ((isset ($_GET['article_id']))) {

$id = $_GET['article_id'];

$query = "SELECT id FROM news WHERE id = $id";
$getarticle = mysql_query($query);
echo $getarticle;

}
?>

 

Any help is good...thanks,

Rye

Link to comment
https://forums.phpfreaks.com/topic/51155-solved-get-methodmysql-helpurgent/
Share on other sites

<?php
include("config.php");

if ((isset ($_GET['article_id']))) {

$id = $_GET['article_id'];

$query = mysql_query("SELECT id FROM news WHERE id = $id");
$result = mysql_fetch_array($query);
$getarticle = $result['id'];
echo $getarticle;

}
?>

 

Should work :)

That really helped but I've run into another problem, unfortunately.

 

As stupid as I am, I didn't call up the articles title, date, or content...any ideas on how I could so I can display each thing separately like this:

<?php

Mysql stuff here...

echo $title;
echo $date;
echo $content;

?>

<?php
include("config.php");

if ((isset ($_GET['article_id']))) {

$id = $_GET['article_id'];

$query = mysql_query("SELECT * FROM news WHERE id = $id");
$result = mysql_fetch_array($query);
$getarticle = $result['id'];
$title = $result['title'];
$date = $result['date'];
$content = $result['content'];
echo $getarticle;

}
?>

 

;)

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.