Page 1 of 1

Highscore in tabel!

Posted: Thu Apr 08, 2010 2:02 am
by Joepiooo
Hi,

I made a Highscore system with Flash PHP and MyQSL. Its sending and getting info from Myqsl and is putting it out in Flash.

But its shown like this:

Here are all the flash scores in our database: name1=Wilfinal1=2000name2=Test
final2=1234name3=Zzyzxfinal3=1000name4=Testfinal4=1000name5=Peterfinal5=44name6=
asdasdfinal6=25name7=Gekheid
final7=20name8=Nick
final8=16name9=
pietjefinal9=11name10=Truusfinal10=2The data has been written to the table!?>


I want to have it in a nice tabel... Is this something I have to do with PHP or Flash?
Dont know where to begin to be honest... I allready tried to adjust it in PHP but that aint working very wel..

Code: Select all

<?php
 
//////////  FILL IN THIS INFORMATION HERE! ////////////
 
  $host = "localhost"; //hostname is usually localhost by default
  $user = "****"; //insert the name of the user here
  $pass = "****";  //insert the password here
  $database = "****";  //insert name of database wherein table was exported
  $table = "****";  //insert the name of the table
 
////////////////////////////////////////////////////////
   //stores the URLvariables into variables that php can use
$one = $_GET['name'];
$five = $_GET['final'];

  // Connects to the database server
  // outputs an error message is it was unsuccessful
  $dbcnx = @mysql_connect($host,$user,$pass);
 
  if (!$dbcnx) {
    echo( "<P>Unable to connect to the database server at this time.</P>" );
    exit();
  }
 
  // Selects the specified database
  if (! @mysql_select_db($database) ) {
    echo( "Unable to find database" );
    exit();
  }
 
  echo("Here are all the flash scores in our database: ");
 
  // Request all the data from the table
  $result = mysql_query("SELECT * FROM {$table} ORDER BY finalTime DESC");
  if (!$result) {
    echo("<P>Error performing query: mysql_error() </P>");
    exit();
  }
 
  // Display the first three records
  //for($x=0;$x <6;$x++)
   //{     
    // $row = mysql_fetch_array($result);
      //    echo "Name : {$row["name"]}" .
       //  "Final Time : {$row["finalTime"]}";
     //}
   
   for($i = 1; $i <= 10; $i++) {
      if($line = mysql_fetch_assoc($result)){
         echo "".$i."=".$line["name"]."".$i."=".$line["finalTime"];
      }
   }
 
 //this is the command used to write the record into the MySQL database
$query="INSERT into {$table} (name,finalTime) VALUES ('{$one}',{$five})";   
 
//executes the command
mysql_query($query) or die("Data not written.");
echo("The data has been written to the table!");
?>
If someone can help me with this I would be very happy.

Thank you

Re: Highscore in tabel!

Posted: Thu Apr 08, 2010 3:04 am
by Architek
I haven't tested it and I am not sure how you anticipate rendering it in flash and what the capabilites are there. You may need to create some sort of object if it is going to be a .swf file???

You could look at displaying this in a nice format in a few ways via html... table, list, simple breaks....

Simple Break...
(also not sure why you have the first quote marks... so I removed it in this example...)

Code: Select all

echo $i."=".$line["name"]."&#32;".$i."=".$line["finalTime"]."<br />";
Simple List...

Code: Select all

echo "<ul>";
    for($i = 1; $i <= 10; $i++) {
         if($line = mysql_fetch_assoc($result)){
         echo "<li>".$i."=".$line["name"]."_".$i."=".$line["finalTime"]."</li>";
          }
     }
echo "</ul>
Simple Table...

Code: Select all

echo "<table>";
    for($i = 1; $i <= 10; $i++) {
         if($line = mysql_fetch_assoc($result)){
               echo "<tr>";
                       echo "<td>".$i."=".$line["name"]."</td><td>".$i."=".$line["finalTime"]."</td>";
               echo "</tr>";
          }
     }
echo "</table>

That maybe what you are looking for?

If not I am sure someone else here will have suggestions or know exactly how to render it in flash.

SS

Re: Highscore in tabel!

Posted: Thu Apr 08, 2010 7:31 am
by Joepiooo
Hey,

I got it into a table now but Flash needs to read it!

I know its possible that Flash reads out the HTML Table and displays it... but how....
I'm working on it the whole day now :banghead:

Re: Highscore in tabel!

Posted: Thu Apr 08, 2010 6:00 pm
by Architek
I have passed flash files variables on a site such as mp3 players where you can send the path of the mp3 and name of the song being played etc. Something kind of along these lines...

http://www.sephiroth.it/swfreader.php

might have to create your flash file with some sort of static file read and maybe just overwrite that static file contents when you want new information to be rendered in the swf.

here is some information about text file reading for flash...

honestly I am just grasping for straws here.. good luck and I hope some of that helps.