SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 39 of 39

Thread: Group by php

  1. #26
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  2. #27
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    That's a good point. Are there any good standardised OOP techniques that allow for proper highlighting of HTML code?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #28
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any particular examples? Keep it short I guess, ie make methods that deal with form elements, rather than the whole form.

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    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
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hash View Post
    Use the count query to get table two above, use php to create links for each row, pass the price in the link, use a where query to get all rows for that price. Is that what you mean?
    Yeah thatís what I meant, I actually thought there was a neater way of doing it, but thanks everyone for the input.

  6. #31
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oddz View Post
    Code SQL:
    SELECT
         p.price
         ,p.prices
         ,t.id
      FROM
         (SELECT
               t.price
               ,COUNT(*) prices
            FROM
               my_table t
           GROUP
              BY
               t.price) p
     INNER
      JOIN
         my_table t
        ON
         p.price = t.price

    The other solution is to eliminate the subquery and count the number of number of rows per price in PHP. In either case your going to need to format the result set on the application side. So I would run a simple select for everything then handle the aggregate calculations on the application side while parsing the result set into a price => rows pair. You could also do as hash said and run the count query then a query for each individual row that pertains to the given price.
    this is well thought too, more towards what I was looking for

  7. #32
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #33
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #34
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #35
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    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.
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #36
    SitePoint Evangelist
    Join Date
    Apr 2005
    Location
    London, UK
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    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.
    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?

  12. #37
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  13. #38
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,032
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    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.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  14. #39
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Hear hear.

    There is an on-going discussion/argument/dollybrook going on at the moment in the JavaScript forum about 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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •