Kiubbo Posted February 12, 2009 Share Posted February 12, 2009 Somebody coded me halfway a site like digg in rentacoder, (when the price looks too cheap, that is what you get) and I am trying to finish it. So the links get ranked all right after they get the second vote, but with just one vote they get sorted backwards (the newest are last). I suspect the answer is in this piece of code: static function getById($id) {/* * Return one record from the database by its id */ $db = null; $record = null; try { $db = parent::getConnection(); $query = "select id, username, created, modified, title, url, description, points, ranking from articles where id = $id"; $results = parent::execSQL($query); if(!$results) { throw new Exception ('Record not found', EX_RECORD_NOT_FOUND); } $row = $results->fetch_assoc(); parent::closeConnection($db); if(!get_magic_quotes_gpc()) { $row['title'] = stripslashes($row['title']); $row['description'] = stripslashes($row['description']); } $article = new Article($row['title'], $row['description'], $row['url'], $row['username'], $row['created'], $row['modified']); $article->id = $row['id']; $article->points = $row['points']; $article->ranking = $row['ranking']; return $article; } catch (Exception $e){ throw $e; } } If someone can help, Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/144878-id-order/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.