Verbat Posted February 24, 2008 Share Posted February 24, 2008 I read info from a database where something = 0. Then i display it in a table with a form to submit, my problem is how do i do that when i click the submit button it will save different info in the table at the same time?! Quote Link to comment Share on other sites More sharing options...
Daney11 Posted February 24, 2008 Share Posted February 24, 2008 Post some code please. Quote Link to comment Share on other sites More sharing options...
Verbat Posted February 24, 2008 Author Share Posted February 24, 2008 echo "<br><br> <form method=post action=edit_distance_go.php> <table align='center' cellpadding='0' cellspacing='1' width='95%' class='tbl-border'> <tr><td colspan='6' class=tbl2><div align=left><img src=./images/planes/tlogo.png></td></tr> <tr> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>Start</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>End</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>Distance</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>Start City</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>End City</b></font></td> </tr> "; $query12 = sprintf("SELECT * from distance WHERE distance='0' LIMIT 10",$db_connect); $result12 = dbquery($query12); while ($roqww = mysql_fetch_assoc($result12) ) { $start = $roqww['start']; $end = $roqww['end']; $distance = $roqww['distance']; $scity = $roqww['scity']; $ecity = $roqww['ecity']; $idd = $roqww['id']; echo " <tr> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>$start</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>$end</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935><input type='text' name='distance' size='15' class='textbox' maxlength=15></b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>$scity</b></font></td> <td class=tbl2 width='20%'><b><font size=1 color=#3A3935>$ecity</b></font></td> </tr> "; } echo " <tr> <td class=tbl1 colspan='5'><br></td> </tr> <tr><td colspan='5' align=center class=tbl2><input type=submit value='Edit' class='button' align=center></td></tr> </table><br><br>"; Now i want the input of distance to change all the 10 rows at the same time by clicking 1 button. Quote Link to comment Share on other sites More sharing options...
Verbat Posted February 24, 2008 Author Share Posted February 24, 2008 Anyone please? Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 24, 2008 Share Posted February 24, 2008 not entirely sure what you mean but I suspect you are looking in the wrong forum. Try javascript. Quote Link to comment Share on other sites More sharing options...
Verbat Posted February 24, 2008 Author Share Posted February 24, 2008 What i mean is, for example when you edit a table in the SQL DB you can pick several rows to edit and then click OK and it will save everything at once. I want to do the same with the PHP code. Quote Link to comment Share on other sites More sharing options...
timmy0320 Posted February 24, 2008 Share Posted February 24, 2008 What i mean is, for example when you edit a table in the SQL DB you can pick several rows to edit and then click OK and it will save everything at once. I want to do the same with the PHP code. Google. I doubt anyone here is going to just make your code for you. http://www.roscripts.com/PHP_MySQL_by_examples-193.html Quote Link to comment Share on other sites More sharing options...
Verbat Posted February 24, 2008 Author Share Posted February 24, 2008 Of course not make the script for me but just explain alittle. Quote Link to comment Share on other sites More sharing options...
timmy0320 Posted February 24, 2008 Share Posted February 24, 2008 Of course not make the script for me but just explain alittle. To display the rows would be something like: $query = "SELECT * FROM table WHERE row = $row"; //or whatever SQL you want to use $result = @mysql_query($query,$db_connection) or die(); if (mysql_num_rows($result) < 1 ) { // no records found for query } else { while( $row = mysql_fetch_array($result) ) { //put output code here // you could do INPUT codes here for a form using $row['distance'] (or whatever part you want to select) as an array } } Then to update it would be something like: for($i=0; $i<$count; $i++) { $query1="UPDATE table SET distance ='$row[$i]' WHERE whatever = '$whatever[$i]' "; $result1 = @mysql_query($query1, $db_connection); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.