EzEApostle
asked on
Inserting a single DB line within a foreach statement
Hi Experts,
I have a form where members can upload a file, I have created a parser to grab the information from the file perfectly. My problem is, my data is currently being displayed via a foreach statement (code in below snippet).
Rather than echoing the data to the screen, I want to save the data in my database as a single line only to save from having to process the file each time. If I put an insert within the foreach statement its obviously going to create more than 1 DB insert.
The values being displayed on the page here is what i need to catch in a single statement:-
echo 'player with no team: <br />';
echo 'player in team '.$k.'<br />';
echo 'Player Name:'.$player['name'].'; IP: '.$player['ip'].'; Army: '.$n->getArmyName($player[ 'army']).'
Can anyone help?
Thanks in advance
I have a form where members can upload a file, I have created a parser to grab the information from the file perfectly. My problem is, my data is currently being displayed via a foreach statement (code in below snippet).
Rather than echoing the data to the screen, I want to save the data in my database as a single line only to save from having to process the file each time. If I put an insert within the foreach statement its obviously going to create more than 1 DB insert.
The values being displayed on the page here is what i need to catch in a single statement:-
echo 'player with no team: <br />';
echo 'player in team '.$k.'<br />';
echo 'Player Name:'.$player['name'].'; IP: '.$player['ip'].'; Army: '.$n->getArmyName($player[
Can anyone help?
Thanks in advance
$n = new $classname();
if (!$n->parse($_FILES['some_identifier']['tmp_name'])) {
die('can not read it somehow');
}
$teams = $n->getTeams();
foreach($teams as $k => $team) {
if ($k == 0) { // team 0 store the player without team
echo 'player with no team: <br />';
} else {
echo 'player in team '.$k.'<br />';
}
foreach ($team as $k_p => $player) {
echo 'Player Name:'.$player['name'].'; IP: '.$player['ip'].'; Army: '.$n->getArmyName($player['army']).'<br />';
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window