Jump to content

Recommended Posts

I've been looking at this code and I have parts of it figured out. I would like to figure this out because it will help me build other features for my script.

if(isset($_GET['id']))
{
    $id = intval($_GET['id']);
if(isset($_SESSION['username']))
{
    $dn1 = mysql_fetch_array(mysql_query('select count(t.id) as nb1, t.title, t.parent, c.name from topics as t, categories as c where t.id="'.$id.'" and t.id2=1 and c.id=t.parent group by t.id'));
if($dn1['nb1']>0)
{

SO above is saying Count topic id as nb1 (IDK) and select topic.parent category.name from topics. the t.id means topic.id? t.id is equal to t.id2 + c.id. i just don't understand the t.parent if you could just set id2 to eaqual category id so you can call all the topics that also have id2 set to the same category. but in this case I don't know why id2 and parent are being used and called upon.
 

 

if someone knows how to explain the break down of whats happening it would help trumendously.

Link to comment
https://forums.phpfreaks.com/topic/287458-grabbing-info-with-phpmysql/
Share on other sites

 

t.id2=1 and c.id=t.parent

It's a "JOIN" but using old style comma-separated list of tables syntax, something like - from table1, table2, etc..... This statement says to the parser, to list only those rows from the topics table with matching rows from the categories table (c.id), which id2 is equal to 1. Everything else will be omitted in the select block. I'd recommend you to start reading up on "JOIN" syntax, which is more readable, powerful and flexible.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.