Xander_Dee Posted April 2, 2014 Share Posted April 2, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287458-grabbing-info-with-phpmysql/ Share on other sites More sharing options...
jazzman1 Posted April 2, 2014 Share Posted April 2, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287458-grabbing-info-with-phpmysql/#findComment-1474717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.