secoxxx Posted July 31, 2008 Share Posted July 31, 2008 Anyone know how i would go about somthing like this.... if "the last record in the database" echo ('NEW!'); else blank Quote Link to comment Share on other sites More sharing options...
niranjnn01 Posted July 31, 2008 Share Posted July 31, 2008 could you give more information as to what your requrement is ? There is one suggesstion, not a solution. maybe it will help Try changing your logic to this write a query to get the data in the ascending order [with respect to some field like id or time - which we know, whose data will be in some definite order.] get the data into an array, and do the processing for all elements, till you reach the last element. when you reach the last element, echo ('NEW!'); or, if you want to detect the last row of the table, then sort the query in descending order with respect to some field like time, id etc Regards Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted July 31, 2008 Share Posted July 31, 2008 What are you trying to do exactly? Quote Link to comment Share on other sites More sharing options...
secoxxx Posted July 31, 2008 Author Share Posted July 31, 2008 i have a list from the database. SELECT * FROM dvd ORDER BY dvd_id DESC this shows everything i want, but i want to add a NEW! under the lastest dvd added thumbnail im just not sure how to integrate a if else into a query or if i even need to. Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 31, 2008 Share Posted July 31, 2008 if ($newdvd == 1); { echo "SHOWTHIS"; } else { echo "if not show this"; } Quote Link to comment Share on other sites More sharing options...
paul2463 Posted July 31, 2008 Share Posted July 31, 2008 $query = "SELECT * FROM dvd ORDER BY dvd_id DESC"; $result = mysql_query($query) or die ("Error in query " . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo "$row['name'] </BR>"; } echo "NEW"; Quote Link to comment Share on other sites More sharing options...
niranjnn01 Posted July 31, 2008 Share Posted July 31, 2008 I think its better you have an additional field "new_entry", which can be set to 0 or 1, and as you display , check this fields value for each, and if its 1, echo NEW. Quote Link to comment Share on other sites More sharing options...
secoxxx Posted July 31, 2008 Author Share Posted July 31, 2008 niranjnn01, thanks, i guess that was the easiest way to do it, i didnt want to add another field but this seems to work fine. Quote Link to comment 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.