Announcement

Collapse
No announcement yet.

Quick mysql/php Noob Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quick mysql/php Noob Question

    Hey,

    I have a mysql query in a php script. The query simply goes something like this.

    select * from blah,blahed,doo,boo where blah.blahid = blahed.blahid and doo.doid = boo.doid etc...

    The problem i have come across is that it only displays results which have enteries in all the tables listed in the query. I would like the query to display an entry even if there is not data for it in the doo and boo table. Any ideas on how this can be achieved?
    http://images.absolutepunk.net/images/andrew.gif

  • #2
    Try replacing your AND with OR.
    Lats...

    Comment


    • #3
      That helped somewhat, now it displays information when it is suppose to but it will display it over and over and over again until eventually by browser crashes lol. I am unsure why but thanks for your help it got me alittle closer .
      http://images.absolutepunk.net/images/andrew.gif

      Comment


      • #4
        Post your whole query string, there's probably something missing/extra/odd in there
        Lats...

        Comment


        • #5
          Here you go and thanks again for the help
          PHP Code:
                $desult mysql_query("
                SELECT * FROM Band,B_Event_Appearances,Event,S_Event_Apperances,Songs,Venue
                WHERE B_Event_Appearances.Band_ID = Band.Band_ID AND 
                B_Event_Appearances.Event_ID = Event.Event_ID OR Event.Event_ID = 
                S_Event_Apperances.Event_ID OR S_Event_Apperances.Song_ID = Songs.Song_ID AND      
                Event.Venue_ID = Venue.Venue_ID AND Event.Event_ID = 
          $_GET[event_ID]"
                or die(
          mysql_error()); 
          Last edited by Bratac; Fri 9 Sep '05, 6:31am.
          http://images.absolutepunk.net/images/andrew.gif

          Comment


          • #6
            The only reason it would display the content over and over again is because you're using a while loop.
            Code:
            while($var = $mysql_fetch_array($desults)){
            echo "content here";
            }
            change it to
            Code:
            $var = $mysql_fetch_array($desults);
            echo "content here";

            Comment


            • #7
              I am pretty sure it needs to be a while loop though because in some tables there are multiple results for one event.
              http://images.absolutepunk.net/images/andrew.gif

              Comment


              • #8
                can you post the url of the site?

                Comment


                • #9
                  well its actully on my laptop apache server and i don't want to upload it because it could be used to bring the server load super high lol.
                  http://images.absolutepunk.net/images/andrew.gif

                  Comment


                  • #10
                    Just to let you know i have actully solved the problem, it was down to not thinking about the database design enough which i then solved by having multiple queries instnead of just the one
                    http://images.absolutepunk.net/images/andrew.gif

                    Comment

                    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                    Working...
                    X