Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to query two tables and I can't figure out how
    primarykey
    data
    text
    <p>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)</p> <pre><code>+---------+--------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+-------------------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(30) | YES | | NULL | | | userid | int(3) | YES | | NULL | | | address | varchar(300) | YES | | NULL | | | desc | varchar(550) | YES | | NULL | | | phone | int(15) | YES | | NULL | | | image | varchar(50) | YES | | NULL | | | website | varchar(100) | YES | | NULL | | | cat | varchar(25) | YES | | NULL | | | date | timestamp | NO | | CURRENT_TIMESTAMP | | +---------+--------------+------+-----+-------------------+----------------+ +----------+-----------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-----------+------+-----+-------------------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | userid | int(11) | YES | | NULL | | | place_id | int(11) | YES | | NULL | | | date | timestamp | NO | | CURRENT_TIMESTAMP | | +----------+-----------+------+-----+-------------------+----------------+ </code></pre> <p>For now I m doing a SELECT * FROM place; and displaying the data on the home page. Something like tihs:</p> <pre><code>&lt;? foreach($places as $place): ?&gt; &lt;? echo $place-&gt;name; ?&gt;; &lt;? echo $place-&gt;userid; ?&gt; etc ... &lt;a href="#"&gt;Click this to insert your userid and $place-&gt;id into wait table&lt;/a&gt; &lt;? endforeach ?&gt; </code></pre> <p>This is where I got lost. I would like to do something like:</p> <pre><code>&lt;? if($current_user_id == $userid_from_wait_that_matches_place_id): ?&gt; &lt;p&gt;You already registered for this!&lt;/p&gt; &lt;? else: ?&gt; &lt;a href="#"&gt;Click this to insert your userid and $place-&gt;id into wait table&lt;/a&gt; &lt;? endif; ?&gt; </code></pre> <p>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. Or should I use two separate queries ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload