dongpu7881 2015-07-31 09:16
浏览 72
已采纳

Xml shoutcast到一个mysql数据库

i have made a php file to retrieve data to a database from a xml file and it works:

$title = $xml->SONGTITLE; {


// performing sql query

$sql = "INSERT INTO test_xml (`title`) VALUES ('$title') ON DUPLICATE KEY UPDATE time = now()";

the xml is from a shoutcast server, witch is made automatically from my radio. The xml line is:

<SONGTITLE>Morrissey - Don`t Make Fun of Daddy`s Voice (John Peel session)</SONGTITLE>

is there a way to separate the artist from the Song name? And retrieve title to title and artist to artist. Can you give me ideas how to start?

  • 写回答

1条回答 默认 最新

  • doudao2407 2015-08-01 08:30
    关注

    The anwser is:

    $title = $xml->SONGTITLE; {
    $pieces = explode("-", $title);
    

    // performing sql query

    $sql = "INSERT INTO test_xml (`title`, `artist`) VALUES ('$pieces[1]',   '$pieces[0]') ON DUPLICATE KEY UPDATE time = now()";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?