Forums
May 15, 2024, 02:49 PM

Author Topic: PHP expert needed!  (Read 5317 times)

0 Members and 1 Guest are viewing this topic.

Offline Ray

PHP expert needed!
« on: February 29, 2012, 03:22 PM »
Hey!

I wrote a neat little calendar script, only for displaying purpose - yet - and I have a small problem that I cannot seem to figure out by my own. Right now, the display of the days - according to PHP's documentation - start from Sunday by default. Now I'd need that to be Monday but I just cannot figure out a way to do it. I'll show you the script so you can see the code and also, take a look at how it looks:

http://pentzzsolt.web.elte.hu/index.php

Please help me, I f@#!ed around a lot with that for loop, but the result was always leaving empty rows or there were two Mondays after each other... I'd appreciate if you could help me! :(

Re: PHP expert needed!
« Reply #1 on: February 29, 2012, 03:36 PM »
Maybe show your code? :)

Here is PHP date() function: http://php.net/manual/en/function.date.php
"N" stands for ISO-8601 numeric representation of the day of the week (1 - Monday, 7 - Sunday).

Also you may find JavaScript-way more cool: http://jqueryui.com/demos/datepicker/#inline ;)


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #2 on: February 29, 2012, 03:41 PM »
Ah yea I forgot to attach the code!

I won't use JavaScript for development, JavaScript and it's libraries should only be used to add more features to a 100% done and working, tested work. It can be turned off and users can miss out the navigation menu or a core function - like this calendar - and navigate away from the site, which we don't want to happen, obviously. :)

And yea, I know the date() function, didn't find what I needed. :-X

Offline THeDoGG

Re: PHP expert needed!
« Reply #3 on: February 29, 2012, 03:56 PM »
lol @ php !

Offline Ray

Re: PHP expert needed!
« Reply #4 on: February 29, 2012, 04:03 PM »
lol @ php !
Please, either contribute to the topic or bring your wasteful ideas of your Ruby joke somewhere else.

Offline darKz

Re: PHP expert needed!
« Reply #5 on: February 29, 2012, 04:26 PM »
lol @ ray !

Sorry, couldn't resist. :D <3
I remember knowing who it was but dont remember exactly what I knew
~ Dubc 2010

Re: PHP expert needed!
« Reply #6 on: February 29, 2012, 04:30 PM »
It should be smth like this (attached).

Also I have to disagree about JavaScript. In modern applications there can be more JS code than PHP (Ajax, jQuery and other stuff), disabled JS in browser => gtfo xD

About your code:
1) you should add missing <td>'s and </tr> for the last week;
2) don't print html code with echo, better include php into html.

Please, either contribute to the topic or bring your wasteful ideas of your Ruby joke somewhere else.

Ruby fans? xD


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #7 on: February 29, 2012, 04:39 PM »
Also I have to disagree about JavaScript. In modern applications there can be more JS code than PHP (Ajax, jQuery and other stuff), disabled JS in browser => gtfo xD
Yes, there can be more, after every core feature and value of a website is reachable through plain HTML. And "gtfo" is the attitude why so many website developers lose customers.

2) don't print html code with echo, better include php into html.
Why?

Offline GreatProfe

Re: PHP expert needed!
« Reply #8 on: February 29, 2012, 04:47 PM »
i would like to help You Ray, but i am not a specialist in caledaries... Tbh i never needed to use it.

Anyway i wanna check ur code and make some tests here :)

Re: PHP expert needed!
« Reply #9 on: February 29, 2012, 05:08 PM »
Quote
Why?

Compare:

Code: [Select]
<div class="mm">
    <p class="barman"><strong><?php echo $barman['name']; ?></strong></p>
</div>

and

Quote
echo '
<div class="mm">
    <p class="barman"><strong>'.$barman['name'].'</strong></p>
</div>';

The first one looks more pretty, huh? :)


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #10 on: February 29, 2012, 05:16 PM »
Absolutely not. The only reason to use your method would be that if an error occours in the PHP script, you can more easily determine the source of the error. Otherwise, opening and closing <?php and ?> every single time when you want to output a variable is just such a huge pain in the ass, imagine a site like this, where basically every word is a variable, due to it's multilinguality.

Your code was working well by the way, thank you, I got what you modified. :)

Offline GreatProfe

Re: PHP expert needed!
« Reply #11 on: February 29, 2012, 05:27 PM »

Re: PHP expert needed!
« Reply #12 on: February 29, 2012, 05:32 PM »
All the best PHP frameworks use the first method or short syntax (<?=$var?>) or some template engine ({%var%}). Second method fails when there are different quotes inside, each of them will require "\". If you still prefer this way, then I would recommend to use heredoc synax.

Good luck! :D


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #13 on: February 29, 2012, 05:41 PM »
Yes Professor, that is what I needed, Statik's version is also working well, but thanks anyway.

Well Statik, so far I haven't ran into any project which I couldn't handle with the methods I use (except from a few minor stupidities like this one :D) but note I'm pretty much a beginner at this field.

Thanks for your help dude. :-*

Offline GreatProfe

Re: PHP expert needed!
« Reply #14 on: February 29, 2012, 05:47 PM »
ae gj Statik

TUS is protected agains the machine coz We have fcking pro php developers xD