simcoweb Posted February 14, 2007 Share Posted February 14, 2007 Let's start from a solid beginning so we can get this answered. First, show me the code you use to insert the video(s) id(s) and related info into your database. I'm assuming you're using a form to add these. Once we determine how you get it in there then we can determine how you can get it out of there. Quote Link to comment Share on other sites More sharing options...
semaj4712 Posted February 14, 2007 Author Share Posted February 14, 2007 um ok...see thats the problem, i know where it ends up in my mysql database but i dont know how it writes it there, because i said this earlier this is a component for my open source that i am trying to edit... ok so this is what i know it asks for the youtube code i put that in that then writes it to the msql database _joom1 in that database there is a table called jos_jmovies then in that table their is a field allvideosfonteid that is where the info is now i want to insert that into my code is that enuff info if not i dunno wat else to tell you, i cant locate the exact spot that the info is written to the db Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 14, 2007 Share Posted February 14, 2007 Looks like you're using Joomla. Is that it? Ok, well... here's the scoop. You can do a query that summons the info from that field but it has to have an 'identifier' in order to do so. Usually that's some sort of unique field like an auto-incrementing 'id' field. So, for every video you enter a 'counter' moves up a notch. If you want to display all videos in a category, for example, then you'd write something like this <?php $sql = "SELECT * FROM videos WHERE category='Action'"; $results = mysql_query($sql) or die(mysql_error()); $echo "<table width='500' border='0' align='center'>"; while ($row = mysql_fetch_array($results)) { echo "<tr><td>" . $row['title'] . "</td><td>" . $row['description'] . "</td><td><a href='http://www.yoursite.com/linktovideo.php?video_id=" . $row['video_id'] . " '>View Video</a></td></tr>"; } echo "</table><br>\n"; ?> That would summon all the videos in that category and place them into a table with each video occupying a different row. The example of the URL is what I think you're looking for. You populate it by doing the query, fetching the array, then populating that spot in the URL with the field used for the id. Quote Link to comment Share on other sites More sharing options...
semaj4712 Posted February 14, 2007 Author Share Posted February 14, 2007 ok so i no this is a huge newb question but then i would put my db where it says videos and the what where it says action Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 14, 2007 Share Posted February 14, 2007 Actually you'd put the table name there, not the database name. Database contains tables tables contain fields fields contain data When you do a query you select data from fields within tables. You do, however, have to connect to the database. That requires code like this: <?php $conn = mysql_connect('hostnamehere', 'usernamehere', 'passwordhere') or die(mysql_error()); $db = mysql_select_db('databasenamehere') or die(mysql_error()); ?> This should be above the query code and, obviously, you'd replace those parameters with the actual info for your database. For the 'what' where it says 'Action', yes..you'd replace that with the field you want to identify with. That is what the query will pull from in order to produce the results. You don't HAVE to have the 'WHERE' clause in there. You can simply pull all the videos if you wish by deleting it. BUT, if you have hundreds of vids to display then the page would be a mile long. You'd need some pagination to make it work right. Quote Link to comment Share on other sites More sharing options...
semaj4712 Posted February 14, 2007 Author Share Posted February 14, 2007 ok all is good so far however it plays the first option on the list allways, how do i tell it to locate what video id it is on and play that ids code?? Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 14, 2007 Share Posted February 14, 2007 If you want to play a specific video then you would need to have a link/url that points to it. Like this: <a href="playvideo.php?video_id=24">Play This Video</a> Now, how you get that id # in there is the trick. First, you must provide a list or something where these people can choose from to watch videos. Is that right? In other words, are you providing some type of selection list that they would click on to view videos? If not, then what does this actually mean: how do i tell it to locate what video id it is on and play that ids code Quote Link to comment Share on other sites More sharing options...
semaj4712 Posted February 15, 2007 Author Share Posted February 15, 2007 well that is wat i meant, however if doesnt work, see the problem i think is that im telling it to display all the videos so it literally shows them all, what do i do to only show the one with that matches the video id Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted February 15, 2007 Share Posted February 15, 2007 So like.. http://www.test.com/index.php?video_id=23 Set the variable: $id = $_GET["video_id"]; Query: SELECT * FROM example WHERE id = '$id' Use the WHERE phrase to select just one based on the ID. In this case $id would be equal to 23, and it would select information in the database where the ID is equal to 23. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 15, 2007 Share Posted February 15, 2007 I think what i'm getting to is HOW do you determine that you want to show A particular video? In other words, are you just wishing to show a specific video on the page? Or is this something that a visitor would select to see? Do you want a random video to show up on the home page? What we need to determine here is WHY that particular video. And WHAT happens prior to the video being shown. Does someone come to your site, see a button that says Videos, takes them to a page that shows ALL of them? Or just one? Where does this video come into play? Quote Link to comment Share on other sites More sharing options...
semaj4712 Posted February 15, 2007 Author Share Posted February 15, 2007 thanx a bunch, what happened is it summoned a pop up, the where id = was the key and that made it work, so thans a bunch for all the help i would have never figured it out with out the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.