11-25-2011, 11:33 AM
11-25-2011, 11:36 AM
(11-25-2011 07:17 AM)RateU Wrote: [ -> ]You can try to check by using $forum['fid']. Something like this:
Code:
<if $forum['fid'] == x then> Codes for forum id = x here <else> Codes for other forum ids here </if>
If it's a complex modification, personally, I prefer using XThreads for that.
Got it working, used this and worked a treat! Thanks!
I'm a bit of a novice and I was wondering how to use the conditionals to create more than two different codings?
IE for the moment I can have:
<if id = 1>
First template
</else>
Second template
</if>
But what if I wanted to have eight different templates? How would I go about doing that? I've tried just adding more if conditionals within it but it doesn't work.
11-25-2011, 03:45 PM
Nesting?
Code:
|
Or reduce the clutter with elseif's
Code:
|
11-25-2011, 11:33 PM
(11-25-2011 03:45 PM)ZiNgA BuRgA Wrote: [ -> ]Nesting?
Code:
<if $forum['fid'] == 1 then> ID 1 <else> <if $forum['fid'] == 2 then> ID 2 <else> <if $forum['fid'] == 3 then> ID 3 <else> something else </if> </if> </if>
Or reduce the clutter with elseif's
Code:
<if $forum['fid'] == 1 then> ID 1 <elseif $forum['fid'] == 2 then> ID 2 <elseif $forum['fid'] == 3 then> ID 3 <else> no, I'm not going to put any more IDs </if>
Perfect! Thanks so much
12-12-2011, 05:07 AM
Hello Zinga, really good job. Thanks!
I read that the code to extract data from the database is the follow. How do I set it to extract all rows from db?
I read that the code to extract data from the database is the follow. How do I set it to extract all rows from db?
Quote:{$attachment['icon']} <a href="attachment.php?aid={$attachment['aid']}" target="_blank">{$attachment['filename']}</a> ({$lang->postbit_attachment_size} {$attachment['filesize']} / {$lang->postbit_attachment_downloads} {$attachment['downloads']}
<?php
$affected_fids = explode(',', $mybb->settings['newpoints_atcost_forums']);
if (in_array($fid, $affected_fids)){
$attach_id = $attachment['aid'];
$attach_check = $db->query("SELECT * FROM mybb_newpoints_attachments WHERE AID='$attach_id'");
$rows = $db->num_rows($attach_check);
if ($rows > 0){
$attach_cost = $db->fetch_field($attach_check, "cost");
$attachment_cost_points = "/ <font color='red'>Cost:</font> ".$attach_cost;
}
}
?>
)
12-13-2011, 01:13 AM
(12-12-2011 05:07 AM)FabrizioCo Wrote: [ -> ]How do I set it to extract all rows from db?Use looping, like while?
12-13-2011, 04:06 AM
(12-13-2011 01:13 AM)RateU Wrote: [ -> ](12-12-2011 05:07 AM)FabrizioCo Wrote: [ -> ]How do I set it to extract all rows from db?Use looping, like while?
I used this code, but it doesn't work. I'm not good in object-oriented programming.
Quote:$query_2 = $db->query("SELECT * FROM voto_voti WHERE id_user = '$userid'");
$number_2 = $db->num_rows($query_2);
$i = 0;
if ($number_2 > 0){
while ($number_2 > $i){
$id_domanda = $db->fetch_field($query_2, "id_domanda");
$i++;
}
}
}
12-13-2011, 05:54 AM
If you are really sure that it is rows, not columns in one row only, maybe something like this:
PHP Code:
|
12-13-2011, 09:43 AM
(12-13-2011 04:06 AM)FabrizioCo Wrote: [ -> ]I used this code, but it doesn't work. I'm not good in object-oriented programming.MyBB is pretty much all procedural. The only link with OO is a few classes, which basically just act as fancy functions.
Although your code should work (as far as the loop is concerned), assuming you're using the data somewhere.
01-09-2012, 11:19 AM
Hi, i need help with this code :
PHP Code:
|
Cause MyBB is telling me it have a security issue :/
And i don't really see how i can fix it
Can you help me please ?