Jump to content

jb60606

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jb60606's Achievements

Member

Member (2/5)

0

Reputation

  1. I've put together a very simple calendar with the following code. The calendar itself works fine, but I would like to give the user the option to, at least, click through the months (what good is a single month calendar). I'm somewhat new to PHP. I can get it to move forward or backward a month or year with some manipulation of the strtotime function or by adding/subtracting thousands of seconds from the date() function - but that's it. And no matter what month I'm on, it can only move to the two adjacent months. Also, if the month is currently April and I click the button to move forward one month, it takes me to May as it should. From May, if I want to move back one month it takes me to March. Any ideas? Thanks in advance. <?PHP if (isset ($_POST['back1'])) { $date = time() - 269743; $month = date('m',$date); $day = date('d',$date); $year = date('y',$date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); } elseif (isset ($_POST['forward1'])) { $date = time() + 269743; $month = date('m',$date); $day = date('d',$date); $year = date('y',$date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); } else{ $date = time(); $month = date('m',$date); $day = date('d',$date); $year = date('y',$date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); } ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="application/x-www-form-urlencoded"> <?PHP switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } $days_in_month = cal_days_in_month(0, $month, $year); echo "<div align=center><table width=\"550\" height=\"440\" class=cal>"; echo "<tr><th colspan=7 bgcolor=#F3F3F3><input name=\"back1\" type=\"submit\" value=\"<<\" /> $title $year <input name=\"forward1\" type=\"submit\" value=\">>\" /></th></tr>"; echo "<tr align=\"center\"><td width=75 height=20>Sun</td><td width=75>Mon</td><td width=75>Tue</td><td width=75>Wed</td><td width=75>Thu</td><td width=75>Fri</td><td width=75>Sat</td></tr>"; //This counts the days in the week, up to 7 $day_count = 1; $i = 0; if($i%2 == 0) { echo "<tr bgcolor='#F4F6FA'>"; $i++; } else { echo "<tr bgcolor='#FFF'>"; $i++; } //first we take care of those blank days while ( $blank > 0 ) { echo "<td bgcolor=#FCFCFC></td>"; $blank = $blank-1; $day_count++; } //sets the first day of the month to 1 $day_num = 1; //count up the days, untill we've done all of them in the month while ( $day_num <= $days_in_month ) { echo "<td valign=\"top\" align\"left\" class=\"cal\"> $day_num </td>"; $day_num++; $day_count++; //Make sure we start a new row every week if ($day_count > 7) { echo "</tr>"; if($i%2 == 0) { echo "<tr bgcolor='#F4F6FA'>"; $i++; } else { echo "<tr bgcolor='#F3F3F3'>"; $i++; } $day_count = 1; } } //Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td bgcolor=#FCFCFC> </td>"; $day_count++; } echo "</tr></table></div>"; ?>
  2. DOH! I meant "truncate". Thanks for your help; it works perfectly
  3. If I have a field (type = 'text') in my database called "comments"; containing various amounts of text submitted by users. I want to display those comments on a PHP web page, though I want to concatenate them to only show, say, the first 5 or 6 words of each individual comment. e.g.: "I think 300 sucked. The acting was terrible, the special effects were nothing I've never seen before and I question the timing of this movie's release." should read: "I think 300 sucked. The acting..." Any ideas... Thanks
  4. I'm sure there is a simple answer to this, though I'm new to mysql. I have several several large numbers stored in a mysql database. Type 'int'. One number, for example, could be '12351'. Is there any simple way to change that to, say, 12.351? The problem is that I'm using these numbers in a combination bar/line chart. The bars represent these large numbers (which can range between 9,000 and 100,000), and the line (which overlays the bars) represent smaller numbers (ranging from 1 to 100). As a result, the line is almost straight wherein fact it's numbers are quite volatile. Thanks in advance
  5. Thanks effigy; I appreciate any and all tips. Perl is probably the first language I am trying to learn thoroughly (as it is becoming more of a necessity within my role at work). I've been told numerous times to use the "strict" pragma, but laziness always gets the best of me; especially when I'm on a deadline or when problems like this regex issue arise & consume so much time. Usually I'm so ecstatic to get the the script working that -- if there are any potential issues that don't affect the the script's ability to function --I don't want to see them. As of late, though, I have been using it more often especially with smaller scripts. I just read that you can declare all private variables at the top of the script in one line (ie: my ($var1, $var2, $var3, $var4, $var5), etc), which definately makes the transition a lot easier. Thanks again.
  6. nevermind effigy. I'm an idiot. My regex was just missing representation for the single letters: A, C, M & S. For some reason, in another script I use, I only had to use the previous regex for it to recognize the single letters. New Regex is as follows: %sbfeeds = ( superbook1 => ["^[A]\$", "^[A][A-I]", "^[A][J-Z]", "^[b]", "^[C]\$", "^[C][A-M]"], superbook2 => ["^[C][N-Z]", "^[D]", "^[E]", "^[F]"], superbook3 => ["^[G]", "^[H]", "^[i]"], superbook4 => ["^[JK]", "^[L]", "^[M]\$", "^[M][A-L]", "^[M][M-Z]", "^[N]"], superbook5 => ["^[O]", "^[P]", "^[QR]", "^[s]\$", "^[s][A-N]"], superbook6 => ["^[s][O-Z]", "^[T]", "^[u-W]", "^[X-Z]"], ); Thanks
  7. Not sure if I know what you mean, but adding a question mark to the end of each resulted in symbols being found in all groups where a single letter of the symbol exists. For example: Enter the symbol: a A found in superbook1 Continue? (y/n): Enter the symbol: amd AMD found in superbook2 AMD found in superbook1 AMD found in superbook1 AMD found in superbook4 any ideas?
  8. I'm working on a Perl script that asks the user for a symbol and, using regex, determines what subgroup of a "hash" the symbol belongs to. %sbfeeds = ( superbook1 => ["^[A][A-I]", "^[A][J-Z]", "^[b]", "^[C][A-M]"], superbook2 => ["^[C][N-Z]", "^[D]", "^[E]", "^[F]"], superbook3 => ["^[G]", "^[H]", "^[i]"], superbook4 => ["^[JK]", "^[L]", "^[M][A-L]", "^[M][M-Z]", "^[N]"], superbook5 => ["^[O]", "^[P]", "^[QR]", "^[s][A-N]"], superbook6 => ["^[s][O-Z]", "^[T]", "^[u-W]", "^[X-Z]"] ); do { print "Enter the symbol: "; chomp($symbol = <>); $symbol = uc($symbol); foreach my $group(keys %sbfeeds){ foreach (@{$sbfeeds{$group}}) { if ($symbol =~ $_){ print "$symbol found in $group\n"; } } } print "\nContinue? (y/n): "; chomp($continue = <>); $continue = uc($continue); } until ($continue eq "N"); exit 0; So, for example, if the user types in the symbol "AMD", it will tell them that the symbol belongs to "superbook1". If the user types in "SIRI", it'll tell them "superbook6". The problem is with the single character symbols A, C, M & S -- they aren't being recognized. They all have one thing in common; they all appear twice. [A][A-I] [A][J-Z] [C][A-M] [C][N-Z] [M][A-L] [M][M-Z] etc Im somewhat new to perl, and very new to regex. Does anyone have any ideas? Thanks in advance.
  9. Problem solved. I deleted the CSS file and started from scratch. It doesn't have a problem with the TD classes, but something else was definately conflicting with the row highlighting. Thanks
  10. Thanks, I removed the TD classes (though they only changed the color and fixed the CSS, though it still doesn't work. There must be something else in the code that is denying this
  11. I think I should mention that when I similarily add a class name to a table cell, like below, it works fine. It seems as though it doesn't recognize what I want to do with "oRow.className =", but understands tdSymbol.className = "ajaxStockWatchlist-stockSymbol"; just fine. var oRow = this.table.insertRow(i); oRow.className = "altcolor"; //Add a cell for the stock's symbol var tdSymbol = oRow.insertCell(0); tdSymbol.className = "ajaxWatchlist-stockSymbol";
  12. This little snippet of code is from a AJAX/PHP/JavaScript widget that retrieves stock quotes and fills in a table with the data. From the JavaScript file: for (var i = 0; i < oResult.stocks.length; i++) { var altcolor = i % 2 == 0 ? 'light' : 'dark'; var oStock = oResult.stocks[i]; var oRow = this.table.insertRow(i); oRow.className = "altcolor"; From the CSS file: .light { background:#000000; } .dark { background-color:#FFFFFF; } I literally just started learning DOM and JavaScript about 4 hrs ago, but shouldn't the above snippet work? It works in another plain JavaScript file that I have. I've also tried a few other similar methods I found on the web, though, they didn't see to work either. Thanks in advance.
  13. Thanks, I figured as much. I've tried replacing the DIV tags with TR/TD tags, etc, though, with the way the Javascript outputs the data, it screwed up the formatting. It's a third party script that I paid for, so I may have to ask/pay them to write a custom script. Thanks
  14. does anyone know a row highlighting technique that will work with CSS tables. I need the rows highlighted on a mouse rollover, or atleast a mouse click event. Is this even possible? An AJAX script i've obtained uses a CSS table to organize it's data via multiple "<DIV>" tags. I've since configured the script to retrieve data from a mySQL database and it has become increasingly difficult to distinguish one line of data from the next, even with static row coloring. Thanks in advance.
  15. DOH! Nevermind... just stumbled upon the answer! It turns out it was that !feof bit. I guess it will spit out a blank line until it receives some kind of end-of-file pointer, or something like that. I replaced it with: while ( ($data = fgetcsv($handle, 200, ",")) !== false ) { I don't know if it's the most effective solution, but it looks like its getting the job done. The extra line is gone. Find out more from the comments here: http://us2.php.net/feof
×
×
  • 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.