Jump to content

[SOLVED] GET method/MySQL help...urgent


ryeman98

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;

}
?>

 

;)

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.