Andy92
05-07-2006, 10:45 AM
Hi there!
On my site, my friend has made a news managment system, so that through mysql you can easily post news. Go to http://www.allsortshop.com/news to see.
In the /news folder i have index.php which is the main file, and article.php whcih is to display articles.
In the index.php, this is the php code that gets all the news from the database...
<?php
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$result = mysql_query("SELECT * FROM news WHERE type=0 LIMIT 0 , 10");
if ($row2 = mysql_fetch_array($result)) {
echo "<table>\n";
do {
Printf("<tr><td><b>%s</b></td></tr><tr><td>%s <a href=article.php?read=$row2[id]>more...</a></td></tr><tr><td> </td></tr>", $row2[title], $row2[mini], $row2[id]);
}while ($row2 = mysql_fetch_array($result));
}else{
echo "No News... Shocking!!!";
}
echo "</table>\n";
?>
That displays news files, but it only displays an intro, then when you click more it goes to the full news article at /news/article.php?read=1
(in the article.php ive converted the id to read)
Then once on the page article.php?read=1 or read=2 depending on what id number the news article is in mysql, it then shows you the full story.
In the article.php this is the code at the very top of that page before the <html> tag...
<?php
$read = $_GET['read'];
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$result = mysql_query("SELECT * FROM news WHERE id=$read");
$text = mysql_fetch_array($result);
?>
Then in the <body</body> tags of the article.php page i have...
<?php
echo ("<b>".$text['title']."</b>");
echo "<p>";
echo $text['full'];
?>
Now in the mysql this is my news table...
http://www.allsortshop.com/images/mysql.JPG
The thing is, i want to display all the images like image.php?id=1 or whatever and then on the news page, when you click more on an article and it takes you to article.php?read=1 then on the mysql table, on the row with id = 1 in it, it has an image at the end. I want to display that image in the article.php?read=1. And then on article.php?read=2, i want it to display the image on that one too which will be located at image.php?id=2.
How do i do this and make the image.php file?
:confused: :confused: :confused:
On my site, my friend has made a news managment system, so that through mysql you can easily post news. Go to http://www.allsortshop.com/news to see.
In the /news folder i have index.php which is the main file, and article.php whcih is to display articles.
In the index.php, this is the php code that gets all the news from the database...
<?php
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$result = mysql_query("SELECT * FROM news WHERE type=0 LIMIT 0 , 10");
if ($row2 = mysql_fetch_array($result)) {
echo "<table>\n";
do {
Printf("<tr><td><b>%s</b></td></tr><tr><td>%s <a href=article.php?read=$row2[id]>more...</a></td></tr><tr><td> </td></tr>", $row2[title], $row2[mini], $row2[id]);
}while ($row2 = mysql_fetch_array($result));
}else{
echo "No News... Shocking!!!";
}
echo "</table>\n";
?>
That displays news files, but it only displays an intro, then when you click more it goes to the full news article at /news/article.php?read=1
(in the article.php ive converted the id to read)
Then once on the page article.php?read=1 or read=2 depending on what id number the news article is in mysql, it then shows you the full story.
In the article.php this is the code at the very top of that page before the <html> tag...
<?php
$read = $_GET['read'];
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$result = mysql_query("SELECT * FROM news WHERE id=$read");
$text = mysql_fetch_array($result);
?>
Then in the <body</body> tags of the article.php page i have...
<?php
echo ("<b>".$text['title']."</b>");
echo "<p>";
echo $text['full'];
?>
Now in the mysql this is my news table...
http://www.allsortshop.com/images/mysql.JPG
The thing is, i want to display all the images like image.php?id=1 or whatever and then on the news page, when you click more on an article and it takes you to article.php?read=1 then on the mysql table, on the row with id = 1 in it, it has an image at the end. I want to display that image in the article.php?read=1. And then on article.php?read=2, i want it to display the image on that one too which will be located at image.php?id=2.
How do i do this and make the image.php file?
:confused: :confused: :confused: