Jump to content

bschultz

Members
  • Posts

    486
  • Joined

  • Last visited

Everything posted by bschultz

  1. Metaphone didn't work for the examples I listed...but Levenshtein-Distance did. There I go again...learning something new! Thanks!
  2. I need to write a select statement where Jo. Doe Doe, Jo Doe John will ALL match John Doe... and where Ja. Doe Doe, Ja Doe Jane will ALL match Jane Doe. So, Initials and full last name are given...is this possible? I've only worked with LIKE...and that didnt' work. Is there another function I'm not aware of?
  3. Step two of this project requires building the html form (dynamically) based on what the user has already selected. I thought there was a way to do this in php, but my searching on Google lead me to jquery and ajax (of which I know neither of them!). I want to have an array of options for a form select box. Once the user selects the first select box, a second select box shows up with every option EXCEPT WHAT WAS SELECTED IN THE FIRST BOX...and repeats it's self until the array is empty (every array item has been selected). Can this be done in PHP? This is what I have so far...which does work...but it's only 2 select boxes...of 20! I can only hope it can done simpler than this: <?php $fields = array('Number', 'Name', 'Picture', 'Position', 'Height', 'Weight', 'Year', 'Home', 'Last School'); $submitted = array("$_POST[column1]", "$_POST[column2]", "$_POST[column3]", "$_POST[column4]", "$_POST[column5]", "$_POST[column6]", "$_POST[column7]", "$_POST[column8]", "$_POST[column9]", "$_POST[column10]"); ?> <form name="form1" method="post" action=""> Column 1 - <label> <select name="column1" id="column1"> <option value="">Select The Value of Column 1</option> <?php foreach ($fields as $field) { echo "<option value='$field'"; if ($_POST['column1'] == $field) { echo " selected"; } echo ">$field</option>\n"; } ?> </select> </label><br> <br> <?php if (isset($_POST['column1'])) { echo 'Column 2 - <select name="column2" id="column2">'; $column_array[] = $_POST['column1']; $array_diff = array_diff($fields,$column_array); if (isset($_POST['column2'])) { echo "$_POST[column1]"; } else { foreach ($array_diff as $fields) { echo "<option value='$fields'"; if ($_POST['column2'] == $fields) { echo " selected"; } echo ">$fields</option>\n"; } } } echo "</select>"; ?> <br /><br /> <label> <input type="submit" name="button" id="button" value="Submit"> </label> </form>
  4. That's what I'm looking for...thanks for the quick reply!
  5. Is there a function to determine which $_POST variable = foo? I have a form with 20 elements...and need to know which one equals another variable that's set in the script...and don't want to write a 400 layer deep if statement. Thanks!
  6. 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 />"; } } ?>
  7. 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.
  8. 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
  9. 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!
  10. got it... $slashes_title = stripslashes($row['headline']); $title = mysql_real_escape_string($slashes_title); $stripslashes= stripslashes($row['story']);; $story = mysql_real_escape_string($stripslashes);
  11. 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!
  12. thanks...was trying to do this in one step...but that will work.
  13. 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?
  14. 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:
  15. 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.
  16. 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!
  17. 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?
  18. 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!
  19. 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!
  20. 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?
  21. I have also added an index to the column game_id on games
  22. 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...
  23. 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].
  24. 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!
×
×
  • 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.