Jump to content

Recommended Posts

well i have got this but it does not work

 

$query = mysql_query("SELECT `post_num` FROM `zBoard_messages` WHERE board_id='$board' ORDER BY `post_num` DESC LIMIT 1") or die(mysql_error());
$fetch= mysql_fetch_assoc($query) or die(mysql_error());
$psot_num = $fetch['post_num'];
$post_num++;

 

it just inputs 1 into the database

Link to comment
https://forums.phpfreaks.com/topic/55245-solved-mysql-max/#findComment-273054
Share on other sites

cheers but it is still producing one

 

this is my whole code

 

<?php

// Start Session
session_start();
if(!isset($_SESSION['username']) && !isset($_SESSION['id']) && !isset($_SESSION['password']))
{
header("Location: login.php");
} else
{
require_once('page_header.php');
$id = $_SESSION['id'];
$username = $_SESSION['username'];
if($_POST)
{

$poster = $id;
$board = '1';

// get actual message
$original = $_POST['message'];
$text = $original;

require_once('bbcode.php');

$date = date('YmdHia');

$query = mysql_query("SELECT MAX(post_num) FROM `zBoard_messages` WHERE board_id='$board'") or die(mysql_error());
$fetch= mysql_fetch_assoc($query) or die(mysql_error());
$psot_num = $fetch['post_num'];
$post_num++;

$query = "INSERT INTO `zBoard_messages` (poster_id,board_id,post_num,subject,message,date) VALUES ('$poster','$board','$post_num','$subject','$original','$date')";
mysql_query($query) or die(mysql_error());
header("Location: thanks.php");
} else {
?>
<html>
<body>
<form name="name" method="post" action="<?php $PHP_SELF ?>">
<center>
<br />
<input type="text" name="subject" id="subject" value="<?php $subject ?>" />
<br />
<br />
<textarea name="message" value="<?php $original ?>" cols="60" rows="15"></textarea>
<br />
<br />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
</center>
</body>
</html>

<?php

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/55245-solved-mysql-max/#findComment-273063
Share on other sites

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.