Azul(Hi)

i created program on php where i can output data set of any table by submitting query.
i need help to input i mean to load data into the table from the HTML file
can any one give help please
thank you.

this is the program i created, so far it work just for retrevie the information only i am looking to add from HTML

there 6 tables: clients, departments, projects, jobs, manages employees

<?php
if (isset($_POST['door']) )
	{
	$door=$_POST['door'];
		
		if(($door=="clients")||($door=="Clients")||($door=="departments")||($door=="Departements")||($door=="employees")||($door=="Employees")||($door=="jobs")||($door=="Jobs")||($door=="manages")||($door=="Manages")||($door=="projects")||($door=="Projects"))
		{
			
			
		if(($door =="clients")||($door =="Clients"))

		{
			echo"you requested table Clients";
			
			echo"we will try connect to the db<br/>\n";

			$barak=mysql_connect("127.0.0.1","root","agouni2008");



				if (!$barak)
		
				{
					die("Fatal Error<br>".mysql_errno()."<br/>".mysql_error() );
				};


				echo "you are connect successfully to MYSQL <br/><br/>";

				mysql_query("use dodgy");



				if(mysql_errno() != 0)
		
				{
					die("can't change databse");
				};



				echo "Dtabase changed successfully! <br/>\n" ;


			$table = mysql_query("SELECT * FROM clients");





			echo "<table border='10'>\n";
			echo"   <tr>
				<tr bgcolor='red'>
				<th>code</th>
				<th>name</th>
				<th>adress</th>
				<th>telephone</th>
				<tr>";




			while($info=mysql_fetch_array($table,MYSQL_ASSOC))
			{
			
			echo 		"<tr> 
					<tr bgcolor='yellow'>
					<td bgcolor='blue'><b>".$info['Clie_ID']."<b/></td>".
					"<td>".$info['Clie_name']."</td>".
					"<td>".$info['Clie_adress']."</td>".
					"<td><a href='mailto:{$info['Clie_phone']}'>".$info['Clie_phone']."</a></td>
					</tr>\n";
					 
			};

			echo "</table>\n";
			//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		
		}//closing if of clienttable
		else//not clients
			{
		
			//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@testing if it is  DEPARTMENTS@@@@@@@@@@@@@@@@
					if(($door =="departments")||($door =="Dpartments"))

					{
					echo"you requested table Departments ";
			
					echo"we will try connect to the db<br/>\n";

					$barak=mysql_connect("127.0.0.1","root","agouni2008");



					if (!$barak)
		
					{
						die("Fatal Error<br>".mysql_errno()."<br/>".mysql_error() );
					};


					echo "you are connect successfully to MYSQL <br/><br/>";

					mysql_query("use dodgy");


			
					if(mysql_errno() != 0)
		
					{
						die("can't change databse");
					};



					echo "Dtabase changed successfully! <br/>\n" ;


					$table = mysql_query("SELECT * FROM departments");





					echo "<table border='10'>\n";
					echo"   <tr>
						<tr bgcolor='red'>
						<th>code</th>
						<th>name</th>
						<th>adress</th>
						<tr>";




					while($info=mysql_fetch_array($table,MYSQL_ASSOC))
					{
				
					echo 		"<tr> 
							<tr bgcolor='yellow'>
							<td bgcolor='blue'><b>".$info['Dep_cod']."<b/></td>".
						"<td>".$info['Dep_name']."</td>".
						"<td>".$info['Dep_adress']."</td>
						</tr>\n";
						 
					};

					echo "</table>\n";
			
		
					}//closing if of departments
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@testing if it is employes@@@@@@@@@@@@@@@@@@@@@
					if(($door =="employees")||($door =="Employees"))

					{
					echo"you requested table Employees ";
			
					echo"we will try connect to the db<br/>\n";

					$barak=mysql_connect("127.0.0.1","root","agouni2008");



					if (!$barak)
		
					{
						die("Fatal Error<br>".mysql_errno()."<br/>".mysql_error() );
					};


					echo "you are connect successfully to MYSQL <br/><br/>";

					mysql_query("use dodgy");


			
					if(mysql_errno() != 0)
		
					{
						die("can't change databse");
					};



					echo "Dtabase changed successfully! <br/>\n" ;


					$table = mysql_query("SELECT * FROM employees");





					echo "<table border='10'>\n";
					echo"   <tr>
						<tr bgcolor='red'>
						<th>Id</th>
						<th>name</th>
						<th>DOB</th>
						<th>Address</th>
						<th>Department code</th>
						<tr>";




					while($info=mysql_fetch_array($table,MYSQL_ASSOC))
					{
				
					echo 		"<tr> 
							<tr bgcolor='yellow'>
							<td bgcolor='blue'><b>".$info['Emp_id']."<b/></td>".
						"<td>".$info['Emp_name']."</td>".
						"<td>".$info['Emp_dob']."</td>".
						"<td>".$info['Emp_adress']."</td>".
						"<td>".$info['Dep_cod']."</td>
						</tr>\n";
						 
					};

					echo "</table>\n";
			
		
					}//closing if of empolyees
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@testing if it is jobs@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
					if(($door =="jobs")||($door =="Jobs"))

					{
					echo"you requested table Jobs ";
			
					echo"we will try connect to the db<br/>\n";

					$barak=mysql_connect("127.0.0.1","root","agouni2008");



					if (!$barak)
		
					{
						die("Fatal Error<br>".mysql_errno()."<br/>".mysql_error() );
					};


					echo "you are connect successfully to MYSQL <br/><br/>";

					mysql_query("use dodgy");


			
					if(mysql_errno() != 0)
		
					{
						die("can't change databse");
					};



					echo "Dtabase changed successfully! <br/>\n" ;


					$table = mysql_query("SELECT * FROM jobs");


					echo "<table border='10'>\n";
					echo"   <tr>
						<tr bgcolor='red'>
						<th>Employees Id</th>
						<th>Projects number</th>
						<th>Working Dtae</th>
						<tr>";




					while($info=mysql_fetch_array($table,MYSQL_ASSOC))
					{
				
					echo 		"<tr> 
							<tr bgcolor='yellow'>
							<td bgcolor='blue'><b>".$info['Emp_id']."<b/></td>".
						"<td>".$info['Proj_num']."</td>".
						"<td>".$info['Date_work']."</td>
						</tr>\n";
						 
					};

					echo "</table>\n";
			
		
					}//closing if of jobs
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ testing if it is table manages@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
					if(($door =="manages")||($door =="Manages"))

					{
					echo"you requested table Manages ";
			
					echo"we will try connect to the db<br/>\n";

					$barak=mysql_connect("127.0.0.1","root","agouni2008");



					if (!$barak)
		
					{
						die("Fatal Error<br>".mysql_errno()."<br/>".mysql_error() );
					};


					echo "you are connect successfully to MYSQL <br/><br/>";

					mysql_query("use dodgy");


			
					if(mysql_errno() != 0)
		
					{
						die("can't change databse");
					};



					echo "Dtabase changed successfully! <br/>\n" ;


					$table = mysql_query("SELECT * FROM manages");


					echo "<table border='10'>\n";
					echo"   <tr>
						<tr bgcolor='red'>
						<th>Departments code</th>
						<th>Projects number</th>
						<tr>";




					while($info=mysql_fetch_array($table,MYSQL_ASSOC))
					{
				
					echo 		"<tr> 
							<tr bgcolor='yellow'>
							<td bgcolor='blue'><b>".$info['Dep_cod']."<b/></td>".
							"<td>".$info['Proj_num']."</td>
							</tr>\n";
						 
					};

					echo "</table>\n";
			
		
					}//closing if of manages
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@testing if it is table projects@@@@@@@@@@@@@@@@@@@@@@@@@@@@
					if(($door =="projects")||($door =="Projectss"))

					{
					echo"you requested table Projectss ";
			
					echo"we will try connect to the db<br/>\n";

					$barak=mysql_connect("127.0.0.1","root","agouni2008");



					if (!$barak)
		
					{
						die("Fatal Error<br>".mysql_errno()."<br/>".mysql_error() );
					};


					echo "you are connect successfully to MYSQL <br/><br/>";

					mysql_query("use dodgy");


			
					if(mysql_errno() != 0)
		
					{
						die("can't change databse");
					};



					echo "Dtabase changed successfully! <br/>\n" ;


					$table = mysql_query("SELECT * FROM projects");





					echo "<table border='10'>\n";
					echo"   <tr>
						<tr bgcolor='red'>
						<th>Projects number</th>
						<th>Type</th>
						<th>Address</th>
						<th>Client Id</th>
						<tr>";




					while($info=mysql_fetch_array($table,MYSQL_ASSOC))
					{
				
					echo 		"<tr> 
							<tr bgcolor='yellow'>
							<td bgcolor='blue'><b>".$info['Proj_num']."<b/></td>".
						"<td>".$info['Proj_type']."</td>".
						"<td>".$info['Proj_adress']."</td>".
						"<td>".$info['Clie_id']."</td>
						</tr>\n";
						 
					};

					echo "</table>\n";
			
		
					}//closing if of projects
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ENd of testinf and viewinf tables@@@@@@@@@@@@
			}//closing else not cloients

		}//close testing tables of database  
			else
			{
			echo "There is not any table called  <b>".$door."</b> in the Dodgy database";
			}
echo "<tr>
<A HREF='http://localhost/databases.php'>Click Here To go back the submit Query</A> 
</tr>";
		}//close _POST
		else//of if _POST
		{
		echo 
			"<html>
	    		<head><title>Viewing tables of database</title>
			</head>
			<body>
				<form action='' method='POST'>
				<input type='text' name='door'>
				<input type='submit' />
				</form>
			</body>
			</html>";
		};


