Main Menu
Search
EnglishUnited Kingdom

PHP expert needed!

Started by Ray, February 29, 2012, 03:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ray

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! :(

Statik

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

Ray

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

THeDoGG


Ray

Quote from: THeDoGG on February 29, 2012, 03:56 PM
lol @ php !
Please, either contribute to the topic or bring your wasteful ideas of your Ruby joke somewhere else.

darKz

lol @ ray !

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

Statik

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.

Quote from: Ray on February 29, 2012, 04:03 PMPlease, 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

Ray

Quote from: Statik on February 29, 2012, 04:30 PMAlso 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.

Quote from: Statik on February 29, 2012, 04:30 PM2) don't print html code with echo, better include php into html.
Why?

GreatProfe

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 :)

Statik

QuoteWhy?

Compare:


<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

Ray

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. :)

GreatProfe


Statik

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

Ray

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. :-*

GreatProfe

ae gj Statik

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