Jump to content

asai

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by asai

  1. Sorry if I am a little slow... From this button is there a way to call a javascript function to open a new window from the url? : <form name="form" method="POST" action="update.php"> <input name='filename' type='hidden' value=<?php echo $row['FileName'];?>> <input type="submit" value="Se film"> </form>
  2. No suggestions on my last question?
  3. This is now my update.php <html> <head> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <?php include 'config.php'; include 'opendb.php'; $filename = $_POST['filename']; $result2 = mysql_query("UPDATE DayMovie SET Counter=Counter+1 WHERE FileName='$filename'") or die(mysql_error()); include 'closedb.php'; $url = "http://81.166.2.19/alldaymovies/$filename"; window.open($url); ?> </html> The data is database is updated, but no window opens with the url. What's missing?
  4. Fantastic! Thanks for quick reply. One final question: Is there a way to open this url in a new window from within the php file without having to click a link or button? Something like this: window.open($url); ??
  5. One simple question: How can i make $url be a combination of the variable $filename and the text "/alldaymovies/" ? Have tried this but it doesn't work: $url = "/alldaymovies/" $filename;
  6. Hi again, I have come a little further with my project. A small change from earlier, but now the update works. Then change is that I haven't a link, but instead uses a button. One small thing that doesn't work, that is the movie is not run. I am not sure how and where to put it. Heres my movies.php file: <html> <head> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <?php include 'combo.php'; include 'config.php'; include 'opendb.php'; $ndate = $_POST['ndate']; $result = mysql_query("SELECT * FROM DayMovie WHERE FileDate LIKE '$ndate%' ORDER BY FileDate DESC") or die(mysql_error()); echo "<table border='0'>"; echo "<tr> <th>Dato</th><th>Visninger</th><th>Handling</th></tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo date('d.m.Y', strtotime($row['FileDate'])); echo "</td><td>"; echo $row['Counter']; echo "</td><td>"; ?> <form name="form" method="POST" action="update.php"> <input name='filename' type='hidden' value=<?php echo $row['FileName'];?>> <input name='url' type='hidden' value=<?php echo "alldaymovies/{$row['FileName']}"?>> <input type="submit" value="Se film"> </form> <?php } echo "</td></tr>"; echo "</table>"; include 'closedb.php'; ?> </html> From here I post both filename and url to update.php update.php looks like this: <html> <head> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <?php include 'config.php'; include 'opendb.php'; $filename = $_POST['filename']; $url = $_POST['url']; $result2 = mysql_query("UPDATE DayMovie SET Counter=Counter+1 WHERE FileName='$filename'") or die(mysql_error()); include 'closedb.php'; ?> Right now I am not using the url. Theres 2 things I would like to happen from here: 1. The movie opens from the url in a new window. 2. The update.php returns to movies.php Is this possible and how?
  7. Theres something not going right here... I have placed the script inside the movies.php file. Is the place inside the file important? The update.php file is never run. The link opens the file, but not from within the script.
  8. Something is still missing here: I have tried this: function playVideo(url, filename) { $.post( "update.php", {filename: "filename"}) .done(function( data ) { alert( "Data loaded: " + data ); }); } The output from the alert is "filename" Not the actual filename i want.
  9. Ok, now I am starting to understand this. One small thing: I suspect that the update.php file never runs or the filename parameter isn't correct. Is this line correct: $filename = $_POST['filename']; ??
  10. Ok, now we are getting closer. When I click the link, theres a empty popup box. When I click OK the movie is shown. But theres nothing updating... The function(data). What is? Should't this be defined somewhere? I know, I am a bit slow...
  11. It is possible that I am a bit slow... But I try my best. I think... Heres my movie.php file: <html> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> function playVideo(url, filename) { $POST( "update.php", {"filename":filename}, function(data) { if (data != '') { alert(data); } else { window.open(url); return false; } }, "Hva skjer her?" ); } </script> <?php include 'combo_new.php'; include 'config.php'; include 'opendb.php'; $ndate = $_POST['ndate']; $result = mysql_query("SELECT * FROM DayMovie WHERE FileDate LIKE '$ndate%' ORDER BY FileDate DESC") or die(mysql_error()); echo "<table border='0'>"; echo "<tr> <th>Dato</th><th>Visninger</th><th>Handling</th></tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo date('d.m.Y', strtotime($row['FileDate'])); echo "</td><td>"; echo $row['Counter']; echo "</td><td>"; echo "<a href='alldaymovies/{$row['FileName']}' onclick='playVideo(this.href, {$row['FileName']});' onkeypress='playVideo(this.href, {$row['FileName']});'>Se film</a>"; echo "</td></tr>"; } echo "</table>"; include 'closedb.php'; ?> </html> And this is my update.php: <?php include 'config.php'; include 'opendb.php'; $filename = $_POST['filename']; $result = mysql_query("UPDATE DayMovie SET Counter=Counter+1 WHERE FileName='$filename'") or die(mysql_error()); include 'closedb.php'; ?> The link opens the video but no update is run.
  12. I know, but I don't know how to make a js function and how to use AJAX. I am sure this is the solution, but I need an example on how to do this.
  13. I would like to use my update to the table. I have made a php file for updating the table: <?php include 'config.php'; include 'opendb.php'; $filename = $_POST['FileName']; $result = mysql_query("UPDATE DayMovie SET Counter=Counter+1 WHERE FileName='$filename'") or die(mysql_error()); include 'closedb.php'; ?> I only need a way to get the filename from the movie page and that this page is called when the link is clicked. Any suggestions for a solution?
  14. No, this i new to me. How could I implement something like that? Take into consideration that this list is updated with a new movie, with link every day. I want to count how many times these movies are shown. The idea is to use the link clicks as a counter.
  15. I am not familiar with AJAX. Could you give me a hint from the information earlier in this thread?
  16. Well, theres no script that opens the file. It is a MP4 file which is opened directly and played within the browser. I tried this: echo "<a href='alldaymovies/{$row['FileName']}' onclick='window.open(this.href); return false;' onkeypress='window.open(this.href); return false;'>Se film</a>"; And then I want to run this command: UPDATE DayMovie SET counter=counter+1 WHERE id=xx
  17. This is just a hyperlink. How do I write a script to do this job and put it into the table instead of the hyperlink?
  18. One more idea I have: Now I have this link to open the movies from the SQL table: echo "<a href='alldaymovies/{$row['FileName']}'>Se film</a>"; Is it possible to make the same link do 2 things: First of all open the movie as it does now. The second thing I would like it to do is update a row in the table. This is for counting how many times the movie is played (the link is clicked). Is this possible?
  19. Fantastic! It works great! Thanks all for the good help.
  20. OK, I see that this is the cause of the problem... The javascript is from a copy paste, so this function isn't existing. The onclick should the be POST? Like this: <select name="ndate" onClick="POST;"> And then $key = $_POST['ndate'] ??
  21. Yes, this is what I try to do. Any example on how to do this?
  22. YES! One small issue remains: Theres nothing happening when I select anything in the combo. It only show me the first value. (Dec 2014) I have separated the code into 2 php files. combo.php: <html> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> <?php include 'config.php'; include 'opendb.php'; $query_disp="SELECT DISTINCT DATE_FORMAT(FileDate, '%b %Y') as adate, DATE_FORMAT(FileDate, '%Y-%m') as ndate FROM DayMovie ORDER BY FileDate DESC"; $result_disp = mysql_query($query_disp, $conn); $options = array(); while ($query_data = mysql_fetch_array($result_disp)) { $options[$query_data["ndate"]] = $query_data["adate"]; } include 'closedb.php'; ?> <select name="ndate" onClick="submitCboSemester();"> <?php foreach ($options as $key => $value) : ?> <?php $selected = ($key == $_POST['ndate']) ? 'selected="selected"' : ''; ?> <option value="<?php echo $key ?>" <?php echo $selected ?>> <?php echo $value ?> </option> <?php endforeach; ?> </select> </html> movies.php: <html> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> <?php include 'combo.php'; include 'config.php'; include 'opendb.php'; $result = mysql_query("SELECT * FROM DayMovie WHERE FileDate LIKE '$key%'") or die(mysql_error()); echo "<table border='0'>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo date('d.m.Y', strtotime($row['FileDate'])); echo "</td><td>"; echo "<a href='alldaymovies/{$row['FileName']}'>Se film</a>"; echo "</td></tr>"; } echo "</table>"; include 'closedb.php'; ?> </html> I miss a small thing here... What is it?
  23. Really getting close now However I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE FileDate LIKE '2014-12%'' at line 5 But when I try this command in my MySQL Workbench, the command works great. What could cause this?
  24. Very close, but a little something wrong: <html> <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" /> <?php include 'config.php'; include 'opendb.php'; $query_disp="SELECT DISTINCT DATE_FORMAT(FileDate, '%b %Y') as adate, DATE_FORMAT(FileDate, '%Y-%m') as ndate FROM DayMovie ORDER BY FileDate DESC"; $result_disp = mysql_query($query_disp, $conn); $options = array(); while ($query_data = mysql_fetch_array($result_disp)) { $options[$query_data["adate"]] = $query_data["adate"]; } ?> <select name="ndate" onClick="submitCboSemester();"> <?php foreach ($options as $key => $value) : ?> <?php $selected = ($key == $_POST['ndate']) ? 'selected="selected"' : ''; ?> <option value="<?php echo $key ?>" <?php echo $selected ?>> <?php echo $value ?> </option> <?php endforeach; ?> </select> <?php $result = mysql_query("SELECT DISTINCT DATE_FORMAT(FileDate, '%d.%m.%Y') as ndate, FileName as filename FROM DayMovie ORDER BY FileDate DESC WHERE FileDate LIKE '$value%'") or die(mysql_error()); echo "<table border='0'>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo date($row['ndate']); echo "</td><td>"; echo "<a href='alldaymovies/{$row['filename']}'>Se film</a>"; echo "</td></tr>"; } echo "</table>"; include 'closedb.php'; ?> </html> I get the combobox correct, but the the value in my WHERE is the adate value and not the ndate...
  25. Yes I understand that, but I can see how I would put this together with the combobox. I would like the combobox to show the value Jan 2015, and when it is selected i would like the value 2015-01 be put into the query so I get a table with the movies from January 2015. I am very close, but haven't nailed it just yet.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.