Jump to content

MYSQL to enter multiple data at once


deaglex

Recommended Posts

I am stuck >:(!!

I want to be able to run the

while

and take the 'number' field to correlate with the points in that row of the table to UPDATE the database with the corresponding record.

 

 

<?php 


require_once 'dblogin.php';

$result = mysql_query("SELECT * FROM drivers");

if (!isset($_POST['submit']))	{


		echo "<table class=\"sortable\" align='center' preserve_style=\"cell\" border='0' width='100%'>
		<tr bgcolor=\"fff978\">
		<th>Car:</th>
		<th>Driver:</th>
		<th>Points:</th>
		</tr><form action\"" . $_SERVER['PHP_SELF']  .	 "\" method=\"post\">";

		$color1=1;
		while($row = mysql_fetch_array($result))
  		{
  			
  			if ($color==1){
  				  
//Change color of rows
  			echo "<tr bgcolor=\"ffee55\">";
			echo "<td align=\"center\">" . '#' . $row['number'] . "</td>";
  			echo "<td>" . $row['first_name'] . ' ' . $row['last_name'] . "</td>";
  			echo "<td align=\"center\">". $row['points'] . "</td>";
  			echo "<td><input type=\"text\" name= \"" .  $row['number'] . "\" size=\"3\" maxlength=\"3\"/></td>";
  			echo "</tr>";
  			
  			$color=2;
  			}  		
		else {
			echo "<tr bgcolor=\"cccccc\">";
			echo "<td align=\"center\">" . '#' . $row['number'] . "</td>";
  			echo "<td>" . $row['first_name'] . ' ' . $row['last_name'] . "</td>";
  			echo "<td align=\"center\">" . $row['points'] . "</td>";
  			echo "<td><input type=\"text\" name= \"" .  $row['number'] . "\" size=\"3\" maxlength=\"3\"/></td>";
  			echo "</tr>";
		$color=1;
		}

  		}
  		echo "</table> <input type=\"submit\" name=\"submit\" value=\"\Submit\"/></form>";
}
?>

 

 

Any help would be greatly appreciated.

 

Thanx

Link to comment
https://forums.phpfreaks.com/topic/140568-mysql-to-enter-multiple-data-at-once/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.