2
I have these values in my SQL database, I want an output this way and this file in the browser using PHP
Database structure with the values I want on output My attempts, although it does not help you at all: Pastebin.com/6tCNbpY4
DATABASE schedule
TABLE stream_playlist
id streamname | playlistname | repeat | scheduled
=====================================================================
1 stackoverflow | plname1 | true | 2009-12-11 16:25:05
2 other_stream | plother2 | false | 2011-11-11 17:01:11
TABLE videos_for_stream_playlist
id | streamname | src | start | length
================================================================
1 | other_stream | http:/ local/demo.mp4 | 60 | -1
2 | stackoverflow | C:\sample.mp4 | 0 | 20
3 | other_stream | otherlocation/mystream | 0 | -1
The output must be written to a.txt file and displayed in the browser when running the PHP script.
Videos can be ordered by id
.
<smil>
<body>
<stream name="stackoverflow"></stream>
<playlist name="plname1" playOnStream="stackoverflow" repeat="true" scheduled="2009-12-11 16:25:05">
<video src="C:\sample.mp4" start="0" length="20"/>
</playlist>
<stream name="other_stream"></stream>
<playlist name="plother2" playOnStream="other_stream" repeat="false" scheduled="2011-11-11 17:01:11">
<video src="http:/ local/demo.mp4" start="60" length="-1"/>
<video src="otherlocation/mystream" start="0" length="-1"/>
</playlist>
</body>
</smil>
How can I do that? I can’t give one loop functional within another loop, everything comes out duplicate.
From the looks of it, you need 2 separate loops, not one inside the other. And if you really need the txt intermediate, that’s two very different questions. One is how to generate txt from SQL, another is to show txt in the browser. From what I saw of your code, you better solve the first table, and after solved, make the code to solve the second, taking advantage of the connection. In the same PHP, but one part after the other, and not mixing.
– Bacco
You mainly need to explain better what you want and what is working or not. Break down the problem in steps and ask one at a time. For example, can you connect to DB and read the data? If you don’t just ask about that part. If so, go to the next step. The way you’re asking, someone’s gonna have to write the whole program for you to solve.
– laurent
Sorry for my arrogance. Thank you @Bacco I will follow this example of yours, I have set the code and I think I already have an idea of how to start doing it. Thank you.
– Florida
it would no longer be practical to query only and have a single loop ?
– Otto
I don’t think @Otto, because as his friend Harry Potter replied, there’s a loop for videos also, what I already knew I had to have, but I did not imagine how it could be.
– Florida