Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying a multi-table mysql query
    primarykey
    data
    text
    <p>This is going to be really hard to explain but I'll attempt to do my best without confusing you all. I have the following table design;</p> <p><img src="https://i.stack.imgur.com/9ujdi.png" alt="Mysql Table"></p> <p>Here is my mysqlFiddle to demonstrate the issue: <a href="http://sqlfiddle.com/#!2/1363c/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!2/1363c/1</a></p> <p>As you can see, the tables work fine and the query is displaying what shelter has what service but my issue comes when I attempt to display this information on my web. I'm currently using the following code;</p> <pre><code>&lt;?php echo '&lt;p&gt;', "&lt;strong&gt;Shelter id&lt;/strong&gt;: " . $query['shelter_id'].'&lt;/p&gt;'; echo '&lt;p&gt;', "&lt;strong&gt;Shelter name&lt;/strong&gt;: " . $query['shelter_name'].'&lt;/p&gt;'; echo '&lt;p&gt;', "&lt;strong&gt;Street&lt;/strong&gt;: " . $query['street'].'&lt;/p&gt;'; echo '&lt;p&gt;', "&lt;strong&gt;City&lt;/strong&gt;: " . $query['city'].'&lt;/p&gt;'; echo '&lt;p&gt;', "&lt;strong&gt;Postcode&lt;/strong&gt;: " . $query['postcode'].'&lt;/p&gt;'; echo '&lt;p&gt;', "&lt;strong&gt;Contact Number&lt;/strong&gt;: " . $query['phone_number'].'&lt;/p&gt;'; echo '&lt;p&gt;', "&lt;strong&gt;Location&lt;/strong&gt; : " . $query['location_name'].'&lt;/p&gt;'; ?&gt; </code></pre> <p>but with the query I'm using, Its not going going to dupe all the information into one row it is, its going to create multiple row's for the service_name, I think.</p> <p>Is it possible for me to create a query that will return all service's the shelter can do on one row?</p> <p>Edit: Will i have to do 2 separate query's? One to get the generic shelter information and then another query to return the services into an array and then just run through them on the page?</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