hi, i was wondering if someone could help me with this
<?php include 'main.php';?>
<?php
$result=mysql_query(" SELECT * FROM form");
$option= "date";
while($row=mysql_fetch_array($result))
{
$option .= "<option";
if (isset($_POST['form']) && $_POST['form'] == $row['date']) {$option.= " selected='selected'";}
$option .= ">" . date ('F Y',$row['date']) . "</option>";
}
?>
<form method= "POST">
<select>
<?php echo $option ;?>.
</select>
<input type="submit" name="Submit" id="submit" value="Go">
</label>
</form><?php mysql_close($conn); ?> </div>
that collects the date from tables in my database, but i only want it to show the month and year once ( not for every post made ( its a blog ))
then when the next month comes, if i make a post, or more than one, i want it do display that month and year ( once ), but if i don't make a post, i don't want that month to show in the menu.
i also have a pagementation for the main page
<?php include 'config.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db( $dbname, $conn );
$perPage = 5; // number to display on per page
// Start by counting the number of posts
$res = mysql_query ("SELECT count(*) AS num FROM form") or die (mysql_error() . 'dying hurts');
$num = mysql_fetch_assoc($res);
$num = $num['num'];
mysql_free_result($res);
// now work out how many pages there are, check if page has been sent via GET
$numPages = ceil($num / $perPage);
// Check to make sure pagenum will be 1 or greater, less than numpages and an actual number
$pageNum = (!empty($_GET['id']) &&
is_numeric($_GET['id']) &&
$_GET['id'] > 1)
? ($_GET['id'] < $numPages ? ($_GET['id']) : $numPages) : 1; // Set to 1 if not set or something dodgy
// Okay, now we run the query and set the limits LIMIT xx, yy (x= start from , y= limit)
$sql = "SELECT * FROM form ORDER BY date DESC LIMIT " . ($pageNum - 1) * $perPage . ", $perPage";
$res = mysql_query($sql, $conn) or die(mysql_error());
while ($row = mysql_fetch_object($res)) {
echo '<hr></hr>';
print $row->title ;
echo nl2br("\n");
print strftime('%d %B %Y', $row->date);
echo nl2br("\n");
echo nl2br("\n");
print $row->blog_mes;
}
// Some paginananananananation
echo '<div>';
for ($i = 1; $i <= $numPages; $i++)
{
if ($pageNum != $i)
echo '<a href="index.php?id=', $i, '">', $i, '</a> ';
else
echo '<b>', $i, '</b>';
}
echo '</div>';
?>
also if the person uses the drop down i need it to only display the posts for that month
this is getting really complicated, i am new to php but i need this feature to work
can you help ?
thank you