Schlo_50 Posted November 13, 2007 Share Posted November 13, 2007 I have a list which is pulled and displayed from my MS Access database. Next to each row, is a text field which appears evertime a new row is displayed and that is called 'code'. I want any text field filled in by the user to be sent into my database, into one field all separated by commas. I have made an attempt at this in the second example script but it needs tweaking. I have here my script which pulls the list from my database: <?php $sql2 = odbc_exec($odbc, "SELECT * FROM Product1 ORDER BY CategoryName") or die (odbc_errormsg()); $prevCat=''; while($row = odbc_fetch_array($sql2)) { $Category = $row["CategoryName"]; $ProductId = $row["ProductId"]; $ProductName = $row["ProductName"]; $Price = $row["Price"]; // has category changed // if so, print it if ($Category != $prevCat) { echo "<h2>$Category</h2>"; } echo 'Item Code: ', $ProductId, '<br/>Item Name: ', $ProductName, '<br/><br/>Price: £', $Price, '<input name="code" type="text" size="2" /> <input name="quan" type="text" size="5" /><br/><br/>'; $prevCat = $Category; } ?> This is the code i have to send all of the inputted data in 'code' to my database, which unfortunately doesn't upload the user input corectly. <?php if ($_POST[submit] == "Submit") { //Collect form data, having problems here! $code = substr($_POST['code'],0); $codeb = substr($_POST['code'],0); $code = "$code,$codeb"; //SQL Statement $conn = odbc_connect('DB', 'root', '') or die('Could not Connect to ODBC Database!'); $sql = "INSERT INTO Order1 " . "(ProductNotes) VALUES ('$code')"; //Execute SQL Statement and store results as a recordset $rs = @odbc_exec($conn,$sql); if (!$rs) { echo "An error has occured. Please try again"; } else { echo "The record was successfully inserted."; } odbc_close($conn); } ?> Thanks in advance guys Link to comment https://forums.phpfreaks.com/topic/77132-_post-identical-text-fields-into-database/ Share on other sites More sharing options...
Schlo_50 Posted November 13, 2007 Author Share Posted November 13, 2007 bump Link to comment https://forums.phpfreaks.com/topic/77132-_post-identical-text-fields-into-database/#findComment-390613 Share on other sites More sharing options...
atlanta Posted November 13, 2007 Share Posted November 13, 2007 Are you getting any errors.?? Link to comment https://forums.phpfreaks.com/topic/77132-_post-identical-text-fields-into-database/#findComment-390624 Share on other sites More sharing options...
Schlo_50 Posted November 13, 2007 Author Share Posted November 13, 2007 No, but the format of the user input being sent into my database is incorect. If a user enters 12, 15 and 29 into the text fields i want those numbers to be entered into my database. All in one field separated by commas. Link to comment https://forums.phpfreaks.com/topic/77132-_post-identical-text-fields-into-database/#findComment-390627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.