Jump to content

mikeg542

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mikeg542's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a program that once a button has been clicked and the page has reloaded it runs an external script with ajax to check if the database has updated. For some reason it works perfect in firefox 3.0.8 but refuses to work after the first load in IE 7. Does setInterval() not work in IE 7 or is it something else? Here's the relevant code The main page <head> <? include 'databaseinfo.php'; include 'show.php'; $user=$_COOKIE['user']; $query = mysql_query("SELECT id from Users where user=$user"); $row = mysql_fetch_assoc($query); $user = $row['id']; if(isset($_GET['id'])) { ?> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script language="javascript" type="text/javascript"> var int=self.setInterval("clock()",1000) function clock() { $('.checky').load('load.php?id='+'<?php echo $row['id']?>'+'&user='+'<?php echo $user?>'); } </script> <? } ?> </head> <body> <?php if(!isset($_GET['id'])) { ?> <div class='checky'> <?php $quer = mysql_query("SELECT cards FROM table1 where player='$user'"); $row = mysql_fetch_assoc($quer); $cardpiece = explode(":", $row['cards']); $num = sizeof($cardpiece)-1; for ($x=0;$x<$num;$x++) { $card = $cardpiece[$x]; $card = mysql_real_escape_string($card); $query = mysql_query("SELECT id FROM tab where name='$card'"); $row = mysql_fetch_assoc($query); $name = $row['id']; ?> <a href=self.php?id=<? echo $name?>><? echo stripslashes(stripslashes($card))?></a> <?php echo "<BR>"; } ?> </div> <? } if(isset($_GET['id'])) { $tempuser = $_COOKIE['user']; $query = mysql_query("SELECT id from Users where user='$tempuser'"); $row = mysql_fetch_assoc($query); $query1 = "UPDATE table1 SET haspicked='yes' WHERE player=".$row['id']; $query = mysql_query($query1); $query = mysql_query("SELECT * from Users where user=$user"); $id=$_GET['id']; ?> <div class='checky'> </div> <? } ?> </body> </html> load.php <? include 'databaseinfo.php'; $user = $_GET['user']; $card = $_GET['id']; $rs="SELECT * from table1 WHERE player=".$user; $query = mysql_query($rs); $row = mysql_fetch_assoc($query); $rs1="SELECT * from table1 WHERE nextplayer=".$user; $query1 = mysql_query($rs1); $row2 = mysql_fetch_assoc($query1); if ($row2['haspicked']=='yes') { echo "Passed!1"; } ?> Thanks for any hel[
  2. So setInterval has been working right how I want it to, so thanks for that. I was just wondering if there is a reason this doesn't work in IE: <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script language="javascript" type="text/javascript"> var int=self.setInterval("clock()",1000) function clock() { $('.checky').load('load.php?id='+'<?php echo $row['id']?>'); } </script> For firefox it runs load.php every second, while in IE it runs it once then stops.
  3. good call, didn't think that through enough then, did I? Do any of you know if I could use jQuery to do this checking? I know how to use it to check the script page (just use .load()) but if there is a quick way to attach that to a timer event instead of a keyboard/click/mouse action... If there isn't a quick way, I'll try and find the harder one myself thanks again
  4. I read something about using ajax/php that doesn't continually check the db for changes and only triggers an event if it is changed (to keep down on server load). I know some ajax, but no java/flash so I'd prefer that method. The main UI would be clicking on something and having it appear as an image on the main page for both users.
  5. Hi. My question is as follows: How does one go about making a program that when two players are logged onto the site and maybe there is a condition (like both have a $_GET['id'] number being the same), and one does something, it reloads the other's page. An example of this to clear it up is a chat program where when you type something and click enter, everyones chat reloads. I'm not asking for any extensive answers (though It'd be nice ), just a few words on what scripting language this is done in and what I should search for to learn it. Thanks a bunch!
  6. The subject sums it up, I have an ajax/jquery function that creations checkboxes when you click on another set of checkboxes. But for some reason I can't add another layer of the same thing (clicking on the inner checkboxes doing something with ajax) here's my code: Main page: <script type="text/javascript" src="javascript/jquery-1.3.2.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { $('.innerchecky').click(function () { alert("yo"); if ($('.innerchecky').is(':checked')) { url = 'test2.php?clickedinner='+$(this).val(); alert(url); $('#outputText'+$(this).val()).load(url); } else { url = 'test2.php'; $('#outputText'+$(this).val()).load(url); } $('.innerchecky').each(function(){ if (!this.checked) { url = 'test2.php'; $('#outputText'+$(this).val()).load(url); } }); } ); $('.checky').click(function () { if ($('.checky').is(':checked')) { url = 'test2.php?clicked='+$(this).val(); $('#outputText'+$(this).val()).load(url); } $('.checky').each(function(){ if (!this.checked) { url = 'test2.php'; $('#outputText'+$(this).val()).load(url); } }); } ); //protect against refreshes that don't empty fields } ); </script> (the alert is a testing thing) And the html/php in the main page: <?php $query = "SELECT id, name from research WHERE active=1"; $rs = dbquery($query); while($row = db_fetch_assoc($rs)) { echo "<input type=checkbox class=checky id=".$row['id']." value=".$row['id'].">".$row['name']."<br />"; $var = "<table cellpadding=4><tr><td> </td><td><div id=outputText".$row['id']."></div></td></tr></table><br />"; echo $var; } ?> And the relevant part of test2.php that is run by ajax include 'php/includes.php'; $clicked = $_GET['clicked']; $clickedinner = $_GET['clickedinner']; $unclicked = $_GET['unclicked']; if(!isset($_SESSION['clickedarray'])) { $arrayl = array(); $_SESSION['clickedarray'] = $arrayl; } if (!empty($clicked)) { $query = "SELECT expertise from expertisecategories WHERE research=".$clicked; $rs = dbquery($query); while($row2 = db_fetch_assoc($rs)) { if (db_num_rows($rs) > 0) { $query1 = "SELECT name,id from expertise WHERE id=".$row2['expertise']; $rs1 = dbquery($query1); while($row = db_fetch_assoc($rs1)) { echo "<input type=checkbox class=innerchecky id=".$row['id']." value=".$row['id'].">".$row['name']."<br />"; } } } } The problem is probably something pretty stupid because I'm not the best with jquery/javascript. Thanks for any help.
  7. Hi, I'm trying to learn JS here and I'm having a bit of trouble here... Currently I have a page with 3 checkboxes that have an onClick() attached to them. Each checkbox has 3 sub-checkboxes that are hidden until the main one is checked. As well, if the main one is checked, but none of the sub ones, it assumes that all of them have been. What is the general idea behind doing this? Is this easier with ajax? Can this be done in jQuery? Thanks a lot!
  8. We are making a group of select drop down boxes that when an item is selected, it removes that item from all the other select boxes. This currently works fine in firefox using focus, but in IE, it loads up the drop down menu as blank, then disappears making you have to drop down the select menu twice to see it updated. Any thoughts as to why onFocus() would preform differently between the browsers?
  9. Hi, just a logic question: We have a DB that has a table for matches with the relevant fields being: id, team1, team2, nextplayoffid, playoffround. The user is supposed to be able to enter a team id and have it return the playoff tree. The system was made so that ALL byes are done in the first round, so for example, a 5 person playoff would have 3 first round byes and 1 game, then 2 games then 1. Bye rounds are NOT in the DB. For example here would be the DB id team 1 team 2 nextplayoffid playoffround 1 15 16 2 1 2 14 - 4 2 3 17 18 4 2 4 - - - 3 And this should display: 15 vs -------- 16 |winner --vs--- 14 | 14 | vs--------- | bye | winner --vs---- 17 | winner vs--------- | bye | 17 | --vs--- 18 | 18 vs -------- bye The playoffs can be between 4 and 11 teams. The number of games/byes first round is: 4 2 games/0bye 5 1 game/3byes 6 2 games/2byes 7 3 games/1bye 8 4 games/0byes 9 1 game/7byes 10 2 games/6 byes 11 3 games/5byes I just would like to hear the best logic way of doing this. My idea was to use a recursive function like function (node, left, right), but I don't know how to get that to do both the left AND right node simultaneously instead of sequentially (which obviouslly creates problems if done sequentially) Any help would be appreicated!
  10. I am making a roulette program and would like to have a picture of a wheel that shows the number you spun at the bottom. I could easily do this by have a large number of pictures, but of course would prefer an alternative. Is it possible to make a picture rotate a certain number of degrees or another method based with php or javascript? Thanks
  11. The file is being uploaded with 0 bytes The code I have is: if (isset($_POST['upload'])) { $linkchars = 'BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz123456789'; $link = ''; for ($x=0; $x < 8; $x++) { $link .= $linkchars{rand(0, strlen($linkchars)-1)}; } $fileName = mysql_real_escape_string($_FILES['userfile']['name']); $fileSize = mysql_real_escape_string($_FILES['userfile']['size']); $fileType = mysql_real_escape_string($_FILES['userfile']['type']); $query = "INSERT INTO items (namefile, sizefile, typefile, content, linknum, sentstaffid, recievedstaffid, clientname) ". "VALUES ('$fileName', '$fileSize', '$fileType', '', '$link', '', '', '')"; $tmpName = $_FILES['userfile']['tmp_name']; move_uploaded_file($tmpName,'uploads/'.$link); mysql_query($query) or die('Error, query failed:'. mysql_error()); echo "<br>File $fileName uploaded<br>"; ?> <form method="post" name="userform"> <input type = "hidden" name ="linknum" value ="<?=$link?>" /> <select name="userchoice"> <option value="default"></option> <option value="staff"> Staff </option> <option value="client"> Client </option> </select> <input type="submit" name="usersubmit" value="Ok!"/> </form> <?php } This is on a page with a large amout of other code, if this would effect it...
  12. How would I use sort to only do it for the domain? I want: f@ab.com to come before a@ah.com
  13. Say I have a list of emails like so: $emails = array('a@ah.com','a@ab.com','a@ac.com','a@aa.com'); And want it sorted to be in the order: a@aa.com, a@ab.com, a@ac.com, a@ah.com. My idea was to assign an unchangable value to the two parts of each (as in , explode them based on @, assign a value to each pair, sort by the second part then attach the first part back on based on the matching values) firstly, is this possible? and second, is it efficient for what I'm aiming for?
×
×
  • 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.