Group by php

heh ok complete sql fail :stuck_out_tongue: but was just trying to make the escaping point

I wonder, if it possible to make him understand at all.

SpacePhoenix, please, do me a favor?
Rewrite your code using, oh my - ok, prepared statements. And try to run it.

Potential issues are:

[list][]“View them” is repeated in plain text after the button
[
]The end of one result runs in to the start of another result
[/list]

Here’s one way to tidy things up


echo <<< EOT
<form method="get" action="script_that_displays_the_members">
    <p>There were $member_count member(s) found for membership type $member_type.</p>
    <p><input type="hidden" name="member_type" value="$member_type" />
       <input type="submit" value="View Them" />
    </p>
</form>

EOT;

And here’s another way


echo '<form method="get" action="script_that_displays_the_members">'
        . '<p>There were ' . $member_count . ' member(s) found for membership type "' . $member_type . '".</p>'
        . '<p><input type="hidden" name="member_type" value="' . $member_type . '" />'
            . '<input type="submit" value="View Them" /></p>'
    . '</form>';

Off topic I guess, but isn’t method three easier to read?

The difficulty with method three is that is it directly output to the page. While the example here uses echo, in real life we are more likely to return the html code so that it can be output at a later date when the time is right.

There are certain uses for the third method, but only when you’re not planning to store the html code for later use.

Well, if you meant $var = ‘html’ or return ‘html’, sure. Other than that there is no diff. I just find syntax highlighting to be useful :slight_smile:

That’s a good point. Are there any good standardised OOP techniques that allow for proper highlighting of HTML code?

Any particular examples? Keep it short I guess, ie make methods that deal with form elements, rather than the whole form.

Sorry, I’ll try to be more clear.

I’m wondering if there are any PHP coding techniques that allow us to use HTML code in such a way that it is not output immediately to the screen (thus satisfying OOP techniques) while also allowing the HTML code to be syntax highlighted by our code editors (thus satisfying our sense of readability).

Edit: s/out/our

Yeah that’s what I meant, I actually thought there was a neater way of doing it, but thanks everyone for the input.

this is well thought too, more towards what I was looking for :slight_smile:

You have to think of interface first.
First figure out what html you want and what happens if user click a link.
After this you can ask for the SQL query.

but only when you’re not planning to store the html code for later use.

Hey Paul.
But why we need that?
In the proper planned application we have all HTML in one place - in the template. And only use for it is output.
And template is more HTML than any other language - another reason to use third method.

Yep, links need to jus retrieve data fro the database (be immutable), because spiders will be crawling all over them and people can bookmark them and perform other crazy stuff with them.

Buttons are for actions that cause a data change to the server, whether they create, update, or delete information in the database.

Yeah, hangs head - I was using CRUD there.

Because I don’t know about you, but many times we are working with other people’s code, not to mention house-standards that may not be agreeable to be followed, but must be none-the-less.

yeah I usually do adapt a prototype approach when web deving, actually always. I dont know, but with web dev I hardly ever approch it from data structure point of view, unless I’m deving a web application. what is ur approach?

Unlike desktop application, web application has discrete nature.
Actually, each page acts more like separate application than part of main program.

Therefore, if you have a link on your page, which leads to another page, there are two separate programs to run. And second one don’t have access to first one’s data and you have to fetch it again. So, no need to fetch actual prices on the first page and there is no use for oddz’s query.

On the other hand, if you plan to fill some javascript array with this data and use some DHTML action instead of a hyperlink, you will need all your data. So, there is use for oddz’q query.

That’s why you have to go for interface first.

I apologize for my crude English. Such explanations are quite complicated for me.

Never rely on javascript being enabled on a given computer. Any web page or web app should be able to function (albeit slightly slower) with javascript disabled or blocked.

Hear hear.

There is an on-going discussion/argument/dollybrook going on at the moment in the JavaScript forum about [url=“How to build a desktop like application interface using JavaScript?”]How to build a desktop like application interface using JavaScript? where the common consensus is to start with a base HTML page and use CSS for presentation. Get the application working in a non-scripted environment, and only then use JavaScript to improve the user interface/experience.