Following are the tables:
Table User:
User_Id = 1,2,3;
User_Name: A,B,C;
Table Business:
Business_Id = 1,2,3;
Business_Name: A,B,C;
Business_Detail: Details_A, Details_b, Details_c;
Table Visits:
Visit_Id = 1,2,3,4,5,6:
User_Id = 1,1,1,2,1,1;
Business_Id = 1,1,1,2,2,3;
I need to create a function that return a list of the visits and the information about the business that the user visited. So far I have got the list of the store the user has visited but don't know where to go from there.
function visit_count($user_id=1){
global $database;
$sql = "SELECT * FROM visits WHERE user_id ='{$user_id}' LIMIT 0 , 30";
$result_set = $database->query($sql);
$visits = mysql_fetch_array($result_set);
//Get the unique ids of the business
//Run another query that has the business information
//combing both queries.
}
Thanks for the quick response guys. It's pretty much what I am looking for I think I am looking for the query to return an object as following:
Object:
- Business:
- Business_id;
- Business_name;
- Visit_counts;
- Business:
- Business_id;
- Business_name;
- Visit_counts;
So basically the object will have the business information and the no of times that the user has visited the store.
Thanks much for all the help