SQL results won't be printed.
Posted: Tue Oct 13, 2009 1:44 pm
Hello there,
I'm currently building a website for our gaming clan. I began creating the code for index.php. On index.php all of the news should be printed. The news should come from my SQL Database containing the following:
members(member_nr, e-mail, username, etc....)
news(news_nr, member_nr, title, content, date, time)
I allready added some members and a news-item. But when I trie to print all of the news-items, the code gives no results. Here's my code:
I'm affraid the problem is my query, but I don't know for sure, so I just posted my problem in PHP - Code. I don't know a lot about using the JOIN, so the problem might be in there.
So could anyone help me?
Gr. Mr.Paplu
I'm currently building a website for our gaming clan. I began creating the code for index.php. On index.php all of the news should be printed. The news should come from my SQL Database containing the following:
members(member_nr, e-mail, username, etc....)
news(news_nr, member_nr, title, content, date, time)
I allready added some members and a news-item. But when I trie to print all of the news-items, the code gives no results. Here's my code:
Code: Select all
<?php
session_start();
include("include/pageheader.php");
$include_add = false;
$bewerk = "";
if($_SESSION['function'] == "admin"){
$include_add = true;
$bewerk = "<a href=\"edit_news.php\">Bewerk artikel</a>";
}
//actual printing
print("<div class=\"pagetitle\">[PDM]Home</div>");
include("include/connect.php");
[color=#FF0000] $query = "SELECT news.title, news.content, news.date, members.gamertag FROM news [/color]
[color=#FF0000]INNER JOIN members ON news.member_nr = members.member_nr";[/color]
$result = mysql_query($query);
while(mysql_fetch_array($result)){
print("<div class=\"news\">");
print("<div class=\"title\">".$row['title']."</div>");
print("<div class=\"content\">".$row['content']."</div>");
print("<div class=\"date\">".$row['date']." by [PDM]".$row['gamertag']." ".$bewerk);
}
print("</div>");
if($include_add){
include("include/menu_home.php");
}
include("include/pagefooter.php");
?>So could anyone help me?
Gr. Mr.Paplu