Jump to content

Jim R

Members
  • Content Count

    852
  • Joined

  • Last visited

  • Days Won

    1

Jim R last won the day on July 26 2018

Jim R had the most liked content!

Community Reputation

1 Neutral

About Jim R

  • Rank
    Prolific Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I changed the TYPE for feet and inches to VARCHAR. I think helped some, but it's also preceding the number with quotation marks. I opened the file in a text editor, and those fields are wrapped with " ". So in position = "PG" @height = "6'4"" <= extra set of double quotes at the end So I'd need to reshape the delimiters. For inches, we have: inches = substring_index(substring_index(@height, '\"', 1), '\'', -1) Would that be a 2 in this instance?
  2. I increased the field lengths for position, feet and inches. Still getting 0's in feet and inches, but position looks like this now... So it's showing the whole position, but where the were multiple positions listed (I just want their primary position), it shows the quotation marks on the left.
  3. Keep what a secret? Here is the file. I forgot to add it. I deleted the columns I'm not using. Here is what it looks like after loaded into the database: Database structure:
  4. Ooops...I've been taking them out as I've posted them because I'm skipping over them in the CSV. Skipping @email, @cell, @role, @video, @weight It's lined up fine, other than the substrings not producing
  5. Interesting too (at least to me), I changed position to @position then added this line: position = substring_index(@position, ',', 1), It should produce entries like PG, SG, SF. Instead, it's producing "P, "S, "S, whereas the rows w/o the , in position produce what's intended.
  6. Disregard the previous post. I had misaligned columns. However, it's still showing 0 in feet and inches... ...with the current query $query = " LOAD DATA LOCAL INFILE '$tmp' INTO TABLE a_rosters FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 Lines (grade,uniform,nameFirst,nameLast,position,@height) SET team = '" .$team . "', level = '" .$level. "', feet = substring_index(@height, '\'', 1), inches = substring_index(substring_index(@height, '\"', 1), '\'', -1) ";
  7. It didn't added the feet or inches columns in the database. They just show up as 0.
  8. Yep...changing it to a CSV file worked. Is there an easy to handle an xlsx file, or will I need to have my Users (coaches) export to CSV? (Not sure what they're exporting from does that just yet. My test User is checking.) It would be easier for my users if I could handle an xlsx file. (I'll search for that after I hit submit.) EDIT: The answer seems to be that I will need to convert it to a CSV file. Agree?
  9. Current code: $filename = $_FILES['fileToUpload']['name']; $tmp = $_FILES["fileToUpload"]["tmp_name"]; $team = $_POST['team']; if(isset($_POST["submit"])) { echo $target_file . '<br>Roster Sent'; echo '<br>' .$filename; echo '<br>' .$tmp; $uploadOk = 0; } $query = " LOAD DATA LOCAL INFILE '$tmp' INTO TABLE a_rosters FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 Lines (uniform,nameFirst,nameLast,position,@feet,@inches) SET team = '" .$team . "', feet = substring_index(@feet, '\'', 1) * 12 ,
  10. I see your EDIT above. I omitted the second substring_index of line 30. I copied what you wrote above, changing @height to @feet and @inches. Still throwing this error: Parse error: syntax error, unexpected '', 1), '' (T_CONSTANT_ENCAPSED_STRING) in /home2/csi/public_html/wp-content/plugins/csi_stats/csi_roster_upload_process.php on line 30 $query = " LOAD DATA LOCAL INFILE '$tmp' INTO TABLE a_rosters FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 Lines (uniform,nameFirst,nameLast,@email,@cell,position,@role,@video,@feet,@inch
  11. First I was getting this error: So I added a \ before the " include("/pathway/to/con.php"); $filename = $_FILES['fileToUpload']['name']; $tmp = $_FILES["fileToUpload"]["tmp_name"]; $team = $_POST['team']; if(isset($_POST["submit"])) { echo $target_file . '<br>Roster Sent'; echo '<br>' .$filename; echo '<br>' .$tmp; $uploadOk = 0; } $query = " LOAD DATA LOCAL INFILE '$tmp' INTO TABLE a_rosters FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 Lines (uniform,nameFirst,nameLast,position,@feet,@i
  12. SET feet = substring_index(@feet, '\'', 1), inches = substring_index(@inches, '"', 1), '\'', -1) Trying that when I get back to my desk.
  13. Can't I also set the substring_index to find @feet then @inches? SET feet = substring_index(@feet, '\'', 1) SET inches = substring_index(@inches, '"', 1), '\'', -1)
  14. Height isn't roster dependent, and most of the players that will be entered by the coaches will not be in the database, so we'll need to include their height regardless. I have key indexes set up not to allow duplicates. Height will be imported here as #'#", but the my database is set up in two columns, feet and inches for over 800 rows. It's also easier for me to create exports for others with different formats, most notably those who want exports in #-# as is common in the US. I know how to get data out how I need it. (At least as it's currently situated.) I've just com
  15. I've been asked to allow coaches to upload rosters exported from another source. So I'll be allowing them to upload CSV files. The players' height will be exported as (US measurements) a single column, e.g. 6'4", but I need to have it be two separate columns -- feet and inches. Trying to make it as easy on the coaches as possible, so I'd rather not force them to reformat their file. (Because many won't.) Here is the query I'm currently working with. It works quite well for my test data, but with feet and inches as separate columns. LOAD DATA LOCAL INFILE '$tmp'
×
×
  • 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.