G'day All,
I need some help with some PHP scripting, I will try to make my request as simple as possible.
Basically what I'm after is to have a folder full of flag images located on my server and I will have a script that will insert some basic data into the database I can do this fine, but what I need help with is a script that will allow me to display a flag if say the user puts in 43 this equals this flag image. Basically if they put in 43 into one of the fields where they are supposed to put a number it displays the australian flag.
Can someone please help me with this, if you still don't understand what I'm after please add me to msn and I will try to explain this a little better.
msn@tutorialgem.net
Number = Image
Started by Trix06, Jul 16 2007 09:01 AM
2 replies to this topic
#1
Posted 16 July 2007 - 09:01 AM
#2
Posted 16 July 2007 - 02:35 PM
Here's an example of a dynamic version using a MySQL database.
The table has a field for the unique ID of the flag, and then a field for the flag's name.
The table has a field for the unique ID of the flag, and then a field for the flag's name.
// Connection assumed
$query = mysql_query("SELECT * FROM `flags` WHERE `id` = ".(int)$_POST['field']) or die(mysql_error());
if(mysql_num_rows() > 0){
$result = mysql_fetch_assoc($query);
// Make the path to the flag image
$flag_img = '/flags/'.$result['name'].'.gif';
}
else{
echo 'Sorry, invalid flag code.';
}
Edited by Demonslay, 16 July 2007 - 02:35 PM.
#3
Posted 17 July 2007 - 07:59 AM
nevermind guys....sorted this out over msn

just made a function that reads the directory, shuvs all flags into an array, and then u feed it a number, it will pull that number as the key from the array and return the flag image
just made a function that reads the directory, shuvs all flags into an array, and then u feed it a number, it will pull that number as the key from the array and return the flag image
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
