Jump to content

bschultz

Members
  • Posts

    486
  • Joined

  • Last visited

Everything posted by bschultz

  1. Alright...I have most of this figured out...except for how to remove periods...WHEN THERE ISN'T A NUMBER IN FRONT OF OR AFTER IT. For instance would keep the 2.0...but replace the period in 8 . 2 with a comma. Any ideas? Also, I need to remove the dashes too...and I HATE regex. Here's the code <?php if ($_POST['submit'] == 'submit') { $array = explode("\n", $_POST['stats']); foreach($array as $value) { $step1 = str_replace(',', ' ', $value); $step2 = preg_replace('/\s+/',',',$step1); echo $step2 . "<br />"; } } ?>
  2. Makes sense...do you know, does Word do anything funky with a table if you copy and paste? Just want to know what I need to strip out. Also, is there a way to have the end user define what order their info is in? Maybe another table that has "their" order so that I can put it into the db in the right order.
  3. I am a radio sports announcer by trade...just happen to dabble in php coding. A few years ago, I developed a system to put football (American) statistics into Excel and upload that (CSV) into a database to ease in preparing for a football broadcast. These stats can either be found on the schools website, or they may send me a Word Document, or a PDF...or maybe even an Excel spreadsheet with their stats...might be a table, might not...that then needs to be entered into "my" Excel spreadsheet (with my formatting, and correct column layout) usually by hand. I'd like to develop a system to "copy and paste" into a web form, and then upload the data to the database. Here's the format of the stats from the web (in an html table) I'm going into this kinda blind...not knowing which direction to go. Should I strip out the whitespace and replace with a comma and continue to upload using CSV? How should I go about maintaining newlines...and knowing which player I'm supposed to update info for? Is there a "better" way to get this info into the DB? What should my database structure be? How should I get the roster imported first...before the stats. Is there a way to leave the column layout of what they're copying and pasting up to them? (There really isn't a "standard" for what order the stats are in or the roster columns. Some will have number, first name, last name, height, weight, hometown... some will have number, last name, first name, hometown, weight, height). Let me know if this doesn't make sense to you...I'm not sure it does to me! Thanks for your time! Brian
  4. The following code is causing a maximum execution time error... $count = count($links); // how many items are in the array // echo $count; exit; //this echo's 16...so there's stuff in the array $i = 0; // total count $s = 0; // table cell count...should ever get above the value of 3 while ($i <= $count); { if ($s == 0) { echo "<tr>"; } // if at the start of a table row, start the row echo $links[$i]; $i++; $s++; // print out the table cell with the proper value if ($s < 3) { echo "<td> </td>"; $s++; } // if we're not at table column 3, add a new column...this also should close the row with "null" values to fill in the table if ($s == 3) { echo "</tr>"; $s = 0; } // are we at table column 3? If so, close the row. } I'm trying to get the values from an array into an html table...three columns wide. Obviously, the loop is stuck, so the max execution time is running out. I just can't see where. Any ideas? Thanks!
  5. got it... $slashes_title = stripslashes($row['headline']); $title = mysql_real_escape_string($slashes_title); $stripslashes= stripslashes($row['story']);; $story = mysql_real_escape_string($stripslashes);
  6. OK...got that working. Now, I need to fix slashes. The old system (which I wrote a LONG time ago) used addslashes to the posts. When I import that into the new Wordpress Database...it has slashes echoed in everything. So, does anyone know where I can add STRIPSLASHES in the WP code (I'm VERY new to WP)... or how can I strip the slashes from my select...before I insert into the WP table? I tried to: $stripslashes= stripslashes($row['story']); But the insert failed at every quote in the original post. Thanks!
  7. thanks...was trying to do this in one step...but that will work.
  8. I"m working on importing my existing website (with a custom cms) into a wordpress system. I'm trying to insert all of my current posts...and need to know what the insert id is for the WP system. I know that mysql_insert_id will get the key of the LAST query...but is there a way to get the id of the CURRENT query?
  9. Alright, after another day of Googling... I've come up with this function. It works as is...but it doesn't take into account what sport it is. SO, if I have 2 values in the array for baseball with Team B, and 1 value for softball for Team B...it gives me a count of 3. I need the count for each sport. Any ideas on how to alter this function to accommodate what I'm looking for? Thanks! <?php function array_icount_values($arr,$lower=false) { $arr2=array(); if(!is_array($arr['0'])){$arr=array($arr);} foreach($arr as $k=> $v){ foreach($v as $v2){ if($lower==true) {$v2=strtolower($v2);} if(!isset($arr2[$v2])){ $arr2[$v2]=1; }else{ $arr2[$v2]++; } } } return $arr2; } $res = array_icount_values($games); print_r($res); ?> This returns this:
  10. But, the value for home and visitor will be the names of teams... For instance (games worked by umpire #6, who has worked five games) #1 - key sport = baseball -- key visitor = Town A -- key home = Town B #2 - key sport = baseball -- key visitor = Town C -- key home = Town A #3 - key sport = softball -- key visitor = Town A -- key home = Town D #4 - key sport = baseball -- key visitor = Town E -- key home = Town C #5 - key sport = baseball -- key visitor = Town A -- key home = Town B I need the results / count of how many key = baseball (which should be 4 in this case) I need the results / count of how many key = baseball and EITHER key visitor or key home = TOWN A (which should be 3 in this case, games 1, 2 and 5 --- not game 3 because it's a softball game) I need the results / count of how many key = baseball and EITHER key visitor or key home = TOWN B (which should be 2 in this case, games 1 and 5) I need the results / count of how many key = baseball and EITHER key visitor or key home = TOWN C (which should be 2 in this case, games 2 and 4) I need the results / count of how many key = softball and EITHER key visitor or key home = TOWN D (which should be 1 in this case, game 3) I need the results / count of how many key = baseball and EITHER key visitor or key home = TOWN E (which should be 1 in this case, game 4) And all of this needs to be dynamic. I don't know the name of the sport...the name of the team for visitor or the name for the team that is the home team.
  11. I don't know what the content of visitor and home are going to be...and I never will. How would I adjust the select statement if I don't know what those are? I have to go umpire a game (ironically!). Thanks for the help...I'll be back tonight!
  12. I am scheduling sports officials. I want to see how many (for instance) times an umpire is working baseball as opposed to softball (count keys for sport=baseball or sport=softball). Also, I don't want to schedule the same umpire to work the same team too often. So, count keys=sport, keys=visitor (for each team that comes up as the visitor) and keys=home (for each team that comes up as the home team) and then I'll know how many times a certain umpire has seen a certain team (both at home and on the road). Make sense?
  13. I'm trying to get an array with keys and values from a while loop in mysql. However, this only returns the last result...not a completed array <?php $sql3 = "SELECT game_id, sport, visitor, home FROM games WHERE `game_id` IN ($all_games_worked_by_this_official_this_year)"; $rs3 = mysql_query($sql3,$dbc); while ($row3 = mysql_fetch_assoc($rs3)) { $games_array['sport'] = $row3['sport']; $games_array['visitor'] = $row3['visitor']; $games_array['home'] = $row3['home']; } print_r($games_array); ?> The result is this: If I remove the keys...I get the full results: <?php $sql3 = "SELECT game_id, sport, visitor, home FROM games WHERE `game_id` IN ($all_games_worked_by_this_official_this_year)"; $rs3 = mysql_query($sql3,$dbc); while ($row3 = mysql_fetch_assoc($rs3)) { //$games_array['sport'] = $row3['sport']; //$games_array['visitor'] = $row3['visitor']; //$games_array['home'] = $row3['home']; $games_array[] = $row3['sport']; $games_array[] = $row3['visitor']; $games_array[] = $row3['home']; } print_r($games_array); ?> Returns this: The second result is what I want (but without the keys). Who can I make this work WITH the keys? Once I get this working, I will probably need some help to count and sort the array...but we'll start with this. Thanks!
  14. I need to use a variable variable. I need: $row['pos_1'] $row['pos_2'] to use $i for the numbers I have this: if ($row{[pos_.$i]} == 'ad') which is throwing an error Any ideas? Thanks!
  15. I have a select statement in a function that I need to tweak. I needed to add a field to the database, and now the current select won't work. Here's the select: $sql = "SELECT row_number, title, $priCASE FROM new_audio WHERE (`client_id` = '$client' or `corporation` = '$corporate') AND (`start_date` <= '$now' AND `end_date` >= '$now') AND `$dow` = '1' AND `is_active` = '1' AND (`start_hour` <= '$hour' AND `end_hour` >= '$hour') AND `priority` IN ($priIN) ORDER BY priSort, last_play ASC LIMIT 1"; $client and $corporate used to be hard coded. For instance, client id 1 would be store A. Client id 2 would be store B. Client id 3 would be BOTH STORE A AND STORE B. I've now put that info into another db table, so that I can consolidate about 10 scripts into 1. As the info is now, if $client = 0, the commercial to play is a CORPORATE-WIDE ad (plays at ALL locations of a company). If this is the case, the $corporate field has that company's corporate id in it. If not, it's a STORE-SPECIFIC ad...that only plays at the on location. In this case, the $client will have a value (not 0), while the $corporate field will be 0. How should I change the select to account for NOT SELECTING a client that equals 0 or a CORPORATE that equals 0...considering that is in the current select as an OR...and it should be an OR?
  16. That did it...thanks a bunch!
  17. I have also added an index to the column game_id on games
  18. Thanks Pysco! Unknown column 'g.date' in 'where clause' Here's the echo of $query SELECT COUNT(g.game_id) FROM scheduled_umps AS u JOIN games AS g USING(game_id) WHERE u.ump_id = '34' AND g.date BETWEEN 2011-10-13 AND 2012-06-13 GROUP BY u.ump_id Oops...that column is called day...not date. Once I fixed that, it's returning 0 rows...
  19. The table 'games' contains the column game_id (which is PRIMARY, AI, INT). That table also contains column 'date' (which is DATE). Then on table scheduled_umps, there is a column 'game_id' (which is INT...but NOT an index). That table also contains column 'ump_id'. So, I need a select where games.game_id = scheduled_umps.game_id (game id from both tables matches) AND games.date falls between the given values, and the scheduled_umps.ump_id = $_SESSION[ump_id].
  20. I have two tables...one is scheduled_umps and one is games. Both tables have a column 'game_id'. I need to select how many games a person is scheduled for in a given time frame. Here's what I have for the select...and it's not working (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE scheduled_umps.ump_id = '34' AND games.game_id = scheduled_umps.game_id AN' at line 1) <?php $today_is_this_date = date('Y-m-d'); $four_months_ago = date('Y-m-d', strtotime('-4 months', strtotime($today_is_this_date))); $four_months_from_now = date('Y-m-d', strtotime('+4 months', strtotime($today_is_this_date))); /// How many games have you worked? //$query = "SELECT COUNT(ump_id) FROM scheduled_umps WHERE `ump_id` = '$_SESSION[ump_id]'"; ///this one selects how many games you've worked NO MATTER WHAT THE DATE $query = "SELECT scheduled_umps.game_id, games.game_id, COUNT(scheduled_umps.ump_id) WHERE scheduled_umps.ump_id = '$_SESSION[ump_id]' AND games.game_id = scheduled_umps.game_id AND games.game_id BETWEEN $four_months_ago AND $four_months_from_now"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "You have been scheduled on <b>". $row['COUNT(ump_id)'] ."</b> dates for the $_SESSION[association_name]."; } ?> [\code] Any ideas where I'm going wrong? Thanks for the help...I HATE multi-table selects!
  21. I got it... $sql = "SELECT * FROM podcasts WHERE `type` = 'podcast' AND recap LIKE '% Men\'s Hockey%' OR recap LIKE '% Mens Hockey%' ORDER BY date DESC";
  22. I'm trying to write a select to match a few certain words... $sql = "SELECT * FROM podcasts WHERE `type` = 'podcast' AND recap LIKE 'Men%' AND recap LIKE '%Hockey%' ORDER BY date DESC"; That's what I have so far...which isn't working... I need to match the string "Mens" OR "Men's" with the word "Hockey" BUT...I can't match "Women's" or "Womens" Any idea what I'm doing wrong? The above code only returns 6 results...when it should return nearly 100. Thanks!
  23. Thanks...that worked!
  24. I need to query a database for a starting time for a meeting, and if the start time is at 7pm, I need to allow access to a page from 6pm til 11pm. Not a problem. The problem lies when the ending time (4 hours after the start time) crosses over to a new day. Here's what I have: <?php elseif ($row['meeting'] == "7:00pm") { $starthour = 18; $endhour = 23; } elseif ($row['meeting'] == "8:00pm") { $starthour = 19; $endhour = 0; } if ($thishour <= $endhour && $thishour >= $starthour) { include "meeting_ok.php"; } else { echo "Meeting room is unavailable at this time...."; } ?> The "0" for endhour is throwing things off. How should I best account for a new day? Thanks!
  25. I need to rename several hundred mp3's in a directory. I've tried this php script...but it seems to have missed every file from 19 to 29 (119-129, 219-229, 319-329 etc). The original names are in no particular order or fashion in how they're named. What's my best choice to rename these files to song1.mp3, song2.mp3 song3.mp3 etc.? <?php $i = 1; foreach (glob("/xmas/*.mp3") as $filename) { copy ("$filename", "/newpopaudio/xmas$i.mp3"); $i++; } ?>
×
×
  • 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.