[eluser]cip6791[/eluser]
I have two tables, the first is the place table where the general information is kept and the second is the wait table where users sign up (like a waiting list).
Code:
+----+---------+---------+--------+-----------+---------------+-------+-------+-------+-----------+-------+------+---------------------+
| id | name | user | userid | address | desc | phone | map | image | website | cat | cats | date |
+----+---------+---------+--------+-----------+---------------+-------+-------+-------+-----------+-------+------+---------------------+
| 18 | title 2 | ciprian | 1 | compay+2 | description 2 | 0 | map 2 | image | website 2 | place | 0 | 2012-02-01 14:32:03 |
| 17 | title 1 | ciprian | 1 | company+1 | description 1 | 0 | map 1 | image | website 1 | place | 0 | 2012-02-01 14:31:23 |
+----+---------+---------+--------+-----------+---------------+-------+-------+-------+-----------+-------+------+---------------------+
Code:
+----+--------+---------+---------------------+
| id | userid | place_id | date |
+----+--------+---------+---------------------+
| 72 | 1 | 18 | 2012-02-01 14:36:08 |
+----+--------+---------+---------------------+
For now I m doing a SELECT * FROM place; and displaying the data on the home page. Something like tihs:
Code:
<? foreach($places as $place): ?>
<? echo $place->name; ?> <? echo $place->userid; ?> etc ...
|a href="#">Click this to insert your userid and $place->id into wait table|/a|
<? endforeach ?>
This is where I got lost. I would like to do something like:
Code:
<? if($current_user_id == $userid_from_wait_that_matches_place_id): ?>
<p>You already registered for this!</p>
<? else: ?>
|a href="#">Click this to insert your userid and $place->id into wait table|/a|
<? endif; ?>
Not sure if it's better to check for the user's id in the model that adds data to the wait table or to check in the model that grabs data for the home page. From what I've read, the second option would be better.
Any help is appreciated.
---EDIT---
This can be taken as a favorites option. When a user likes a post he/she clicks a link(call it Like), that post's id and the user's id is inserted into the "favorites" (in my case) wait table. What I want to do is display all posts from table place on the front page, and change or disable the "Like" link (if it has been clicked).