Log in

View Full Version : List of pictures to match with list of variables



smithster
05-03-2007, 02:04 PM
Ok, so I have a php file with a list of map names. It is a for a call of duty website. I want to match the right map picture with the map name. But I am not sure how to do that. I have tried alsorts of things but could not get it to work. If someone has any idea, please let me know. Assume the pictures are in the same folder as the file with the map names.

Here is the list as written in the file.

$list_of_maps[] = 'mp_farmhouse Beltot, France';
$list_of_maps[] = 'mp_brecourt Brecourt, France';
$list_of_maps[] = 'mp_burgundy Burgundy, France';
$list_of_maps[] = 'mp_trainstation Caen, France';
$list_of_maps[] = 'mp_carentan Carentan, France';
$list_of_maps[] = 'mp_decoy El Alamein, Egypt';
$list_of_maps[] = 'mp_leningrad Leningrad, Russia';
$list_of_maps[] = 'mp_matmata Matmata, Tunisia';
$list_of_maps[] = 'mp_downtown Moscow, Russia';
$list_of_maps[] = 'mp_harbor Rostov, Russia'; //1.3
$list_of_maps[] = 'mp_dawnville St. Mere Eglise, France';
$list_of_maps[] = 'mp_railyard Stalingrad, Russia';
$list_of_maps[] = 'mp_toujane Toujane, Tunisia';
$list_of_maps[] = 'mp_breakout Villers-Bocage, France';
$list_of_maps[] = 'mp_rhine Wallendar, Germany'; //1.3
$list_of_maps[] = 'mp_gob_rats';
$list_of_maps[] = 'mp_industry';
$list_of_maps[] = 'islands';

Any further info required, please ask.

Thanks

Smithster

GhettoT
05-03-2007, 08:59 PM
Have you tried using a database instead? Like have URL's in the database and have the map names in the database too. Then do something like this.



$server = "[SERVER]"; //url for the mysql server
$DBuser = "[USERNAME]"; //database username
$DBpass = "[PASSWORD]"; //database password
$DB = "[DATABASE NAME]"; //actual database name for sitering
$table = "[TABLE NAME]"; //database table name

mysql_connect($server,$DBuser,$DBpass); //connect to server
mysql_select_db($DB); //select database
$names= mysql_query("SELECT * FROM ".$table.""); //use table 'sites;

while ($qry = mysql_fetch_array($sites)) {
echo $qry[MAP_NAME].'<br />'; //change MAP_NAME to the row that has the map name
echo '<img src="'.$qry[MAP_IMAGE].'" /><br />'; //change MAP_IMAGE to the row that has the map image URL
}

That way all the same stuff gets with the right images and names.

Twey
05-03-2007, 09:14 PM
Split them like so:
foreach($list_of_maps as $k => $v)
$list_of_maps[$k] = explode(' ', $v, 2);