Jump to content

a.mlw.walker

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

a.mlw.walker's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK So i managed to get it to not produce the error by changing the condition to: if ((count($tournKeys) == $c+1) || (($gameKeys[$e] > $tournKeys[$c]) && ($gameKeys[$e] < $tournKeys[$c+1]))) however if my list were: It now outputs this: i.e it seems to print again. Any ideas why changing the condition like that would cause that to happen?
  2. So is there no way for me to know whether the explode was succesful in terms of whether it found the delimiter and "exploded" it? Ah I used a strpos. Thanks
  3. That is a nice proposal, however i think merely calling explode forces pieces into an array, because even if there is no " v " it still thinks pieces is an array because if I do $pieces = explode(" v ", strip_tags($matches[$gameKeys[$e]])); echo "<p>pieces = ". $pieces; It returns: pieces = Array
  4. So is there a way to check whether calling the fucntion explode returns succesful rather than generating an error?
  5. I am getting an undefined offset when using an explode. Usually it works however on one instance it fails. It is the second explode here that is failing, because there was no instance of " v " in the first one: $pieces = explode(" v ", strip_tags($matches[$gameKeys[$e]])); echo $pieces[1]."<p>"; $findtime = explode(",", $pieces[1]); print_r($findtime); produces: So it works on the one above and below, however one of them seems to have nothing in it, and therefore pops up an error. This won't always be the case, but sometimes this might occur. The data it is reading from shows this: Morocco v Tunisia, GpC, 19:00 Qatar OFF Sweden, 13:00 Cardiff v Crystal Palace, (agg 0-1), SF, L2, 19:45 So you can see the Qatar one is of slightly different format - it says OFF instead of " v ". Can i run an if statement on the first one. So if there was a " v " then do the next else have something that will avoid the error occuring? Rate this post
  6. Have I foxxed you all? I cant think of a solution either! I have seen that the function next(); exists. Perhaps I should be using this in some way. Im thinking if (next($dayKeys) exists)??? or something that was a bit pseudo but you know what I mean? What about using http://www.php.net/manual/en/function.array-key-exists.php in some way? its confusing me, however I can see there must be a way to get around it...
  7. So I have a list of events happening on certain dates Date event event event Date event event Date event Date event event i.e the number of events per date change. The whole list is stored in an array called $matches. Depending on the formatting of the event or date tells the computer (or me) whether it is an event or a date. So the locations of the dates within $matches[] are stored in the array $dayKeys, and the position of the events within $matches[] is stored in the array $tournKeys. I am trying to print the list back out in the correct order. foreach($dayKeys as $a => $b) { $c = $a; foreach($tournKeys as $c => $d) { if (($tournKeys[$c] > $dayKeys[$a]) && ($tournKeys[$c] < $dayKeys[$a+1])) //if both are true print the events until it is required to print the next date as oppposed to an event. { ......print the data from matches..... } } } I have tried to simplify the above loops as much as possible for this thread. My point is though, that when I am at the end of $dayKeys, $dayKeys[$a+1] generates an error, because there are no more $dayKeys. So my question is how should I rephrase that if condition so that I dont have to look to see whether The next thing to print is a date or an event by looking at the next $dayKeys value?
  8. OK, So I can put the apostrophe straight into a database using: mysql_real_escape_string($AwayTeam) kind of thing. however I notice the problem is arising when I try to pass the word with an apostrophe in via a form. If I disregard escaping it like so: echo "<input type='hidden' name='AwayTeam' value= '".$user_array['COL 4']."' />"; Then everything before the apostrophe is posted, so if the word is Nott'ham, then Nott is posted. If I put the escape in like so: echo "<input type='hidden' name='AwayTeam' value= '".mysql_real_escape_string($user_array['COL 4'])."' />"; Then a slash is also posted, but not the apostrophe, and nothing after that, like so: Nott\ Then I get an error because I am then trying to pass the word to a database, and it is trying to pass Nott\
  9. Ahhh thats soo much better. One table all entries and a unique identifier. So now I just need to find all cases of a field having the same value - i.e a book title or whatever, and then average the rating for each one. So I suppose the first thing to do is find out how many distinct 'books' there are, then for each of the cases, average their ratings box? is that how you guys would do it?
  10. Thanks for that link. Incidently, $interval->format('%R%a') == 0 whats I cant find it on the formatting page?
  11. I see. so have one table and just add a field that is the userID or whatever. Then when search for entries by a user also include a match in that field for a current user. Yeah I see that: http://en.wikipedia.org/wiki/File:Update_anomaly.png
  12. I mean, as long as the entry doesnt have an apostrope, then the sql statement is fine. Its not a typo because it works otherwise...
  13. Wow! in terms of database space that sounds inefficient! Surely storing it in the table that stores the user data is more efficient! The thing is my users are only giving ratings, and their "usefulness" is based on how "good" their ratings are. So Rather than the product being the important piece of info, its the user's ability to "rate" well. I.e each table represents a user, and I want to be able to run through the ALL my users and cross reference the things that have been rated and come up with an average. What would you recommend. To put it in other terms, forget what I've said so far, and think if you had a load of tables in a database, and you wanted to search all the tables for similar entries, and add up the value of a certain field within those tables of the matching entries, how would you do it?
  14. so its a plus not a minus! Sorry If I wasnt clear but basically if $dt->format('Y n j') is the same day as today, i.e date('Y n j) and the hour now is the same as my variable $pieces[2], which in this case stated it was half five, (17:30) then I want to run a condition to check whether it is before half four or not on the day that $dt->format('Y n j') states it is.
×
×
  • 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.