Jump to content

Recommended Posts

well for most recent, you would probably want to have the date logged when they post, sort  by date, like have a field called
postdate
have it put a time stamp there whenever they post
then on the homepage
have
$select = "SELECT * FROM tablename SORT BY postdate LIMIT 4;";
$query = mysql_query($select);
while ($row = mysql_fetch_array) {
// whatever to display
$controller = true; // or whatever variable
}
if ($controller != true) {
echo "There are no recent entries";
}
you probably wouldn't need the message if it's a forum though because there will always be recent entries, just the last 3 posted entries.
table field name could be timeentry
$variable = time();
to display it
it's the same thing
$select = "SELECT * FROM tablename SORT BY postdate, timeentry LIMIT 4;";
I don't remember what goes in between those and I don't have time to check it's either
postdate AND timeentry
postdate OR time entry
postdate, time entry
it's one of the three.
$select = "SELECT * FROM tablename SORT BY postdate LIMIT 4;";
$query = mysql_query($select);
while ($row = mysql_fetch_array) {
// whatever to display
$controller = true; // or whatever variable
}
if ($controller != true) {
echo "There are no recent entries";
}

Alright were it says "what ever to display" what exactly would go there?
[code]It depends on how you wanted to display it, with tables it would be like
<?php
echo "<table>";
while ($row = mysql_fetch_array) {
echo "<tr><td>$variable</td></tr>";
$controller = true; // or whatever variable
}
echo "</table>";// tables outside of while, or it redoes table every circle through
?>[/code]
Just put the data in a formatted table, I can't do it for you, ebcause I don't have time and because I don't know how many fields you have, or you can use lists
[code]<?php
echo "<ul>" or echo "<ol>" // more of ul
while ($row = mysql_fetch_array) {
echo "<li>{variablename}</li>";
echo "<li>{varieblename2}</li>";
$controller = true; // or whatever variable
}
echo "<ul" or echo "<ol>" // more of ul[/code]
of course each call you make to the db variable you have to use the variable you used to access it, in this case it would be
$row['variablename']
or
$row['variablenamer']
when extrapolating they teach you to leave off the ' ' like
$row[variablename]
$row[variablename2]
Parse error: parse error, unexpected '}' in /home/spxxxrw/public_html/mf/recentforum.php on line 9

<?php

$dbh=mysql_connect ("localhost", "spxxxrw_Axxxxn", "asxxxxxxx96") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("spyderw_dk");

$select = mysql_query("SELECT author,newpostdate,title, FROM spxxxxxw_forum ORDER BY `newpostdate` DESC LIMIT 3");
$total=1;
while($row = mysql_fetch_array($select))
}
if(isset($_GET['display'])) echo $recentforum;
?>


Any idea whats wronge with it?

"xxx" added for secur.
[code]
<?php
$dbh=mysql_connect ("localhost", "spxxxrw_Axxxxn", "asxxxxxxx96") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("spyderw_dk");

$select = mysql_query("SELECT author,newpostdate,title, FROM spxxxxxw_forum ORDER BY `newpostdate` DESC LIMIT 3");
$total=1;
while($row = mysql_fetch_array($select)) {
}
if(isset($_GET['display'])) echo $recentforum;
?>
[/code]
[code]if(isset($_GET['display'])) echo $recentforum;[/code]
That is not good practice, I was shown this before, someone corrected if not I would have made a grave mistake
it's always
[code]<?php
if (isset($get['display'])) {
echo $recentforum; // even here I like echo "{$recentforum}";  just depends on preference
}
// or
if (isset($get['display']))
{
echo $recentforum;
}
// I prefer the top
?>[/code]
I put in what you gave me and got this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/spyderw/public_html/mf/recentforum.php on line 7

<?php
$dbh=mysql_connect ("localhost", "spyxxxton", "ashtxxx596") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("spydxxxk");

$select = mysql_query("SELECT author,newpostdate,title, FROM spydexxxum ORDER BY `newpostdate` DESC LIMIT 3");
$total=1;
while($row = mysql_fetch_array($select)) {
}
if(isset($_GET['display'])) echo $recentforum;
?>
Parse error: parse error, unexpected $ in /home/spyderw/public_html/mf/recentforum.php on line 11

[code]<?php
$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("spyderw_dk");

$select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3");
$total=1;
while($row = mysql_fetch_array($select)) {
}
if (isset($get['display'])) {
echo $recentforum; // even here I like echo "{$recentforum}";
?>[/code]
[code]<?php
$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("spyderw_dk");

$select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3");
$total=1;
while($row = mysql_fetch_array($select)) {
}
if (isset($get['display'])) {
echo $recentforum; // even here I like echo "{$recentforum}";
}
?>[/code]
[code]<?php
$dbh=mysql_connect ("localhost", "spyderw_Ashton", "ashton2004596") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("spyderw_dk");

$select = mysql_query("SELECT author,newpostdate,title, FROM spyderw_forum ORDER BY `newpostdate` DESC LIMIT 3");
$total=1;
while($row = mysql_fetch_array($select)) {
}
if (isset($get['display'])) {
echo $recentforum; // even here I like echo "{$recentforum}";
}
?>[/code]
The code here doens't make sense to me though, your while statement is doing absolutely nothing.
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.