Jump to content

Th3Boss

Members
  • Posts

    33
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Th3Boss's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok got this all working. Thanks a lot everyone who helped.
  2. Yeah that fixed the errors. echo $query looks like this: INSERT INTO Table2 (`ID`,`Name`) VALUES ('50', 'Name1'), ('50', 'Name2'), ('50', 'Name3') Though it doesnt insert it into the table. It does insert the 50 into Table1 though from. $query = "INSERT INTO table1 (ID) VALUES (NULL)";
  3. Warning: array_filter() expects parameter 1 to be array, string given in on line 60 $textLines = array_filter('trim', $textLines); Warning: array_filter() expects parameter 1 to be array, string given on line 62 $textLines = array_filter('mysql_real_escape_string', $textLines); Warning: Invalid argument supplied for foreach() on line 71 foreach($textLines as $line) And should field1 be a new column for the parent record or should that be the auto increment ID from table 1? Like: //Create parent record in table 1 $query = "INSERT INTO table1 (ID) VALUES (NULL)"; $result = mysql_query($query) or die(mysql_error()); $table1ID = mysql_insert_id();
  4. oh I just noticed I have that wrong. The ID needs to be the same as the ID from another table that is auto increment, the structure is this. It inserts the ID row # for Table 1 as auto increment and then inserts the ID from Table 1 into Table 2 with the data from the textarea. From Textarea: Info1 Info2 Info3 Info4 Info5 Table 1: ID 1 2 3 4 Into Table2: ID | Name 4 | Info1 4 | Info2 4 | Info3 4 | Info4 4 | Info5
  5. What do you mean normalize the data? the structure I want is this From Textarea: Info1 Info2 Info3 Info4 Info5 Into Table: ID | Name 1 | Info1 1 | Info2 1 | Info3 1 | Info4 1 | Info5
  6. Well I replied to an old thread but as it is old it doesnt seem to be getting any activity as it is marked answered. The thread is: http://forums.phpfreaks.com/topic/228584-insert-different-lines-from-textarea-to-different-mysql-rows/ This doesnt work. I have tried it so many different ways. I have a textarea that has data like Info1 Info2 Info3 Info4 Info5 I have a table that has an auto increment ID and a Name column and I want each line from the textarea in its own row inserted in the Name column. The only reply to the thread says to try: $lines = array_map('mysql_real_escape_string', explode("\n", $_POST['textarea'])); $values = "VALUES ('" . implode("'), ('", $lines) . "')"; $query = "INSERT INTO table_name (column_name) $values"; Which didnt work. Ive tried a bunch of different things and cant get this to work. Here is my last attempt of trying to get the above to work: $lines = array_map('mysql_real_escape_string', explode("\n", $_POST['TextArea'])); $values = implode("'), ('", $lines); $query = "INSERT INTO Table (`ID`,`Name`) VALUES (NULL, '$values')";
  7. This doesnt work. I have tried it so many different ways. I have a textarea that has data like Info1 Info2 Info3 Info4 Info5 I have a table that has an auto increment ID and a Name column and I want each line from the textarea in its own row inserted in the Name column. I tried like posted above and so many other ways. Here is my last attempt. $lines = array_map('mysql_real_escape_string', explode("\n", $_POST['TextArea'])); $values = implode("'), ('", $lines); $query = "INSERT INTO Table (`ID`,`Name`) VALUES (NULL, '$values')";
  8. after lots or searching and reading I finally figured it out. http://stackoverflow.com/questions/10371502/storing-multiple-rows-from-mysql-in-separate-variables
  9. Can you do an example of how I can do this with arrays?
  10. Right now in the query it selects all of that data i need from the database and now I need to set all of that data as the correct variables.
  11. Pretty sure im doing this completely wrong. while($row = mysql_fetch_array($result)){ if($row['slot'] == 'high') { $i=1; while($i<= { $name[$i] .= $row['name']."" ; $typeID[$i] .= $row['typeID']."" ; $i++; } } else { } } There will always be 0 to 8 items that are 'high' in the database $row['slot']. I want all of the 'name' and 'typeID' to be as: $name1 $typeID1 $name2 $typeID2 $name3 $typeID3 and so on up to how ever many there is, but no more than 8 How do I do something like this? (Sorry if that is a terrible explanation)
  12. I keep getting #1054 - Unknown column 'drone' in 'field list' but dont see whats wrong with it. Anyone see whats wrong? http://pastebin.com/qzuMJC4s
×
×
  • 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.