adam291086 Posted October 4, 2007 Share Posted October 4, 2007 how do i seach through a specific column of data within a database for the highest value? Quote Link to comment https://forums.phpfreaks.com/topic/71793-search-a-database/ Share on other sites More sharing options...
jaymc Posted October 4, 2007 Share Posted October 4, 2007 MAX() Or use ORDER BY DESC And this should be in MYSQL section Quote Link to comment https://forums.phpfreaks.com/topic/71793-search-a-database/#findComment-361546 Share on other sites More sharing options...
adam291086 Posted October 4, 2007 Author Share Posted October 4, 2007 Ok. I have a next button and it works. The way it works is by adding 1 to the photo Id that is posted from a pervious page. I have got the code to count the number of photos on display. This is stored in an array. I then have an If statement say If the photo on display = 0 then redirect. But the page doesn't redirect it displays all the links and no pictures. Can you help? // get picture details $con; $sql = "SELECT photo_title, photo_id, photo_location, album_id FROM photos WHERE photo_id = " . addslashes($_GET['photo_id']); $result = @mysql_query($sql) or die("Error retrieving record: " . mysql_error()); while($row = @mysql_fetch_array($result)) { $photo_title = $row['photo_title']; $photo_loc = $row['photo_location']; $album = $row['album_id']; $photo = array($column['photo_id']); } // stop blank pictures $empty = count ($photo); echo $empty; If ($empty ==0){ header('Location: http://www.example.com/'); } Quote Link to comment https://forums.phpfreaks.com/topic/71793-search-a-database/#findComment-361554 Share on other sites More sharing options...
jaymc Posted October 4, 2007 Share Posted October 4, 2007 echo $empty; If ($empty ==0){ header('Location: http://www.example.com/'); } Your echoing before your calling a header set At a guess, because I dont actually know, I'd say if you print anything before you set a header it will cause problems Serves the same princeable as when using cookies, they must be set before anything is sent to the page Just try taking away the echo and ammend your code so that if the photo is 0 then location can be set before anything else is on the page Quote Link to comment https://forums.phpfreaks.com/topic/71793-search-a-database/#findComment-361620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.