Jump to content

Hilly_2004

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by Hilly_2004

  1. Firstly, thanks for all the help Mchl, it's very much appreciated. However, can I do the above without the need for a MYSQL function? It's just I'm still on MYSQL 4 and I'm unable to upgrade in the mean time due to circumstances beyond my control.
  2. Ha! I honestly thought it would just have been a simple SELECT statement and I was being an idiot somewhere! In terms of performance, I will only be bringing back 10 records, so hopefully if you have a working query it shouldn't effect performance that much?
  3. Although valid (bravo by the way! ), unfortunately the output is still the same... Timestamp, M_Timestamp_Edit and Timestamp_Edit. Just seen your update! Would it make any difference if I changed it from Timestamps to Date or would I stumble into the same problem?
  4. Is it possible? Here is my table (Events) Basically, I want to group the C_Timestamp, Timestamp, M_Timestamp_Edit, C_Timestamp_Edit and Timestamp_Edit as one and then order them based on the most recent (Descending). My SELECT statement looks like so... $query = "SELECT forum_members.M_FIRSTNAME, forum_members.M_SURNAME, Events.C_Timestamp, Events.Timestamp, Events.M_Timestamp_Edit, Events.C_Timestamp_Edit, Events.Timestamp_Edit FROM forum_members, Events WHERE forum_members.MEMBER_ID = Events.MEMBER_ID ORDER BY C_Timestamp DESC, Timestamp DESC, M_Timestamp_Edit DESC, C_Timestamp_Edit DESC, Timestamp_Edit DESC"; At the minute, it's just outputting information based on the order of the columns e.g. the first output is Timestamp, the second is M_Timestamp_Edit and the last being Timestamp_Edit. I'm thinking that because the information in the table is a UNIX Timestamp, it might be better formatting the columns as DATE and inserting and sorting by that way - would there be any difference? Thanks in advance for any help guys!
  5. Think of it like a "Recent Activity" widget... e.g. Stephen Hill has updated their profile... (2 hours ago...) Charlotte Morley has posted a submission... (3 hours ago...) The amount of information displayed above can obviously change depending on how in depth I want it to be, but the above is a good start.
  6. Is it possible to display data from 2 separate tables and order the way it's displayed based on 2 columns from the separate tables. e.g. forum_members MEMBER_ID | M_FIRSTNAME | M_SURNAME | M_PROFILEUPDATE submissions MEMBER_ID | TITLE | SUMMARY | TIMESTAMP M_PROFILEUPDATE and TIMESTAMP are obviously timestamp records, so hopefully the end goal would be to order the 2 tables based on this columns (the latest being displayed first). Thanks in advance for any help!
  7. Wahey! Get in, works like a charm. Have a look at your handy work: http://www.kingjamescc.co.uk/barchart.php
  8. Afraid not... When you echo the str variable, it just prints out: ");"
  9. I've just tested that and unfortunately the source code shows it as: var myData = new Array(); myData[0] = new Array('Bowled','24'); myData[1] = new Array('Caught','11'); myData[2] = new Array('L.B.W.','5'); ...it needs to be in the exact same format as: var myData = new Array(['Bowled', 23], ['Caught', 44], ['LBW', 11]);
  10. Simple really. I'm trying to go from a PHP array to a JavaScript array in the following format: var myData = new Array(['Bowled', 23], ['Caught', 44], ['LBW', 11]); My question is...how? The data to populate the array will be retrieved from a table in the database e.g. Wicket_ID How_Out Number_Of_Times 1 Bowled 23 2 Caught 44 3 LBW 11 How do I retrieve this data from the database, make it into an array, and then pass that array across into it's JavaScript equivilant? Any help whatsoever would be greatly appreciated!
  11. Fantastic, works a treat, cheers Barand. One thing I needed to add to get it to work was: $monthyear = $myrow['monthyear']; ...but that's trivial anyway. Once again, thank you!
  12. ....or something like this: (Don't know how valid this is mind you) SELECT * FROM tbl_news WHERE DATE = DATE_FORMAT('$VARIABLE', '%M %Y') ORDER BY Date
  13. Works a treat....cheers Barand. One more, and I think this is the easy part. Obviously with this it will echo out: July 2008 etc... On the next page I have to pass across a variable for the SELECT procedure to get all of the records in that month. Will it be something like: SELECT * FROM tbl_news WHERE Date = '%M %Y' ORDER BY Date
  14. $result = mysql_query("SELECT DISTINCT DATE_FORMAT(Date, '%M %Y') as monthyear FROM tbl_news ORDER BY Date",$connect); while($myrow = mysql_fetch_array($result)) { echo $monthyear; echo "</br>"; } Obviously I'm doing it wrong.
  15. The problem with that I'm guessing is that it requires me to enter the specific month e.g. May 2008. I want the script to dynamically check if there have been any records created, and sort them into the relevant months.... e.g. The end list may look like: June 2007 January 2008 April 2008 May 2008 etc....
  16. Barand....the timestamp is formatted like: 2008-06-04 17:37:35
  17. Spot on Wuhtzu... In my mind I see 2 pages. 1st page is a script which gets all the records in tbl_news and checks to see which month and it's year a record has been added e.g. Has there been anything posted in April 2008? No....don't display a link. Has there been anything posted in May 2008? Yes........display "May 2008" and a link to the next page. The next page then displays all of the records added in May 2008 which might be 4 or 5. Hope that makes sense?
  18. Hi guys, Bit of help. I have a table in a database called tbl_news. How would I go about sorting all of the records in that table into the same month by the timestamps at which they were created.... e.g. Basically I want the page to dynamically check if records were posted in a certain month of the year and if they were echo a link...... June 2008 May 2008 April 2008 Then that link would go to a page where all the news stories posted in that month would be displayed.
  19. Cheers! Works a treat. For anyone else wondering my script looks like: <?php //Load all fixtures from the database and then ORDER them by Date (nearest date displayed first) $today = date("Y-m-d"); $result = mysql_query("SELECT * FROM tbl_fixtures WHERE Fixture_Date > '$today' ORDER BY Fixture_Date ASC LIMIT 1", $connect); //Loop and Get All The Fixtures From The Database while($myrow = mysql_fetch_array($result)) { //Prints Results echo "<p class=\"ColumnTitle\">"; echo $myrow['Opponent']; echo "</p>"; } ?>
  20. Hi guys, I've searched through the forums, and haven't found anything that might help me. I have a field in a table called "Fixture_Date" with a 'date' type e.g. YYYY-MM-DD, does anyone know a select query that will select the next upcoming event based on the current date? Thanks for any help you can throw my way!
  21. Hi guys I have this simple script, but it doesn't some to be echoing the expect results... Can anyone see where I'm going wrong? <?php $bowled = "15"; $caught = "12"; $stumped = "1"; $other = "5"; $highest = max($bowled, $caught, $stumped, $runout, $other); // Gets highest number of dismissals from the database echo $highest if ($highest === $bowled) { $bowled_height = "160"; $caught_height = 160 / $caught; $stumped_height = 160 / $stumped; $runout_height = 160 / $runout; $other_height = 160 / $other; } elseif ($highest === $caught) { $bowled_height = 160 / $bowled; $caught_height = "160"; $stumped_height = 160 / $stumped; $runout_height = 160 / $runout; $other_height = 160 / $other; } elseif ($highest === $stumped) { $bowled_height = 160 / $bowled; $caught_height = 160 / $caught; $stumped_height = "160"; $runout_height = 160 / $runout; $other_height = 160 / $other; } elseif ($highest === $runout) { $bowled_height = 160 / $bowled; $caught_height = 160 / $caught; $stumped_height = 160 / $stumped; $runout_height = "160"; $other_height = 160 / $other; } elseif ($highest === $other) { $bowled_height = 160 / $bowled; $caught_height = 160 / $caught; $stumped_height = 160 / $stumped; $runout_height = 160 / $runout; $other_height = "160"; } else { echo "Something's cocked up"; } echo $bowled_height echo $caught_height echo $stumped_height echo $runout_height echo $other_height
  22. First off, let me apologise for asking such a newbie question... This is my code.... // Fetch RSS feed $rss = fetch_rss('http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/eng_div_3/rss.xml'); if ($rss) { // Split the array to show first 10 $items = array_slice($rss->items, 0, 10); // Cycle through each item and echo foreach ($items as $item ) { echo '<li><a href="'.$item['link'].'">'.$item['title'].'</a> - '.$item['description'].'</li>'; } } else { echo '<h2>Error:</h2><p>'.magpie_error().'</p>'; } It's basically displaying information from an RSS feed on my page. However I want to display 2 pieces of that array at once, then in the next loop, get the next 2 arrays, and so on and so forth.
  23. Hi Guys, Wondered if you could help me. Im using prototype.js to help me add a weather console to my site using Yahoo!'s weather feed. Now I've created a very basic HTML page which works as expected, however when I add that page into my site it refuses to work, leaving me very puzzled indeed! http://www.e-lementdesigns.com/temp-cricket/weather/ Heres my example page, firstly the javascript: <script type="text/javascript" src="../Scripts/prototype.js"></script> <script type="text/javascript" language="JavaScript"> function reportError2(request) { $F('WeatherDetails') = "Error"; } function WeatherLookup() { // Swap Div contents to loading... document.getElementById("WeatherDetails").innerHTML = "Loading..." // Call XML feed var url = 'ajax_test.php?theCityCode='+$F('theCity'); var params = ''; var ajax = new Ajax.Updater({success: 'WeatherDetails'},url,{method: 'get', parameters: params, onFailure: reportError2}); } </script> Secondly, the form used: <body onLoad="WeatherLookup();"> <h3>Cricket Weather:<br></h3> <form> <select name="theCity" id="theCity" onChange="WeatherLookup(this.value);"> <option selected="selected" value="0" label="Select a cricket venue">Select a cricket venue</option> <option value="UKXX1798">Aldbrough St John</option> <option value="UKXX1798">Barningham</option> <option value="UKXX1798">Barton</option> <option value="UKXX0657">Catterick</option> <option value="UKXX0817">Cliffe</option> <option value="UKXX0817">Cockerton</option> <option value="UKXX0817">Haughton</option> <option value="UKXX0556">Heighington</option> <option value="UKXX1150">King James</option> <option value="UKXX1150">Lands</option> <option value="UKXX0817">Raby Castle</option> <option value="UKXX0721">Trimdon</option> </select> </form> <div id="WeatherDetails"> </div> </body> </html> Now as I say, this works fine. The page displays "Loading..." when trying to find the feed, then when found displays the weather found in ajax_test.php Now, this is all well and good but I need this to work within my site. Now surely it should just be a case of inserting the javascript into the head of the page, and the form into my site, and of course making sure that all the links point to the right location. I've done this yet when I try and use the form, the feed isn't brought back and "Loading..." is just displayed. Here is my PHP page: <?php if (!$_GET["theCityCode"]) { $xml_file=file_get_contents("http://xml.weather.yahoo.com/forecastrss?p=UKXX1150&u=c"); } elseif ($_GET["theCityCode"]) { $xml_file=file_get_contents("http://xml.weather.yahoo.com/forecastrss?p=" . $theCityCode . "&u=c"); } //******************** GETTING THE INFORMATION **************************** // For getting the last build date preg_match_all("#<lastBuildDate>(.*?)</lastBuildDate>#s",$xml_file,$today); $today= $today[1][0]; // For getting the title preg_match_all("#<title>Yahoo! Weather - (.*?)</title>#s",$xml_file,$title); $StrippedTitle = $title[1][0]; // for getting the sunrise and the sunset preg_match_all("/<yweather:astronomy([^\<]*)/i", $xml_file, $res0); // res1 for getting the sunset and sunrise preg_match_all("/([^\"]*)/i", $res0[1][0], $res1); // res0 contains all the information/day preg_match_all("/<yweather:forecast([^<]*)/i", $xml_file, $res); //************************************************************************ $n=0; $days=count($res); // count the number of forecast days in the array while($n<$days) { preg_match_all("/\"([^\"]*)/i", $res[1][$n], $array); $day[$n] =$array[1][0]; $date[$n]=$array[1][2]; $low[$n] =$array[1][4]; $high[$n]=$array[1][6]; $text[$n]=$array[1][8]; $code[$n]=$array[1][10]; $n++; } echo "<p class=\"ColumnBody\"><strong>" . $StrippedTitle . "</strong></p>"; for($n=0; $n<$days;$n++) // Day Forecast day 1,2,3, ... { echo "<p class=\"ColumnTitle\"><a href=\"#\">" .$day[$n]. "</a></p>"; echo "<div class=\"WeatherSymbol\"><img src=\"../Images/weather/".$code[$n].".png\" ></div>"; echo "<p class=\"ColumnBody\"><strong>Today </strong><br />"; echo $text[$n]."<br>"; // Partly Cloudy echo "low °C: ".$low[$n]."<br>"; // 8 echo "high °C: ".$high[$n]."<br>"; // 19 echo "</p><br />"; } ?> I realise this seems a long request, but any help whatsoever would be really appreciated.
  24. Cheers for that JRS, Il try and employ some of the code into the workings of mine... Ive managed to kind of do this loop thing I was on about however I know for a fact that it could and SHOULD be done much easier, instead Ive had use 10 sql queries to get 10 bits of information out of the database (10 being the maximum number of people a user can select), I know it should be done using an array but I dont know how.... [code] if (isset($_REQUEST['studentIDs'])) { $error = 0; //get student id's passed by flash $studentIDs = $_REQUEST['studentIDs']; //get email address to send to $emailAddress = $_REQUEST['emailAddress']; //create array of student id's $idArray = explode("-",  $studentIDs); $test = array($idArray); foreach($test AS $key => $value) //--------------------------------------------------------------------------- $Query3 = "SELECT * FROM students_test WHERE studentID = '$value[0]'"; $Result3 = mysql_query($Query3); $num = mysql_num_rows($Result3); if ($Result3) { while($row = mysql_fetch_array($Result3)) { $firstname = $row['firstName']; $blurb = $row['blurb']; $lastname = $row['lastName']; $course = $row['course']; if ($course == 'i'){$course = "Interactive Multimedia";} else if ($course == "w"){$course = "Web Design";} else if ($course == "g"){$course = "Games Design";} $web = $row['web'];         }     } if($firstname == ''){} else { $user = "<strong>$firstname $lastname</strong><br>     $course<br>     <a href=\"http://$web\">$web</a><p>     $blurb</p>     <hr>"; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- $Query3 = "SELECT * FROM students_test WHERE studentID = '$value[1]'"; $Result3 = mysql_query($Query3); $num = mysql_num_rows($Result3); if ($Result3) { while($row = mysql_fetch_array($Result3)) { $firstname1 = $row['firstName']; $blurb1 = $row['blurb']; $lastname1 = $row['lastName']; $course1 = $row['course']; if ($course1 == 'i'){$course1 = "Interactive Multimedia";} else if ($course1 == "w"){$course1 = "Web Design";} else if ($course1 == "g"){$course1 = "Games Design";} $web1 = $row['web'];         }     } if($firstname1 == ''){} else { $user1 = "<strong>$firstname1 $lastname1</strong><br>     $course1<br>     <a href=\"http://$web1\">$web1</a><p>     $blurb1</p>     <hr>"; } //--------------------------------------------------------------------------- $Query3 = "SELECT * FROM students_test WHERE studentID = '$value[2]'"; $Result3 = mysql_query($Query3); $num = mysql_num_rows($Result3); if ($Result3) { while($row = mysql_fetch_array($Result3)) { $firstname2 = $row['firstName']; $blurb2 = $row['blurb']; $lastname2 = $row['lastName']; $course2 = $row['course']; if ($course2 == 'i'){$course2 = "Interactive Multimedia";} else if ($course2 == "w"){$course2 = "Web Design";} else if ($course2 == "g"){$course2 = "Games Design";} $web2 = $row['web'];         }     } if($firstname2 == ''){} else { $user2 = "<strong>$firstname2 $lastname2</strong><br>     $course2<br>     <a href=\"http://$web2\">$web2</a><p>     $blurb2</p>     <hr>"; } [/code] etc...etc... but 10 times!!!!
×
×
  • 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.