Jump to content

Search the Community

Showing results for tags 'php foreach table'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Morning all, I've been writing a few pages over the last week (learning by doing) and I've been pretty successful so far. However i now have a problem that has boggled me for days and no amount of googling is helping. <?php // Define cache file $cache_file = "cache.txt"; // Cache file is less than thirty minutes old. if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 30 ))) { // Don't bother refreshing, just use the file as-is. $file = file_get_contents($cache_file); // Our cache is out-of-date, so load the data from our remote server, // and also save it over our cache for next time. } else { $file = file_get_contents('http://eu.battle.net/api/wow/guild/chamber-of-aspects/requiem%20paradisum?fields=achievements'); file_put_contents($cache_file, $file, LOCK_EX); } // Decode cache file $achie = json_decode($file); // Seperate achievements and timestamps as variables $achiachi = ($achie->achievements->achievementsCompleted); $achitime = ($achie->achievements->achievementsCompletedTimestamp); foreach(array_combine($achiachi, $achitime) as $f => $n){ // Combine achievement number into Link for wowhead script $achilink = ("http://www.wowhead.com/achievement=". $f); // Sort out time formatting $unix = ($n); $not_unix = $unix / 1000; $date = date("F d Y @ h:i A", $not_unix); //Print into table echo " <table align=center class=mytable cellpadding=8 style=font-family:verdana;font-size:8pt;color:white;> <tr> <th>Achievement</th><th>Timestamp</th> <tr> <td><a href=\"$achilink\" rel=\"item=$achiachi\"></a></td> <td>$date</td> </tr> </table> "; } ?> This does work for the most part . . . . but . . . . .when the arrays are printed it creates a new table for every array entry. I'm expecting : table1 header1 - header2 achievement1 - achievement time achievement2 - achievement time achievement3 - achievement time achievement4 - achievement time I'm getting : table1 header1 - header2 achievement1 - achievement time table2 header1 - header2 achievement2 - achievement time table3 header1 - header2 achievement3 - achievement time table4 header1 - header2 achievement4 - achievement time Most annoying! If someone could tell me what the chuff I've done wrong I'd be very appreciative. Thanks John
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.