Jump to content

Big Problem with mysql :(


Demonic

Recommended Posts

Alright right now im selecting topics from my database like this:

$topics = mysql_query("SELECT * FROM topics WHERE fid='$fid' ORDER BY timestamp DESC") or die(mysql_error());


ok it displays the new topics from newest how can make it so it bumps topics? when you add a reply?
Link to comment
Share on other sites

can you give me a brief idea

topics table
[quote]
CREATE TABLE `topics` (
  `id` int(9) NOT NULL auto_increment,
  `timestamp` int(20) NOT NULL default '0',
  `fid` int(4) NOT NULL default '0',
  `title` varchar(255) NOT NULL default '',
  `post` longtext NOT NULL,
  `username` varchar(32) NOT NULL default '',
  `last_post_username` varchar(32) NOT NULL default '',
  `replies` int(9) NOT NULL default '0',
  `views` int(9) NOT NULL default '0',
  `sticky` int(10) NOT NULL default '1',
  `closed` int(10) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=31 ;
[/quote]

replies table
[quote]
-- Host: localhost
-- Generation Time: Aug 29, 2006 at 07:35 AM
-- Server version: 4.0.27
-- PHP Version: 4.4.2
--
-- Database: `nev_php4skill`
--

-- --------------------------------------------------------

--
-- Table structure for table `replies`
--

CREATE TABLE `replies` (
  `id` int(9) NOT NULL auto_increment,
  `tid` int(9) NOT NULL default '0',
  `post` longtext NOT NULL,
  `username` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=14 ;
[/quote]
Link to comment
Share on other sites

When someone adds a new reply you have to get it to edit the `timestamp` of the topic.

Heres a couple things i notice you may also change...

  `replies` int(9) NOT NULL default '0',

This is not needed. You can use a query like "SELECT * FROM replies WHERE tid='$tid'" then use mysql_num_rows() on the query to find out how many replies there are...

You may want to add Time of first posting for replies and topics.
Link to comment
Share on other sites

like you said could i do a simple query and update that topics timestamp

when a user make a reply as you said i could do

$newtime = time();
mysql_query("UPDATE topicname SET timestamp='$newtime' WHERE id='$s' ");

think that would work?

($s is the _GET of the page :))
Link to comment
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.