简体   繁体   中英

Generating loop XML foreach PHP

I created a script where we add 'playlists'. In MySQL is something like:

Cod: 18, Playlist: teste, Looptande: 1, Starttime: 09:00
Cod: 19, Playlist: teste2, Looptande: 0, Starttime: 10:00

I'm trying to generate an XML in the following format:

<playlist loopatend="1" shuffle="inherit">teste</playlist>
<calendar starttime="09:00">

Second:

<playlist loopatend="0" shuffle="inherit">teste2</playlist>
<calendar starttime="10:00">

I was wondering if it detects that the number of playlists and repeat correctly as above.

I'm trying to do this:

$qtd_ag = 0;

$sql_ag = mysql_query("SELECT * FROM event where codigo_stm = '".$dados_stm["codigo"]."' ORDER by playlist");
while ($dados_ag = mysql_fetch_array($sql_ag)) {

    $ag_config_autodj .= "playlistfilename_".$qtd_ag."=".$dados_ag["playlist"]."\n";
    $ag_config_autodj .= "playlistfilepath_".$qtd_ag."=/home/streaming/playlists/".$dados_stm["porta"]."-".$dados_ag["playlist"].".pls\n";
    $ag_config_calendar = array ("loopatend" => $dados_ag["loopatend"], "priority" => $dados_ag["priority"], "playlist" => $dados_ag["playlist"], "starttime" => $dados_ag["starttime"], "duration" => $dados_ag["duration"], "repeat" => $dados_ag["repeatc"], "startdate" => $dados_ag["startdate"], "enddate" => $dados_ag["enddate"], "shuffle" => $dados_ag["shuffle"]);

    $qtd_ag++;
}

$config_calendar = gerar_calendar_autodj($dados_stm["porta"],$djs_config_calendar,$ag_config_calendar);                 

$ssh->enviar_arquivo("../temp/".$config_autodj."","/home/streaming/configs/".$config_autodj."",0777);
$ssh->enviar_arquivo("../temp/".$config_calendar."","/home/streaming/configs/".$config_calendar."",0777);

unlink("../temp/".$config_autodj."");
unlink("../temp/".$config_calendar."");

Function second: (function.php) I can not paste the code here, I always fumble excuse me please, but I need help. then will the print:

打印

Thus it creates the XML but goes wrong with values ​​that do not correspond to the database:

<playlist loopatend="0" shuffle="0" priority="0" >array</playlist>
<calendar starttime="0" endtime="" repeat="128">
<playlist loopatend="0" shuffle="0" priority="0" >array</playlist>
<calendar starttime="0" endtime="" repeat="128">

In image you are using $$event[...] . I think that should be $event[...] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM