Demonic Posted August 29, 2006 Share Posted August 29, 2006 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 https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/ Share on other sites More sharing options...
AndyB Posted August 29, 2006 Share Posted August 29, 2006 Without knowing your database structure, that's impossible. Link to comment https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81985 Share on other sites More sharing options...
Demonic Posted August 29, 2006 Author Share Posted August 29, 2006 can you give me a brief ideatopics 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 https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81987 Share on other sites More sharing options...
AndyB Posted August 29, 2006 Share Posted August 29, 2006 In the (apparent) absence of any timestamp specifically associated with a reply, it's difficult to see how you could do what you're asking. Link to comment https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81990 Share on other sites More sharing options...
DarkendSoul Posted August 29, 2006 Share Posted August 29, 2006 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 https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81991 Share on other sites More sharing options...
Demonic Posted August 29, 2006 Author Share Posted August 29, 2006 like you said could i do a simple query and update that topics timestampwhen 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 https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81993 Share on other sites More sharing options...
DarkendSoul Posted August 29, 2006 Share Posted August 29, 2006 topicname isnt the name of your table, but yes that would work. Link to comment https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81995 Share on other sites More sharing options...
Demonic Posted August 29, 2006 Author Share Posted August 29, 2006 i know topicname isnt the name of my topic table it was an example and it worked like i hoped it did. Link to comment https://forums.phpfreaks.com/topic/18967-big-problem-with-mysql/#findComment-81996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.