- Home
- Tutorials
- Flash
- Intermediate
- Populating a MySQL Database using MS Excel

PHP script
For the PHP/ASP/CF file you would just make something that queries the DB and then concatenates the ID with the variables Flash is looking for. I have used something like:
<?php
mysql_connect ("localhost", "username", "password");
mysql_select_db ("database_name");
$qResult = mysql_query ("SELECT * FROM table_name");
$nRows = mysql_num_rows($qResult);
for ($i=1; $i< $nRows+1; $i++){
$row = mysql_fetch_array($qResult);
$rString .="&word".$i."=".$row['word']."&".
"answer".$i."=".$row['answer']."&".
"wrong".$i."=".$row['wrong'];
}
echo $rString;
?>
Excel uses &, Flash uses +, and PHP uses a dot to add strings together. There are probably millions of PHP tutorials out there and I can’t explain it any better so I won’t try to decipher it line by line. I will say this script is using the variable “i” rather than the ID in the spreadsheet, both are ok.
Spread The Word
Article Series
-
Populating a MySQL Database using MS Excel

