Jump to content

Query Problem


gobbles

Recommended Posts

Hey All,

 

Im having some problems with a script of mine.

 

i have one MySQL table that has the value of an account i.e 'Free Account' = $0, 'Basic Account' = $300 .. then i have another table with the account id which would be 'Free Account' or 'Basic Account' and also a paid which is 'Yes' and 'No'

 

How could i combine 2 tables into one search.

 

What i want to do, is check if an account is paid, if the paid column is 'no' then display $0, but if it is 'yes' then check the account id and match it with the account id on the other table and return the value i.e $300 of that account.

 

If that makes sense to anyone, i would really like some help.

 

Cheers.

Link to comment
Share on other sites

you would run the query:

 

<?php
//Get it from the "SEARCH" form...
$accountname = $_POST['account_name'];
$result = mysql_query("SELECT * FROM table_name WHERE account_name= '$accountname'");

//Then you would output it in a variable
$i = 0;
$num = mysql_numrows($result);
$accoutname=mysql_result($result, $i,"Account Name");
$paid=mysql_result($result, $i,"Paid");
while ($i < $num) {
echo $accountname;
echo $paid;
}
?>

 

There's a basic listing for a search function

Link to comment
Share on other sites

Im sure theres a left join in there somewhere.

 

Here is the table layout

 

----------------------------------

| packages      | advertisers        |

----------------------------------

| id                | plan                  |

| price            | paid                  |

|                  | id                    |

|                    | signup_date      |

|                    | venue_name      |

----------------------------------

 

The ID field in the packages table and the PLAN field in the advertisers table are the ones that have the same values.

 

SELECT * FROM both tables where packages.id = advertisers.plan AND paid = YES

 

Thats basically what i need to do

 

If someone could actually put that into a SQL statement, it would REALLY help me out

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.