Jump to content

gin

Members
  • Posts

    82
  • Joined

  • Last visited

    Never

Everything posted by gin

  1. I'm not entirely sure what you mean by granularity but I think I get it. Users can only select times at half hour intervals, incidentally. So one pass to create an $output array and a $clash array, then loop thru the $output array while checking with the $clash array whether to output the additional image, right? Wow, still something of a headache, but doable now. Thank, I'll try this!
  2. Actually that sounds like a properly formatted CSV file to me. You can do something like so: (not tested!) LOAD DATA INFILE 'data.csv' INTO TABLE my_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'; IGNORE 2 LINES; Look up the LOAD DATA INFILE commmand in the MySQL Manual. I think MySQL might even be able to handle gzipped files, you'll have to look it up. At the end of the day, I doubt you'll need to do any tinkering from the PHP end at all.
  3. Since I'm not familiar with MS access, this is just a guess, but is one of the fields set as a primary key? And if so, does the entry you just input already exist?
  4. There's a tutorial about this here: http://www.phpfreaks.com/tutorials/9/0.php Not entirely code efficient, but an okay beginner tutorial.
  5. I really hate it when a designer gives me something like that to work with. I've changed that over the last few years by going over there and looming at them when I hear a site re-design is in the offing. Really, they're crappy site designers if they haven't considered text overflow. I'm with the above, use the overflow and let it scroll. Personally, in a similar case when I couldn't let it scroll, I just used an overflow: hidden, and let the user figure it out for themselves. Incidentally, in IE one of the properties will add an ellipsis (...) for you (can't remember which, sorry). But only in IE and no other browser. If you really want to count chars and manually add an ellipsis, make your life easier by using a fixed-width font like uh... courier, I think it was.
  6. I'm building a scheduler, something along the lines of Google Calendar, where a user can input events and generally plan their day. One of the features I wish to add is a check for time clashing, where if two events overlap a small image alert will display. What I currently have is like so: 1) query db and loop thru results 2) for each and every event, query db again and look for clashes 3) if there are clashes, add image to $output 4) echo $output The actual problem is the query within a loop, which is an awful example of coding, I know. Is there some kind of... uh, funky recursive loop or something... that I can use? Any advise appreciated. This is the actual code, if anyone's interested: [code] <?php // sort of pseudo code // Get all events happening in a day. // For each event check if another event clashes with it, then output. $query = "SELECT * FROM events WHERE date='$today'"; $result = mysql_query($query) or die ("Query failed: " . mysql_error()); if ($myrow = mysql_fetch_array($result)) { do { $this_id = $myrow['id']; $ts = $myrow['timestart']; $te = $myrow['timeend']; $query2 = "SELECT id,timestart,timeend FROM events WHERE date='$today' AND id<>$this_id"; $result2 = mysql_query($query2) or die ("Query failed: " . mysql_error()); while ($myrow2 = mysql_fetch_array($result2)) { $ts2 = $myrow['timestart']; $te2 = $myrow['timeend']; // if event2 starts and ends totally before or after event1, then no clash if ( ($te2<=$ts) || ($ts2>=$te) ) { // no clash } else { // clash! $clash[$j] = $myrow['id']; $j++; } } if ($j>0) $clash = '<img src="clash.gif">'; echo $clash.' event details here'; // output event details } while ($myrow = mysql_fetch_array($result)); } ?> [/code] Edit: Edited for clarity.
×
×
  • 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.