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 Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/ 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 Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604368 Share on other sites More sharing options...
MasterACE14 Posted July 31, 2008 Share Posted July 31, 2008 What are you trying to do exactly? Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604370 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. Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604372 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"; } Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604376 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"; Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604380 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. Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604386 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. Link to comment https://forums.phpfreaks.com/topic/117497-solved-ifelse-question/#findComment-604395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.