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>";
};
?>