Jump to content

Help with a QUERY


Canman2005

Recommended Posts

Minase

 

Your code worked spot on.

 

I'm wondering if anyone can help me further this code, basically I want to add another field to the "members" table called "code", so the table would look like

 

ID     NAME     CODE

1      David      A

2      Bob        B

3      Sarah     A

 

and then I want to alter the QUERY so that it only selects members with A in the code field and skips any member with B in their CODE field.

 

Can anyone help?

 

Masssive thanks to everyone who has helped so far

 

Dave

Link to comment
Share on other sites

$select = mysql_query("SELECT * FROM scores ORDER BY ID DESC LIMIT 1");

change that to

$select = mysql_query("SELECT * FROM scores ORDER BY ID DESC WHERE code = 'A' LIMIT 1");

its just 10 in the morning here,just waked up.hope it works :)

Link to comment
Share on other sites

Yep, that seems to do the job until you reach a row which doesnt have that code im asking for.

 

Because you're grabbing the next ID in the sequence, if that ID it returns doesnt equal what im asking then it just displays nothing.

 

If that makes sense?

 

Any ideas?

Link to comment
Share on other sites

Just stuck trying to get just the rows of the table "members" that have a particular code, but then auto skipping the ones that dont have that code.

 

it cant work with

 

$return = "SELECT id, name, code FROM members WHERE id = '".$id."' AND code = '' ";

 

because as soon as a row is returned without the correct code you are asking it for, it simply returns an empty row.

Link to comment
Share on other sites

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.