Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    gathering results from db.

    I am developing a not for profit website to enable people to generate a bespoke tour itinerary for initially Bulgaria but hopefully other countries as well. The address is Bespoke Tour Planner.

    I am a novice in php and hope you may be able to help me.
    I have a db that shows a range of subjects and individual numbers for each.
    I need to create a form that displays these results to the user.

    ie monasteries 10
    ski runs 7
    archeological sites 8

    if the db result is 0 then neither the name or quantity are not displayed.

    It would be even better if the results can be moved up when result is 0
    ie
    monasteries 10
    ski run 7
    archeological sites 8

    when ski run = 0 becomes

    monasteries 10
    archeological sites 8

    If anyone can offer help could you show me a script and explain how it works.
    Thanks in anticipation
    Alan

  • #2
    Regular Coder
    Join Date
    Jun 2009
    Posts
    146
    Thanks
    3
    Thanked 21 Times in 21 Posts
    You need to run a query to get the number of each, you can use PHP to sort and organise them, but its smarter to use the power of mysql

    PHP Code:
    SELECT A.trip_typeCOUNT(*) AS number_of_this_group
    FROM trip_type_groups 
    AS A
    INNER JOIN trips 
    AS B ON A.group_id B.parent_group
    GROUP BY B
    .trip_type
    ORDER BY number_of_this_group 
    The INNER JOIN excludes any that dont have matches ie. the ski run
    The ORDER BY is what puts them in the order you wanted
    Last edited by itxtme; 03-05-2014 at 09:20 PM.


  •  

    Tags for this Thread

    Posting Permissions

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