Jump to content

Recommended Posts

You cant query the result of a query, you can only manipulate the result through PHP - the way you do this entirely depends on how you want to manipulate the data.

 

Have you got a specific task in mind?

 

-cb-

 

yeah, i have this query, which works fine on its own, however as a result of the database it returns multiple the same values

 

$result=mysql_query("SELECT * FROM $stand WHERE id NOT IN (SELECT seatid FROM booking WHERE eventid = $event AND stand = '$stand')");

 

it then populates a dynamic drop down box with the available blocks, however due to the way the database is set out, that returns something like A1, A1, A1, A1, i had countered this before by using SELECT DISTINCT block FROM $stand but as far as im aware and ive tested, i cannot do something like that on the above query

When your looping the results you could have a match array:

$temporary = array();

// looping the results
while($row = mysqlq_fetch_array($result)){
   
   // Check if its been echoed before
   if(!isset($temporary[$row['block']])){
      // Flag it as being echod, then echo it.
      $temporary[$row['block']] = 1;
      echo $row['block'];
   }
}

 

im no good at mysql but i bet there will be a single magical query for you :P.

 

-cb-

Hows about "SELECT * FROM $stand WHERE id NOT IN (SELECT seatid FROM booking WHERE eventid = $event AND stand = '$stand') GROUP BY id " (assuming id is the field that you are returning).  Also, as a rule of thumb, avoid SELECT * wherever possible.

 

this post led me to the answer, thanks, instead of group by ID (which of course is different everytime and therefore does nothing i grouped it by the field which needed to be cut down to just 1 instance ie block) thanks for that.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.