View Full Version : View Active Promocodes Plugin
HIddenPanda
01-23-2011, 01:06 PM
Compatible With: Mysidia Adoptables 1.0 - 1.1.2
This plugin is just a simplified version of my old mod. It can be accessed through the System Settings> Plugins Menu
Just upload both admcodes.php and admcodes_install.php to the main directory. Open up admcodes_install.php (YOU MUST BE LOGGED IN TO AN ADMINISTRATOR ACCOUNT FOR THE INSTALLATION TO WORK!) in your web browser. Then delete it off your server and voila
Edit 1: Bugfix - The code would only show one promo code over and over again, but this fixes that :D
If you already installed this addon All you need to do is replace admcodes.php (Delete if off the server and upload this copy (in the attatchments))
Bloodrun
01-23-2011, 09:07 PM
Nicely done Panda. =D This is how Plugins should work.
HIddenPanda
01-23-2011, 10:20 PM
Thank you :D, I was always wondering why no one ever took advantage of the Admin Control Panel Plugin page? Wasted page much?
Bloodrun
01-23-2011, 10:45 PM
Thank you :D, I was always wondering why no one ever took advantage of the Admin Control Panel Plugin page? Wasted page much?
No one ever knew how lol. =P
fadillzzz
01-23-2011, 10:54 PM
For some reason, it only loop the first promo code over and over.
Are you aware of this?:cfrown:
Kaeliah
01-24-2011, 08:18 AM
For some reason, it only loop the first promo code over and over.
Are you aware of this?
Is it repeating the adoptable type as well as the promocode?
You may want to replace the loop, give this a try:
$i=0;
while($i < $num){
$article_content = $article_content."<tr><td>Adoptable</td><td>".$promocodes['type']."</td><td>".$promocodes['promocode']."</td></tr>";
$i++;
}
I don't know if that's the issue or not but that's how almost all the other loops in the script are set up so...
Hall of Famer
01-24-2011, 09:21 AM
Honestly I wonder too, it may seem that most coders never really pay much attention to acp. We'd rather directly add/modify script files or mysql tables at this moment, which is another reason why acp needs a serious overhaul. It's quite meaningless if using acp does not give an edge over manipulating phpmyadmin.
Kaeliah
01-24-2011, 09:44 AM
I almost never use the ACP so that's why I never discovered the plugin thing. I have started an ACP overhaul project though... >.> more or less for a commission but I can release it here too.
fadillzzz
01-24-2011, 09:58 AM
Is it repeating the adoptable type as well as the promocode?
You may want to replace the loop, give this a try:
$i=0;
while($i < $num){
$article_content = $article_content."<tr><td>Adoptable</td><td>".$promocodes['type']."</td><td>".$promocodes['promocode']."</td></tr>";
$i++;
}
I don't know if that's the issue or not but that's how almost all the other loops in the script are set up so...
Yes, it's repeating the type and the promo code and I already tried that loop before. Didn't work
Kaeliah
01-24-2011, 10:06 AM
I think I see the error...
Just replace everything on that page between the End Prepwork and Begin Template with this:
if($isloggedin == "yes"){
$group = getgroup();
$cancp = cancp($group);
if($cancp == "yes"){
$article_title = "Promo Codes";
$article_content = "<table width='400' border='1'><tbody><tr><td><b>Type</b></td><td><b>Reward</b></td><td><b>Promo Code</b></td></tr>";
$query = "SELECT * FROM " .$prefix . "adoptables WHERE whenisavail='promo'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
$i=0;
while($i < $num){
$promocodes = @mysql_result($result,$i,"promocode");
$type = @mysql_result($result,$i,"type");
$article_content = $article_content."<tr><td>Adoptable</td><td>".$type."</td><td>".$promocodes."</td></tr>";
$i++;
}
$article_content = $article_content."</tbody></table>";
}else{
$article_title = "Access Denied";
$article_content = "Access Denied";
}
}
The issue is $i is not involved in the array, so it's only reading the first row. I'm not great with arrays so I just reverted it to results...
Hall of Famer
01-24-2011, 11:50 AM
True, I agree with what Kaeliah said above. To loop through an array, use the following syntax below:
for each($array as $temp){
//your codes here
}
This way every element within the array is stored as a temporary variable called $temp. Once a single loop is executed, it will repeat the same thing for the second loop, and the value stored in $temp is changed to the second element in your array. I will post a tutorials on how to use Arrays when I have time, but for now we need tutorials for conditional branches and functions first.
Hall of Famer
HIddenPanda
01-25-2011, 05:10 PM
I saw this error last night and was planning on uploading a fixed admcodes.php tonight
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.