Randomizer Fix

This is a randomizer fix that will work with sets that have different amount of cards in them. This is my randomizer file. You might have to edit the “$name/$name” part depending on how you have your cards set up.

**NOTE THIS FILE GOES IN YOUR /MYTCG FOLDER, NOT THE MAIN FOLDER**

<?php

if($randtype=="regular") {
$query="SELECT * FROM `$table_cards` WHERE worth='1' ORDER BY RAND() LIMIT 1";
$result=mysql_query($query);

while($row=mysql_fetch_assoc($result)) {
$name=stripslashes($row['filename']);
$digitsc = rand(01,$row['count']);
if ($digitsc < 10) { $_digitsc = "0$digitsc"; } else { $_digitsc = $digitsc;}
echo "$name/$name$_digitsc";
}
}

elseif($randtype=="special") {
$query="SELECT * FROM `$table_cards` WHERE worth='2' ORDER BY RAND() LIMIT 1";
$result=mysql_query($query);

while($row=mysql_fetch_assoc($result)) {
$name=stripslashes($row['filename']);
$digitsc = rand(01,$row['count']);
if ($digitsc < 10) { $_digitsc = "0$digitsc"; } else { $_digitsc = $digitsc;}
echo "$name/$name$_digitsc";
}
}

elseif($randtype=="member") {
$query="SELECT * FROM `$table_members` WHERE membercard='Yes' ORDER BY RAND() LIMIT 1";
$result=mysql_query($query);

while($row=mysql_fetch_assoc($result)) {
$name=stripslashes($row['name']);
echo "mc/mc-$name";
}
}

/*
To add a type of randomizer (ie. you want just the cards from a certain category), 
include the following code OUTSIDE these comments FOR EACH RANDOMIZER TYPE. 
Make sure this code is AFTER the if statement at the top and BEFORE the else statement below!
elseif($randtype=="NAME") {
$query="SELECT * FROM `$table_cards` WHERE category='CATNUM' ORDER BY RAND() LIMIT 1";
$result=mysql_query($query);

while($row=mysql_fetch_assoc($result)) {
$name=stripslashes($row['filename']);
echo "$name/$name" . $digits[array_rand($digits,1)] . "";
}
}
*/

else {
echo "Your card cannot be displayed";
}
?>