Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP MYSQL Multiple table query
    primarykey
    data
    text
    <p>I have two tables 'p_tuts' and 'h_tuts'. I'm using a method to display all the returned rows. Although I'm not sure how to set it up to run multiple queries, I can only get it to return one query at a time. Heres my code...</p> <pre><code> public function QueryAll($my_field, $limit) { $query = mysql_query("SELECT * from $my_field LIMIT $limit"); $rows = array(); while($row = mysql_fetch_array($query)) { $rows[] = $row; } return $rows; } </code></pre> <p>Here is my index file</p> <pre><code> &lt;?php $results = $Database-&gt;QueryAll('p_tuts', 5); ?&gt; &lt;?php foreach ($results as $result): ?&gt; &lt;div class="tutorial"&gt; &lt;div class="tut_header"&gt;&lt;h2&gt;&lt;a href="view_article_p.php?id=&lt;?php echo $result['id']; ?&gt;" title="&lt;?php echo $result['tut_header']; ?&gt;"&gt;&lt;?php echo $result['tut_header']; ?&gt;&lt;/a&gt;&lt;/h2&gt;&lt;/div&gt; &lt;div class="tut_poster"&gt;Posted by: &lt;a href="#" title="Adam"&gt;&lt;?php echo $result['tut_poster']; ?&gt;&lt;/a&gt; on &lt;?php echo $result['tut_date']; ?&gt;&lt;/div&gt; &lt;div class="tut_img rounded"&gt;&lt;img src="&lt;?php echo "img_uploads/". $result['tut_img']; ?&gt;" width="180" height="151" /&gt;&lt;/div&gt; &lt;div class="tut_content"&gt;&lt;p&gt;&lt;?php $Website-&gt;CharLimit($result['tut_content'], 800); ?&gt;&lt;/p&gt;&lt;/div&gt; &lt;/div&gt; &lt;?php endforeach; ?&gt; </code></pre> <p>I'd really like to adapt it so I can use this class to display both multiple tables, rather than just the one.</p> <p>kind regards</p>
    singulars
    1. This table or related slice is empty.
    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.
    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