Jump to content

noj75

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Everything posted by noj75

  1. Jcbones you are a star !! Works a treat thank you very much !! Out of curiosity what is the extra @$ for before @$$r['month'] Many thanks
  2. That will only display the months that contain data. I need to display Jan through to Dec and numrically display how many entries that month has even if it is zero. Thanks for that but any other ideas. Kind regards
  3. Hi Guys, Im sure there is a way to simplify this into one query or something. Anyone have any ideas: <?php $mqry1 = "SELECT * FROM $blog WHERE month = 'January'"; $mqry2 = "SELECT * FROM $blog WHERE month = 'February'"; $mqry3 = "SELECT * FROM $blog WHERE month = 'March'"; $mqry4 = "SELECT * FROM $blog WHERE month = 'April'"; $mqry5 = "SELECT * FROM $blog WHERE month = 'May'"; $mqry6 = "SELECT * FROM $blog WHERE month = 'June'"; $mqry7 = "SELECT * FROM $blog WHERE month = 'July'"; $mqry8 = "SELECT * FROM $blog WHERE month = 'August'"; $mqry9 = "SELECT * FROM $blog WHERE month = 'September'"; $mqry10 = "SELECT * FROM $blog WHERE month = 'October'"; $mqry11 = "SELECT * FROM $blog WHERE month = 'November'"; $mqry12 = "SELECT * FROM $blog WHERE month = 'December'"; $mres1 = mysql_query($mqry1); $mres2 = mysql_query($mqry2); $mres3 = mysql_query($mqry3); $mres4 = mysql_query($mqry4); $mres5 = mysql_query($mqry5); $mres6 = mysql_query($mqry6); $mres7 = mysql_query($mqry7); $mres8 = mysql_query($mqry8); $mres9 = mysql_query($mqry9); $mres10 = mysql_query($mqry10); $mres11 = mysql_query($mqry11); $mres12 = mysql_query($mqry12); $cmres1 = mysql_num_rows($mres1); $cmres2 = mysql_num_rows($mres2); $cmres3 = mysql_num_rows($mres3); $cmres4 = mysql_num_rows($mres4); $cmres5 = mysql_num_rows($mres5); $cmres6 = mysql_num_rows($mres6); $cmres7 = mysql_num_rows($mres7); $cmres8 = mysql_num_rows($mres8); $cmres9 = mysql_num_rows($mres9); $cmres10 = mysql_num_rows($mres10); $cmres11 = mysql_num_rows($mres11); $cmres12 = mysql_num_rows($mres12); echo '<ul id="monthul"> <li><a href="index.php?month=January">January</a> ('.$cmres1.')</li> <li><a href="index.php?month=February">February</a> ('.$cmres2.')</li> <li><a href="index.php?month=March">March</a> ('.$cmres3.')</li> <li><a href="index.php?month=April">April</a> ('.$cmres4.')</li> <li><a href="index.php?month=May">May</a> ('.$cmres5.')</li> <li><a href="index.php?month=June">June</a> ('.$cmres6.')</li> <li><a href="index.php?month=July">July</a> ('.$cmres7.')</li> <li><a href="index.php?month=August">August</a> ('.$cmres8.')</li> <li><a href="index.php?month=September">September</a> ('.$cmres9.')</li> <li><a href="index.php?month=October">October</a> ('.$cmres10.')</li> <li><a href="index.php?month=November">November</a> ('.$cmres11.')</li> <li><a href="index.php?month=December">December</a> ('.$cmres12.')</li> </ul>'; ?> Any help would be appreciated. Regards
  4. Hi all, Thank you all anyway but I have finally figured it out. Many thanks to those who tried to help. Regards
  5. Thanks for that, I have now chosen a different approach using cron jobs and a mixture of PHP and JS. I have set up a cron job that updates two tables every 5 minutes. The first table is to update the players rep by 1 point. The second updates the current time "h:i:s" to show when it was updated. All that is in a seperate file. I am trying to use the code below to work out the last time the cron was updated, then minus the current time from that which will then give me time left untill the next cron update. I need to convert that to seconds and enter the value into the JC code "secs". Please see the code below: <?php $dTqry = "SELECT * FROM $mycrondb"; $dTres = mysql_query($dTqry); $dTrow = mysql_fetch_array($dTres); $dbtime = $dTrow['timed']; // h:i:s stored in the database eg: 10:02:39 $dbt = date('h:i:s', $dbtime); // database value $crt = date('h:i:s'); // current time $newtime = $crt - $dbt; // trying to get the difference ?> <script type="text/javascript"> /* START TIMER */ var timeInSecs; var ticker; function startTimer(secs) { timeInSecs = parseInt(secs); ticker = setInterval("tick()", 1000); } function tick( ) { var secs = timeInSecs; if (secs > 0) { timeInSecs--; } else { clearInterval(ticker); startTimer(300); // start again from 5 minutes } var mins = Math.floor(secs/60); secs %= 60; var pretty = ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; document.getElementById("countdown").innerHTML = pretty; } startTimer(<?php echo $newtime; ?>); // time left untill next cron update </script> <span id="countdown" style="font-size:12px;"></span> Now I am totally stuck on how to finish this little script. Anyone have any ideas? Kindest regards
  6. Hi Paystey, your explanation is very interesting and sounds safe, could you possibly help me further? I really would like to find a solution. Willing to pay if required (reasonable amount) :-\
  7. Please could you show me this in detail. As i said, I dont knoe javascript or Ajax. regrds
  8. Hi all, For the last week I have been pulling my hair out trying to figure out how to impliment a timer into my pages and have it countdown from 4 minutes 59 seconds. A simple countdown using javascript would solve the coundown issue but I need the timer to remain the same on everypage as it counts down - !important. Once it has counted down I need to execute a mysql query and then it starts again from 4mins 59secs. (Like mobwars or mafiawars for cash/energy). I found this on another website but dont know how to fill in the blanks: <?php session_start(); //to reset the saved countdown if (!empty($_REQUEST['resetCountdown'])) { unset($_SESSION['startTime']); } if (empty($_SESSION['startTime'])) { $_SESSION['startTime'] = time(); } //In seconds $startTime = time() - $_SESSION['startTime']; ?> <script type="text/javascript"> var countdown = 60; //in seconds var startTime = <?php echo $startTime; ?>; startCountdown(startTime, countdown); function startCountdown(startFrom, duration) { //countdown implementation } </script> <?php echo $startTime; ?> That is a start but when the page is refreshed it shows the counter going up? As I said I need the counter to perminantly display whilst counting down, accross ALL pages, execut a query, start again. I would really appreciate it if any of you top coders out there could help me finish it. I am a beginner at PHP and know NOTHING about javascript. PLEASE HELP, its driving me MAD !! :'( Many kind regards.
  9. Problem solved. I changed the modal to Ajax rather than iFrame and turned off cache. Works a treat now.
  10. Thats just it, I dont have any addons on my FF installation.
  11. The above code IS called inside a jquery iFrame popup though !
  12. Hi all, I am trying to get this code to update a gamers database field by 10 each time the query is run. The code is working fine in IE but for some reason it adds 30 in Firefox when it is supposed to add 10. Anyone any ideas on why its doing this? Is it something to do with the sessions? $mastery = $row['mastery']; /* Current mastery */ if($mastery == '0') { $mastery = '10'; } elseif($mastery > '0') { $mastery = $mastery + '10'; } if($row['mastery'] == '90') { $mastery = '0'; } $uqry = "UPDATE $table SET "; $uqry .= "mastery = '".$mastery."' "; $uqry .= "WHERE gamerid = '".mysql_real_escape_string($_SESSION['gid'])."'"; $ures = mysql_query($uqry);
  13. LOL by "sussed it" I meant the stuff after the query. I got myself stumped on how to display it :-\ Thanks very much for your help with the query mate, very kind.
  14. Think I have sussed it: <?php $qry = "SELECT COUNT(*) as cnt, username FROM $table GROUP BY username ORDER BY cnt DESC LIMIT 5"; $res = mysql_query($qry); while ($row = mysql_fetch_array($res)) { echo $row['cnt'].' '.$row['username'].'<br />'; } ?> Look ok to you Ben? It seems to be working fine.
  15. Thanks for the reply Ben. where do I go from here? I have no clue at all now. How do I get from that query to listing the top 5 entries by the user? Appreciate your valuable time!
  16. Hi all, I have a database that users enter records into. I want to list the top 5 record submitters but am unsure how to do it. Each time they enter a record their username and id is also entered so thats the basis of the query I believe. I want to display the results like so: Username: 21 Records Username: 19 Records and so on.. The query I need is stumping me a little. I understand that i first need to find out who has the most entries, how many they have and then display the results. Displaying the results is not a problem it is just the query itself as I am unable to use "WHERE id='blah'" etc. Anyone any ideas on this query? Regards
  17. Hi guys, Thanks for the replies. I am not too great with PHP at present. Could anyone give me an example on how to re-arrange the code to deal with the large image first and then the small thumb. Many thanks.
  18. Anyone have any sort of answer for this? i.e can it be optimized in any way. Sorry to be an annoyance. Regards
  19. Greetings all, I am struggling with a script on my server that is using alot of memory. I have upped the max file size and the memory limit to what my hosts will allow me to use. The code below is the main "feature" script of the whole thing. I am wondering if there is a way to optimize it at all. My clients NEED to upload photos, some over 2-3MB. $image = $_FILES["new_image"]["name"]; $uploadedfile = $_FILES['new_image']['tmp_name']; /* START DEALING WITH THE UPLOADED IMAGE */ if ($image) { $filename = stripslashes($_FILES['new_image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); $uploadedfile = $_FILES['new_image']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); list($width,$height) = getimagesize($uploadedfile); /* SET LARGE PHOTO SIZES */ $newwidth=600; $newheight=450; $tmp = imagecreatetruecolor($newwidth,$newheight); /* SET THUMBNAIL SIZES */ $newwidth1=250; $newheight1=188; $tmp1 = imagecreatetruecolor($newwidth1,$newheight1); /* COPY THE IMAGES */ imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); /* RENAME THE PHOTOS */ $newimagename = $hname.'.'.$extension; $newimagename1 = $hname.'.'.$extension; /* STORE THE IMAGE AND THUMBNAIL */ $filename = "../../****/images/****/". $newimagename; $filename1 = "../../****/images/****/thumbs/". $newimagename1; imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100); imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1); } Any help appreciated as I am working on abit of a deadline. Many thanks.
  20. Hi Ken, Yep, I got it now. The problem I was having was that when I used FOREACH nothing was happening. I changed it to FOR and it works a treat: $rdated = $_REQUEST['eracedated']; $rdatem = $_REQUEST['eracedatem']; $rtime = $_REQUEST['eracetime']; $rtype = $_REQUEST['eracetype']; $rage = $_REQUEST['eraceage']; $redted = $_REQUEST['eentdated']; $redtem = $_REQUEST['eentdatem']; $rtrack = $_REQUEST['eracetrack']; $rdist = $_REQUEST['eracedistance']; $rhid = $_REQUEST['ehid']; $rhorse = $_REQUEST['ehorse']; $arrlen = count($rdated); for($e=0; $e < $arrlen; $e++) { $rdated1 = $rdated[$e]; $rdatem1 = $rdatem[$e]; // same for the rest of the arrays print $rdated1.' '.$rdatem1.'<br>'; } All I need to do now is simply change the print to an sql query and roberts your fathers brother! Thanks for the help Ken, you are a star!
  21. Sorry Ken, I didnt explain myself enough. $rdated = $_REQUEST['eracedated']; $rdatem = $_REQUEST['eracedatem']; $rtime = $_REQUEST['eracetime']; $rtype = $_REQUEST['eracetype']; $rage = $_REQUEST['eraceage']; $redted = $_REQUEST['eentdated']; $redtem = $_REQUEST['eentdatem']; $rtrack = $_REQUEST['eracetrack']; $rdist = $_REQUEST['eracedistance']; $rhid = $_REQUEST['ehid']; $rhorse = $_REQUEST['ehorse']; That is what I want in one row on my database, not individually. Does that make sense?
  22. That is so annoying! I tried that and it wasnt working because I didnt set the array [] to the javascript names! LOL Thanks very much mate. Now, how would I store each form set into the database? i.e so they insert into seperate rows? Sorry to be a pain!
  23. The more I am looking into this the more I am thinking it is not possible. Anyone have an igloo on this?
×
×
  • 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.