MyBB Community Forums

Full Version: help me to understand SQL WHERE operators?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Technically its ok where it won't throw an SQL error, however you are missing the $ in front of the variable $query. Most of the time you'd really only need fid,name, open, and active. http://docs.mybb.com/Database_Tables-mybb_forums.html

http://docs.mybb.com/Database_Methods.ht...o help you.
(2014-07-16, 07:11 PM)marcus123 Wrote: [ -> ]Guys you are great. I am really sorry for asking basic questions but the reason I ask here is cause MYBB has it's own functions that might not be described in SQL manual.


@avril is it ok to do this:

query = $db->simple_select('forums', '*');

DragonExpert has this right. I wouldn't run this query in a plugin, depending on how many forums you have this could be a nightmare.

Instead you should get just the things you need which are most likely only going to be the forum ID and the forum title, and even still this query on its own is probably going to be a pre-curser for another query, so why not use a join here?

What is it you are trying to grab?

also all class calls need to be placed into a variable, so

db

will not work, php interprets that as text or as constant, so it will throw an error. What you want is

$query = $db->simple_select('forums', '*');

I would probably constrain that though if you can with a where clause.

Additionally you are going to need to do something with the results set, because right now all that does is assign a class->function call to a variable. So you will need to loop through the results

$query = $db->simple_select('forums', '*');  
while($result=$db->fetch_array($query))	
{
  echo "The forum ID is ".$result["fid"]."<br/>";
}
Awesome love you guys very much I am starting to do basic coding super simple you know but at least it's working Smile
(2014-07-17, 07:31 PM)marcus123 Wrote: [ -> ]Awesome love you guys very much I am starting to do basic coding super simple you know but at least it's working Smile

We all have to start somewhere mate. Without asking questions you will never get answers and without people to answer them you will never learn.

Glad I have helped and hope it's the start of a bright coding future for you
Pages: 1 2