CodyBecker Posted December 1, 2009 Share Posted December 1, 2009 I have a query [ $result = mysql_query("SELECT * FROM people WHERE status = '0' AND POST = '$post' ORDER BY lname ASC"); ] and i want to be able to insert into a separate table a value for each person. So basically i want to be able to open this page and see a list of all people in the database with a box next to it to add the value. - - - - - - - - - - [Month] [Name] - [input box value] [Name] - [input box value] [Name] - [input box value] [Name] - [input box value] [submit] - - - - - - - - - - So that when it adds to the other table the data will go in like this..... month, name, value month, name, value Hope i explained this in a way everybody can understand. Thanks Link to comment https://forums.phpfreaks.com/topic/183529-please-help/ Share on other sites More sharing options...
monkeytooth Posted December 1, 2009 Share Posted December 1, 2009 First, I would say just add another column rather than a whole new table. Just more work for you later if the tables that small already. Then simply in concept atleast (im not testing as I go). But //database information user, pass, db, server.. $sq_hst = "localhost"; $sq_unme = "database_username"; $sq_pzwrd = "database_passworkd"; $database = "database_name"; //dont edit below $dbconnReg = mysql_connect($sq_hst, $sq_unme, $sq_pzwrd) or die('Transaction failed. DB connection not made.'); mysql_select_db($database) or die('Transaction failed. Wrong Database Name'); //edit this line as needed to match query needs $display_query = " SELECT * FROM people WHERE status='0' AND POST='$post' ORDER BY lname ASC"; //dont edit below $display_result = mysql_query($display_query) or die('Transaction failed. ' . mysql_error()); echo "<form method=\"post\" name=\"peoples\" action=\"".$_SERVER['PHP_SELF']."\">"; while($people = mysql_fetch_array($display_result)) { //edit here for outputs echo $people['column_month'] . $people['column_names'] . "<input type=\"text\" name=\"".$people['column_names']."\" value=\"\"><br />"; //no more editing } mysql_close(); echo "<input type=\"submit\" name=\"newValues\" value=\"Change Info\"><br />"; echo "</form>"; to submit the form and have it update things accordingly, that may be a bit trickier, however insead of naming the form input names as the people like I did, maybe it would be easier to build them to form an array later when you submit them then use the array and a foreach loop to take the post data and put it in the database.. Link to comment https://forums.phpfreaks.com/topic/183529-please-help/#findComment-968741 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.