Jump to content

asai

Members
  • Posts

    36
  • Joined

  • Last visited

asai's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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?
×
×
  • 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.