Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

alphanumetrix's Achievements


Newbie (1/5)



  1. Um... I never really figured out a solution using just SQL, but I re-did it with some PHP, and a modified table, now I have the same desired result. Since no one seems to know how to figure this out, I'll just close this as solved.
  2. notice how there are no duplicate series & it shows the maximum placement for each of those series, as well as it is ordered by date
  3. This code isn't exactly right... I need the ENTIRE row WHERE the max placement is, and the results have to be DISTINCT based on the SERIES... So I don't want any duplicate series...I basically just want the ENTIRE ROW where HIGHEST placement is from EACH series and order them by date.. Make more sense? The code you had gave me a result like this: max(placement) 12 13 13 13 24 13 25 45 26 25 The result I'm looking for is going to be like this: Series Placement date 314 12 December 30, 2009, 9:04 am 313 13 December 30, 2009, 9:02 am 312 13 December 30, 2009, 9:02 am 309 13 December 30, 2009, 8:59 am 306 24 December 26, 2009, 6:01 pm 307 13 December 26, 2009, 5:59 pm 308 25 December 26, 2009, 5:58 pm 303 45 December 26, 2009, 4:13 pm 41 90 December 26, 2009, 4:06 pm
  4. Nope, that's not what I'm looking for. I'm looking for the highest Placement of EACH series ordered by date.
  5. No one can help me with this??? I know of several alternatives to this problem, but I would MUCH rather do it with just this SQL statement.
  6. Yeah, no problem. I tried to keep it simple in my description above, because the design is a little more complex in actuality, because of the purpose of the website. Here is a dump of the two tables (not data actually added--i would, but the database has in excess of 10 thousand, so you can see why i didn't... & it's actually data that is not meant to be disclosed publicly): -- phpMyAdmin SQL Dump -- version 3.1.5 -- http://www.phpmyadmin.net -- -- Host: mysql1026.servage.net -- Generation Time: Dec 30, 2009 at 08:49 PM -- Server version: 5.0.85 -- PHP Version: 5.2.42-servage13 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `bliljerk10121` -- -- -------------------------------------------------------- -- -- Table structure for table `links` -- CREATE TABLE IF NOT EXISTS `links` ( `id` int(6) NOT NULL auto_increment, `placement` int(10) NOT NULL, `owner` int(10) NOT NULL, `date` text NOT NULL, `type` varchar(255) NOT NULL, `ext` varchar(255) NOT NULL, `size` int(6) NOT NULL default '0', `quality` varchar(120) NOT NULL default 'N/A', `link` text NOT NULL, `hits` int(10) NOT NULL default '0', `series` int(6) NOT NULL, `episode` varchar(50) NOT NULL, `details` text NOT NULL, UNIQUE KEY `id` (`id`), KEY `type` (`type`,`series`,`episode`), KEY `ext` (`ext`), KEY `size` (`size`), KEY `owner` (`owner`), KEY `quality` (`quality`), KEY `hits` (`hits`), KEY `placement` (`placement`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10146 ; -- -------------------------------------------------------- -- -- Table structure for table `series` -- CREATE TABLE IF NOT EXISTS `series` ( `id` int(6) NOT NULL auto_increment, `date` varchar(255) NOT NULL, `published` int(10) NOT NULL default '1', `name` varchar(255) NOT NULL, `site` varchar(255) NOT NULL, `picture` text NOT NULL, `status` varchar(125) NOT NULL, `description` text NOT NULL, UNIQUE KEY `id` (`id`), UNIQUE KEY `site` (`site`), KEY `date` (`date`), KEY `name` (`name`), KEY `published` (`published`), KEY `status` (`status`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=315 ;
  7. Okay, so I have two tables... "series" & "links" Series Table looks like: id, name The links table looks like: id, placement, date, series Now I'm basically trying to get the latest links (latest means the highest "placement") for EACH series in order of the DATE of the link... What I've come up with is this, but it's not working at all: "SELECT MAX( placement ) AS max_placement, max( date ) AS max_date FROM links GROUP BY series ORDER BY max_date DESC LIMIT 0 , 30"
  8. Hey, I think we are working on the same (or at least a similar) project. Mark asked me to help you out. I am not sure how to do this with MySQL, but there are a couple ways of doing this using PHP. How many users are you working with?
  9. Hmm... If you are going to strip all the tags, then maybe you should try the "fgetss" function. Should be here: http://php.net/fgetss
  10. PCRE functions are slow & inefficient. Just try the DOMDocument parser (depending on your PHP configuration, you should be able to use it). *Note, parsing XML with DOMDoc. is also slow & inefficient, if there are better alternatives available... but this is definitely a better choice than PCRE from what you said. IE: function parseTagData( $tag, $xml, $single = false, $dir = true ) { $parser = new DOMDocument(); if ( $dir === true ) $parser->load( $xml ); else $parser->loadXML( $xml ); $data = $parser->getElementsByTagName( $tag ); if ( $single === false ) { $collected = array(); foreach ( $data as $d ) array_push( $collected, trim( $d->nodeValue, "\n" ) ); } else { $collected = $data->item(0)->nodeValue; } return $collected; } /* should print "title here" */ echo ( parseTagData( "h3", "file.html", true ) ); /* should print "first paragraph of text here - another one here - " */ $paragraphs = parseTagData( "p", "file.html" ); foreach ( $paragraphs as $p ) echo $p . ' - ';
  11. Are you running your site through an index (single file)? If so, just put the array in your main script, and all your files can have access to it. If you mean that you are creating an array for every user, a good idea would be to create a multi-dimensional array instead. IE of multi-dimensional array: $building_array = array( 'user1' => array('castle', 'storage', 'barracks', 'hospital', 'tower', 'inn'), 'user2' => array(1, 2, 3, 4, 5, 6) ); You can then access the data like this: echo $building_array['user1'][0]; // will display "castle" echo $building_array['user2'][0]; // will display "1" You can make the arrays more detailed by changing it like so: $building_array = array( 'user1' => array( 'castle' => 'some castle name', 'storage' => 'some storage name' ) ); echo $building_array['user1']['castle']; // will display "some castle name"
  12. You weren't kidding when you said it's big. You said it's only the one part giving you problems, right? Replace this part of the code: ////// BEGIN THUMBNAIL AND GALLERY CREATION... $imagenum++ ; $galleryname = $galleryname . $galnum . ".html" ; // Build full file name for gallery. $thumbfileread = opendir($thumbimages) ; // Read the file name of the thumb images. while($readthumb = readdir($thumbfileread)) { echo "$readthumb" ; } With this: ////// BEGIN THUMBNAIL AND GALLERY CREATION... $imagenum++ ; $galleryname = $galleryname . $galnum . ".html" ; // Build full file name for gallery. $thumbfileread = opendir($thumbimages) ; // Read the file name of the thumb images. $newarray = array(); while($readthumb = readdir($thumbfileread)) array_push($newarray, $readthumb); sort($newarray); foreach ($newarray as $n) echo $n; Battery is going to die any second, so I can't check it. But should fix it.
  13. Well, I can't do much with jus that bit of code. It doesn't even show the array you are storing the data in. In essence though, you typically have to give order to file results, by using sort(); IE: sort($array); Simple, no?
  14. I'll tell you the basics: never trust data from users, so always filter. It's considered tainted data. As far as the authentication goes IE: sessions/cookies. Make sure they can't be easily hijacked. IE: if you were allowing admins access by recognizing $_COOKIE['admin'] == 'admin' - then it could easily be hijacked via the URL using javascript: javascript:document.cookie='admin=admin'; Hope that helps some.
  15. Oh, well that's a completely different story. Neither of those will work for you. At least, not with the .php extension and <?php/?> tags (as file_get_contents renders what the server renders, so if the server can't recognize the php to parse, file_get_contents will display the php). Display the current PHP's source, would be a little more complicated. I would say the best way to do it, would be to open the file for reading, then echo out the contents in a textarea. Maybe like so: $filename = "CURRENT FILE HERE"; $h = fopen ($filename, "r"); $contents = fread ($h, filesize($filename)); fclose ($h); echo '<textarea cols=10 rows=20>' . $contents . '</textarea>'; See if that works... (don't forget to specify the file where I put "CURRENT FILE HERE")
  • 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.