mysql查询连接表

时间:2012-06-18 13:36:41

标签: php mysql

我有两个表,表的结构就像这样

TableA

id      location
1        Australia
2        Nepal
3        Australia
4        U.K

id是自动增量和唯一

TableB 

uid   app      title    var1
2      music   reeedd    rfrwwdew
4      game     jejee     edeeded
2      game     efrfeded   ededede
3      book      ededed   dedee

请注意tableA“id”和tableB“uid”指的是用户的相同标识 我想打印细节,以便来自尼泊尔的用户只能看到内容rfrwwdewas app只有音乐出现一次。

所以我使用了这个查询,一切都很好,它根据我的requiremnet打印了记录,但是当我点击播放时它就是逃避我注意到它没有解析(嵌入java脚本)播放器

 $res6411 = sql_query("SELECT * from TableB as c join TableA as p on c.uid=p.id  where p.location='{$client['location']}' and c.app='music' order by rand() desc limit 3");



while($row6411 = sql_fetch_array($res6411)) {
    $outputmusic .= '<div href="'.$row6411['var1'].'" style="width: 520px;" class="item">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">'.$row6411['title'].'</div>
        </div>
        <div class="player inactive"></div>
    </div>';        
        }

我得到的输出是

<div id="playlist" class="playlist1"> <div class="item" style="width: 520px;" href="">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">Dheere Dheere Se Meri Zindagi</div>
        </div>
        <div class="player inactive"></div>
    </div><div class="item" style="width: 520px;" href="">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">DEKHA NE HAYE -BOMBAY TO GOA</div>
        </div>
        <div class="player inactive"></div>
    </div><div class="item" style="width: 520px;" href="">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">Saagar Kinare</div>
        </div>
        <div class="player inactive"></div>
    </div></div>

但我希望得到这个输出

<div id="playlist" class="playlist1"> <div class="item" style="width: 520px;" href="uploads/userfiles/201206/1112_06_rhuak.01_TERE_NAAM.MP3">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">Tere Naam</div>
        </div>
        <div class="player inactive"></div>
    </div><div class="item" style="width: 520px;" href="uploads/userfiles/201206/114_50_q7n4k.25RAATKALIEKKHUWABMEIN.mp3">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">RAAT KALI EK KHUWAB MEIN</div>
        </div>
        <div class="player inactive"></div>
    </div><div class="item" style="width: 520px;" href="uploads/userfiles/201206/123_29_52l7b.15TeriPyariPyariSuratKo.mp3">
        <div>
            <div class="fr duration"></div>
            <div class="btn play"></div>
            <div class="title">Teri Pyari Pyari Surat Ko</div>
        </div>
        <div class="player inactive"></div>
    </div></div>

0 个答案:

没有答案