Results 1 to 3 of 3

Thread: List of pictures to match with list of variables

  1. #1
    Join Date
    Oct 2006
    Posts
    94
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default List of pictures to match with list of variables

    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

  2. #2
    Join Date
    Nov 2006
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

    PHP Code:
    $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
    $namesmysql_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.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Split them like so:
    Code:
    foreach($list_of_maps as $k => $v)
      $list_of_maps[$k] = explode(' ', $v, 2);
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •