Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Lee_K

Members
  • Joined

  • Last visited

  1. I've just noticed a problem that I think someone could help me with. Basically what I've got is: $var = "celebrity"; $line = str_replace("'", "\'", $line); $line[9] = strtolower($line[9]); if (strpos($line[9], $var)){ But I've noticed that if celebrity is the first word on a line, then it's not included. Why's that?! [EDIT]: I've just used all my wisdom and changed it to this which seems to work: $var = "celebrity"; $line = str_replace("'", "\'", $line); $line[9] = strtolower($line[9]); if (strpos($line[9], $var) !== FALSE){ I know it's working, but is that the correct way of doing it? Could someone explain why? Also, in the examples below, which would be correct? if (strpos($line[20], $var1) !== FALSE || strpos($line[20], $var2) !== FALSE){ Or this one: if (strpos($line[20], $var1) || strpos($line[20], $var2) !== FALSE){ I'm thinking it's probably the first of the two?
  2. I had a feeling that might be the case, just wanted to double check!
  3.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  4. 1 more question! When I'm in phpMyAdmin and displaying all the rows, I've noticed that it will say something like: Showing rows 0 - 109 (110 total, Query took 0.0692 sec) But where is the 110th row? Why does it always seem to be 1 short?!
  5.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  6. Thanks for all the help! It's been much appreciated! I'll definitely look into PDO at a later date. Just glad to get this working for now. Can I just ask, where did you learn this stuff? Did you study it in Uni or just pick it up yourself? What sort of qualifications are available for this kind of thing?
  7.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  8. I've pretty much got this working now I think! I've done it differently though, instead of using PDO I've just used the usual MySQL connect. What's the difference here? Does it really matter? I'm also having a small problem with apostrophe's ( ' ) within the CSV file conflicting on input. Much appreciated for all the help with this though! It turned out to be a lot more complicated than I had thought, It's not something I could of done entirely on my own, not until I understand a bit more about PHP.
  9. Not really! I've basically used this code to display the output in the browser, it was just to get me started: $file = fopen('CSV/newfile.csv', 'r'); while (($line = fgetcsv($file)) !== FALSE) { //$line is an array of the csv elements $var1 = "name"; $var2 = "address"; $line[20] = strtolower($line[20]); if (strpos($line[20], $var1) || strpos($line[20], $var2)) { echo '<pre>'; print_r($line[0]); echo "<br />"; print_r($line[7]); echo '<br />'; print_r($line[4]); echo '<br />'; print_r($line[14]); echo '<br />'; print_r($line[36]); echo '<br />'; print_r($line[39]); echo '</pre>'; } } fclose($file); Everything displays how I want it to in the browser. But I don't really know where to go from here to insert each line into the right columns of my database. I tried the first bit of code, using PDO but I don't understand the $connectionString part. From what I read on Google it should be like: $pdo = new PDO('mysql:host=localhost;dbname=mydbname', 'myusername', 'mypassword');
  10.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  11.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  12.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  13. That helps a lot, but how would I include another variable? Something like: $var1 = "Find this"; $var2 = "Find that"; Or $var = "Find this" or "Find that" ; So that I could get a result if either of them are in the string? Also is there a way to make the variable so that it isn't case sensitive?
  14. It's been a long process for a beginner but I'm definitely getting somewhere though! Can someone tell me if I can use wildcards like this? if ($line[20] == '%xyz%' I can get it to print the line if I use the exact phrase, but is there anyway I could just use part of the phrase inside of 2 of those, like '%xyz%'.
  15.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  16. Wow thanks! There's plenty here to get me going in the right direction! Much appreciated guys! I'm going to check it all out properly tonight!
  17. Ok so I basically turn each row of my CSV file into an array using the code above and then have to insert each requested row that into the database using PDO?
  18.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  19. Could anyone give me some help with this? I've literally sat and scratched my head all day trying to work it out! I came across the following code: $csv = explode("\n", file_get_contents('test.csv')); foreach ($csv as $key => $line) { $csv[$key] = str_getcsv($line); } Which I believe turns my CSV file into an array? But then how do I go about using it to delete specific rows where their not like "xyz" and then convert it back into a CSV file for uploading to database?!
  20.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  21.    Lee_K reacted to a post in a topic: LOAD DATA LOCAL INFILE WHERE clause?
  22. Is that the only way it can be done?
  23. 126 views and no replies tells me this can't be done then! Haha. What about using PHP to remove rows from the CSV file or extracting the rows I need and putting them into another CSV file before loading them into MySQL. Would that be possible?
  24. Is this possible? I've basically got a cronjob script that inputs data from a CSV file into my database. Everything works fine except one of my CSV files has a lot of data that I don't need. I don't want to import all of it as it's just taking up resources. Is it possible to use something like this: "LOAD DATA LOCAL INFILE 'CSV/Filename.csv' INTO TABLE `TABLE 3` WHERE `colu` LIKE '%xyz%' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\\\' IGNORE 1 LINES (name, date);" `colu` being column U in the CSV file?
  25. Lee_K replied to Lee_K's topic in Server Side
    Thanks man! That's done the job perfectly! I would never of been able to get that right and was having no luck with Google either! Very much appreciated!

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.