PDA

View Full Version : PHP if condition


Mythotical
12-12-2009, 04:29 PM
Well found another coding error and can't seem to figure out what is going on. Need someone to look over this for me and tell me if there is another way to work the if condition or work around for it.

$query = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "download WHERE catid = '" . $cid . ");
while ($dl = $db->fetch_array($query))
{
$fid = $dl['file_id'];

$moderated = $dl['moderated'];
$version = $dl['version'];
$name = $dl['name'];
$title = $dl['title'];
$size = $dl['size'];
$description = $dl['description'];
$username = $dl['username'];
$userid = $dl['userid'];
$ugpid = $dl['usergroupid'];
$bytes = vbmksize($size);
$fileview = $ugpid;

if (!empty($ugpid))
{
$ugpids = explode(',', $ugpid);
}
else
{
$ugpids = array('0');
}
$myids = '';
if ($vbulletin->userinfo['membergroupids'] == '')
{
$myids = array($vbulletin->userinfo['usergroupid']);
}
else
{
$myids = explode(',',$vbulletin->userinfo['membergroupids']);
}

$showfile = 0;

if (!empty($ugpid))
{
for ($i=0; $i<=20; $i++)
{
if (in_array($ugpids[$i], $myids))
{
$showfile = 1;
}
}
}
}

Thanks in advance for the help
Steve

Lynne
12-12-2009, 04:59 PM
What is it that you want to happen and what is happening? Just seeing some code without an explanation doesn't give me a place to start. Is this a plugin? Where does the output go?

Mythotical
12-12-2009, 05:46 PM
The variable $showfile is used in my template to display the file depending on the usergroup ids pull from the DB. Instead of it showing any files it is blank. I remove the $showfile if condition and it works so I know the showfile variable is causing the issue, its not rendering the usergroup ids as existent or something.

BBR-APBT
12-12-2009, 06:44 PM
Did you register the $showfile variable?

If it is not registered in the template it will display nothing.

Mythotical
12-12-2009, 08:00 PM
BBR-APBT: You have a point, I completely forgot about that variable. I will check it.

BBR-APBT
12-12-2009, 08:07 PM
BBR-APBT: You have a point, I completely forgot about that variable. I will check it.

I been there, I was like wtf the template is being called from the debug. But nothing showed.

LOL

It may not be the case but if you have not registered it I would say that is the case.

Mythotical
12-12-2009, 08:13 PM
Thanks much, that was the case. Can't believe I missed that variable. It works now, I can finish playing WoW happy and work on it more this evening.