Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Personally I would just go for a simple query such as </p> <pre><code>select Channel.Title, Channel.Desc, Channel.Link, Channel.id, Item.Title, Item.Desc, Item.Link as ItemLink from Item, Channel where Channel.id = Item.Chan_id order by Channel.id; </code></pre> <p>as a query, get all the items (as we are talking of not a lot of items), then loop through them. Where channel.id isn't the same as the previous channel ID, do the header thing.</p> <p>I have no idea what you are doing with those sprintfs, as you are sprintf'ing nothing, they are just text strings you can put straight into the queries. </p> <p>I would use classes to deal with the database, not because in this example you need it, but it is a good practice to be in, and once you get use to it it becomes second nature. however, as an example (and not necessarily as I would do it):</p> <pre><code> $query = "select Channel.Title as ChanTitle, Channel.Desc as ChanDesc, Channel.Link, Channel.id, Item.Title, Item.Desc, Item.Link as ItemLink from Item, Channel where Channel.id = Item.Chan_id order by Channel.id"; $t_result = mysql_query( $query ) OR die ('Could not execute query: ' . mysql_error()); $rowCount = mysql_num_rows( $t_result ); $cat = -1; // last category for($r = 0; $r &lt; $rowCount; $r++) { $row = mysql_fetch_array( $t_result ); if($row['id'] != $cat) { $cat = $row['id']; print $row['ChanTitle']."&lt;br&gt;"; print $row['ChanDesc']."&lt;br&gt;&lt;br&gt;"; } print $row['Title']."&lt;br&gt;".$row['Desc']."&lt;br&gt;&lt;br&gt;"; } </code></pre> <p>That way you are only doing the one get from the database, instead of a fetch for each small category, and just working with the data in arrays. Note this would miss out any groups that had an id without a matching channel, but I guess that would make sense.</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.
 

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