Need help with array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Need help with array

Post by Celauran »

Rovch wrote:Actually you're right, however what initially changes 'is_show' in the table?

Can I completely get rid of 'is_show' and use something like:

Code: Select all

$month = $date("n");	
return $db->query("SELECT DISTINCT month_id from travel WHERE month_id=".$month." ORDER BY 1 ".($parms['start'] == 12 ? 'DESC' : '')." ".$limit);
And hopefully not change anything else.
It's worth a try. I have no idea what sets is_show or where else it might be used; this isn't my code.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Need help with array

Post by Celauran »

Rovch wrote:For some reason I can't get PHP to identify month number like this:

Code: Select all

date_format($date, "n")
That should work assuming $date is a DateTime object.
Rovch wrote:Also, how would I go about getting two months instead of one out of this? So far I can only get one month to output properly.

Code: Select all

 return $db->query("SELECT DISTINCT month_id from travel WHERE month_id=".$month." ORDER BY 1 ".($parms['start'] == 12 ? 'DESC' : '')." ".$limit);

Code: Select all

return $db->query("SELECT DISTINCT month_id from travel WHERE month_id >= ".$month." ORDER BY 1 ".($parms['start'] == 12 ? 'DESC' : '')." ".$limit);
Rovch
Forum Newbie
Posts: 10
Joined: Wed Feb 01, 2012 8:26 pm

Re: Need help with array

Post by Rovch »

Celauran, thanks a lot for help. But I ended up writing my own code.
See, somehow 'is_show' is an algorithm that edits itself and shows three proper links.
Although each month has three. table only holds 24.. I am just going to end up bumping that up to 36.

It's too risky to mess with that class because I don't know if anything else relies on it.

Thanks a lot for help tho.
Post Reply