?>

From where you want to insert data in this table? from an html page that any user has submitted or from the DB?

from DATA base (DB).

for more details: i have MYSQL and PHP instaed in machine only there no connect to any network (localhost).
as you see the program i posted before. from the html i put query then the program output table (data set) on html page. what i am looking how to use query to input from html file.
example: if have to unpdata table Clients i want to creat HTML page and by feeling all field (name, dob, address) and after pressing submit query will input this information on the table client.
thank you

from DATA base (DB).

for more details: i have MYSQL and PHP instaed in machine only there no connect to any network (localhost).
as you see the program i posted before. from the html i put query then the program output table (data set) on html page. what i am looking how to use query to input from html file.
example: if have to unpdata table Clients i want to creat HTML page and by feeling all field (name, dob, address) and after pressing submit query will input this information on the table client.
thank you

As per I can reach to your problem you want to create such an html page from where you enter values and that values will be inserted in the table "client". For this the html page will be:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add new Client</title>
</head>

<body>
<form method="post" action="insertClient.php">

	<table align="center" width="80%">
	
		<tr>
			<td><input type="text" name="name" /></td>
		</tr>
		
		
		<tr>
			<td><input type="text" name="add" /></td>
		</tr>
		
	</table>
	
</form>
</body>
</html>

and code for createClient.php is as follows:

<?

	// write here db connectivity code
	
/* value posted by user at html page. It will be retrived by post 
 method and should be saved in php variables */

	$name = $_POST["name"]; 
	$add = $_POST["add"];

/* applying insert query. here the "name" and "add" are the name of db fields from client table and "$name", "$add" contains values posted by user */

$Q = mysql_query("Insert into clients (name, add) values ('$name', '$add') ");

/* if you have setted the client id at auto increment then there is no need to insert the value for client id, as db will automatically insert new id when a new client will be added */

?>

Hope that it will be helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.