Jump to content

StevenOliver

Members
  • Content Count

    102
  • Joined

  • Last visited

  • Days Won

    1

StevenOliver last won the day on November 25 2018

StevenOliver had the most liked content!

Community Reputation

6 Neutral

About StevenOliver

  • Rank
    Advanced Member

Recent Profile Visitors

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

  1. mac_gyver, thank you! Your answer both answers my question and brings up some good points (e.g. whether a submit button may or may not be set, depending on the browser, etc.). Thank you again!!
  2. To execute code on successfully submitting text input, is this "bare minimum" code secure enough? if(!empty($_POST["textfield_input"])) { //execute code } ...or is it best to make sure all 4 of these are confirmed: if ( ($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST["submit_button_name"] && isset($_POST["form_name"] && (!empty($_POST["textfield_input"])) ) { //execute code } The html portion is simply: <form name="form_name" method="post" action="somepage.php"> <input type = "text" name="textfield_input"> <input type="submit" name="submit_ button_name"> </form> I've searched on the net about this several times, and see different answers, and it looks like each PHP expert has their favorite.... but I would rather know the "best practices" answer to this. Thank you!!
  3. OMG! Barand, you nailed it! (pardon the pun). That works "right out of the box!" (pardon yet another pun) What worries me is that I am realizing there was (and is) NO WAY I could ever have figured this out on my own. There's nothing on the 'net like this. I don't know how you know this stuff.... but you have my undying respect! THANK YOU!!
  4. SaranacLake, I'll have to get back to you. I am reading and appreciating Barand's most recent answer. Thank you.
  5. SaranacLake, actually, I am trying to accomplish this in real life. You also ask "what happens" if I have blue pliers with 25 sku numbers? All the more reason to have it all on one line: Pliers, blue, 2222, 1111, 8888, 9999, 3292, 2992 And, you're right, usually there is a better way to communicate things.
  6. SaranacLake, thank you, but I just did. Here is the real-life problem I want to solve (and I went ahead and used plain English): I have a mySQL table with items, descriptions, and sku numbers: Hammer, red, 5555 Pliers, blue, 2222 Pliers, blue, 1111 Pliers, blue, 8888 Goggles, yellow, 6666 I want the result to look like this, with similar items (in this case, the blue colored pliers) grouped as follows: Hammer, red, 5555 Pliers, blue, 2222, 1111, 8888 Goggles, yellow, 6666
  7. My fruit table example was too simplistic (oops), may I please ask from a different angle: I have a mySQL table with items, descriptions, and sku numbers: Hammer, red, 5555 Pliers, blue, 2222 Pliers, blue, 1111 Pliers, blue, 8888 Goggles, yellow, 6666 I want similar items (in this case, the blue colored pliers) grouped like this: Hammer, red, 5555 Pliers, blue, 2222, 1111, 8888 Goggles, yellow, 6666 After several 12 hour days, I cannot figure out how to do this.....
  8. This will be my worst-ever question posted on this forum 😀 But here goes.... I have a mySQL script which retrieves data.... then my PHP script creates a text document out of it, and ends with: $output = ob_get_contents(); ob_end_clean(); file_put_contents("document.txt", $output); The resultant thousand-item list will have some of the items duplicated, with one or more numerals appended, like this: banana 1 apple 1 apple 1 and 2 lemon 1 blueberry 1 strawberry 1 strawberry 1 and 2 strawberry 1 and 2 and 3 melon 1 When an item is duplicated and suffixed with more than one numeral, I want only the latest duplicated item, like this: banana apple 1 and 2 lemon 1 blueberry 1 strawberry 1 and 2 and 3 melon 1 Is there a way to make "file_put_contents" go like "oh, an item was listed more than once, let's only list the latest ("modified") item"?
  9. Perfect! I see it now. I ended up following your advice and created an fgetcsv PHP script (which only took me an hour, not the 2 days I anticipated :-) Now instead of the hassle of opening the file in excel, copy-and-pasting into text editor, creating a mySQL lookup, formatting the data to paste back into Excel, etc., all I have to do is open up SSH and type "php my_new_script.php" and voila.
  10. Barand: Thank you (I like the "Hands up" analogy) 😀 I cannot change the table structure (my table has 2 columns "fruit" and "color"), and your table doesn't have colors, and I tried but couldn't figure out how to modify your suggestions. Benanamen: Yes, I can explain. I have an excel spreadsheet, I select the entire "fruit" column, open my text editor and quickly create a mySQL query "Select fruit,color from mytable where fruit = 'apple' or fruit = 'banana' or fruit = 'orange'.... 1000 more fruits." Then I copy-and-paste the mySQL result into excel and I can see which ones match. They never match because every 10 fruits or so, one is missing from my mySQL table... I know I could take a full 2 days off and hack out some PHP code to take a .csv file, parse it for fruit names, create an array, create PHP/mySQL script, etc., I just hoped there would be a way for mySQL to at least do this via SSH command line result using an ifnull or coalesce or some mysterious acronym.... | grape | purple | | apple | 0 ERROR NOT HERE | | banana | yellow | | pomegranite | 0 ERROR NOT HERE |
  11. What is the most efficient way to return results in the same order as I used in my Select Statement, and return "0" if no record is found. Example: "SELECT fruit,color from table where fruit = 'grape' or fruit = 'apple' or fruit = 'banana' or fruit = 'pomegranite'; Current Result: | banana | yellow | | grape | purple | Desired Result: | grape | purple | | apple | 0 | | banana | yellow | | pomegranite | 0 | Thank you.
  12. No -- no warnings. I created the tables with both "primary key col2 (col2)" and "primary key (col2)" and there were no warnings. Then I tried the "alter table" syntax after dropping the primary keys: "alter table Table1 add primary key col2 (col2)" -and- "alter table Table1 add primary key (col2)" ... and neither of those gave any warnings. For all intents and purposes, they seem 100% identical. Perhaps in the olden days the "...primary key col2 (col2)" was how it used to be done, then it got deprecated and now "...primary key (col2)" is how it's done today, with both commands having the same effect. What are your thoughts?
  13. show index from Table1; +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table1 | 0 | PRIMARY | 1 | col2 | A | 0 | NULL | NULL | | BTREE | | | +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 1 row in set (0.007 sec) show index from Table2; +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table2 | 0 | PRIMARY | 1 | col2 | A | 0 | NULL | NULL | | BTREE | | | +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 1 row in set (0.007 sec)
  14. I did -- I did "show index from Table1" and the result was identical to "show index from Table2."
  15. Hmm... I did that, the results are absolutely identical. I created the tables like this: Create table Table1( col1 varchar(3), col2 varchar(3), primary key col2 (col2) ); Create table Table2( col1 varchar(3), col2 varchar(3), primary key (col2) ); What would you think I should be seeing that I'm missing?
×
×
  • 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.