Hello and welcome to our community! Is this your first visit?
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
    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
    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

  2. #2
    Regular Coder
    Join Date
    Jun 2009
    Thanked 22 Times in 22 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
    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