Forum Moderators: coopster
I just want it to display this, which is working on the other page that has all the scripts:
<a href="<?php print $article_path;?><?php print $default_id;?>" title="<?php print $default_title;?>"><?php print $default_title;?></a> I'm not really sure on how to do this but if you know what I mean please help :)
SELECT * .... .... LIMIT 5
Obviously not the whole query, but you get the point.
You might also want to take a look at the Basics of extracting data from MySQL [webmasterworld.com] for additional information.
Oh, and Welcome to WebmasterWorld! :)
$offset = $page * $posts_per_page - $posts_per_page; $query = mysql_query("SELECT * FROM $mysql_posts_table ORDER BY id DESC
LIMIT $posts_per_page OFFSET $offset");
global $mysql_comments_table;
display('header.php');
display('pages.php');
// Previous
if($page > 1)
print '<a href="?page=' . ($page - 1) . '"></a> ';
else
print '';
// Direct links.
for($a = 1; $a <= $pages; $a++)
if($a == $page)
print "$a ";
else
print '<a href="?page=' . $a . '">' . $a . '</a> ';
// Next
if($page < $pages)
print '<a href="?page=' . ($page + 1) . '"></a>';
else
print '';
display('pages2.php');
while($row = mysql_fetch_array($query))
{
global $default_title;
global $default_content;
global $default_date;
global $default_id;
global $default_author;
global $default_section;
$default_title = $row['title'];
$default_content = $row['content'];
$default_date = $row['date'];
$default_id = $row['id'];
$default_author = $row['author'];
$default_section = $row['section'];
$default_title = stripslashes($default_title);
$default_content = stripslashes($default_content);
$default_author = stripslashes($default_author);
$default_section = stripslashes($default_section);
// Get the number of comments for this post.
$query_sava = mysql_query("SELECT id FROM $mysql_comments_table WHERE
post=$default_id");
global $default_comments;
display('default.php');
}
That is just a small sample but that is basicly what puts it on the other page. I'm not really sure on how to make it be able to go on the other page, I tried doing:
display('default.php', 'news.php');
But that still doesn't work.
$query = mysql_query("SELECT * FROM `insert_table_name` ORDER BY id DESC
LIMIT 5");
If you want this on a separate page you are going to have to query this again. The code you have included above is for a pagination script. Since this is not what you want, you must send the same or similar query from a separate file and sort/echo them according to your needs.
[code]$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$query = mysql_query("SELECT * FROM $mysql_posts_table ORDER BY id DESC
LIMIT 5");
while($row = mysql_fetch_array($query))
{
global $default_title;
global $default_date;
global $default_id;
global $default_author;
$default_title = $row['title'];
$default_date = $row['date'];
$default_id = $row['id'];
$default_author = $row['author'];
$default_title = stripslashes($default_title);
$default_author = stripslashes($default_author);
}[/cpde]
It connects fine, but I get a:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bfplanet/public_html/articles/themes/BF3Planet/news.php on line 13
This is line 13:
while($row = mysql_fetch_array($query))
Im not sure whats wrong. but then under that I try to actually get some information by putting <?php print $default_title;?> but nothing shows up except the error. Do I have to define a row or what? Im not sure what to do after this
$query = mysql_query("SELECT * FROM $mysql_posts_table ORDER BY id DESC
LIMIT 5") or die(mysql_error());