hi everybody i have this code for selecting data from my sql database but when i outpot it it it looses align ment,can someone help me ,pliz,thanks

<?php 
//The code is for selecting all patients records in the database
//This selects the database and connects to the database
require_once('Connections/Database.php');
mysql_select_db($database_Database, $Database);
$stat="select * from patients";
$stat2=mysql_query($stat) or die('Error, query failed,we cant select any records');
echo"<table>";
echo"<tr><th></th><th>ID</th><th></th><th>SURNAME</th><th></th><th>FIRSTNAME</th><th></th><th>VILLAGE</th><th></th><td></td><td></td>

<th>DEPARTMENT</th><th></th><th>AGE</th><th></th><th>SEX</th><th></th><th>TRIBE</th><th></th><th></th><th></th

><th></th><th></th><th></th><th>SYMPTOMS</th><th></th><th></th><th></th><th></th><th></th><th></th><th>DATE</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th>WEIGHT</th><th></th><th></th><th></th><th></th><th>HEIGHT</th><th></th><th></th><th></th><th></th><th>TEMP</th><th></th><th></th><th></th><th></th><th>BLDPRESSURE</th></tr>";
echo"</table>";
echo"<table>";
while ($stat3=mysql_fetch_array($stat2))
{
echo"<tr><th></th><th>$stat3[pID]

</th><td></td><td></td><td></td><td></td><td>$stat3[pName]

</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[pfName]

</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[village]</td><td></td><td></td><td></td><td>$stat3[dept]

</td><td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[age]

</td><td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[sex]

</td><td></th><td></td><td></td><td></td><td></td><td>$stat3[tribe]</td><td></td><td></td><td></td><td></td><td></td><td>$stat3[symptoms]</td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[day]</td><td>$stat3[month]</td><td>$stat3[year]</td><td></td><td></td><td></td><td></td><td>$stat3[wgt]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[hgt]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[temp]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[bldp]</td></tr>";

}
echo"</table>";


?>

i also have this code for login as either administrator or user using the same button on the form but its not working whats the problem

<?php
// This code will use the username entered to open the wellcome page for kawempe health centre
require_once('Connections/Database.php');
mysql_select_db($database_Database, $Database);
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['password'] )
{
die('You did not complete all of the required fields');
}
$a=$_POST['username'];
$b=$_POST['password'];
//This code runs if the form has been submitted

if (isset($_POST['SUBMIT']))
{

$_POST['username'] = addslashes($_POST['username']);
$sql = "SELECT * FROM admin WHERE username = '$a' AND Password = '$b'";
$result = mysql_query($sql); 
$num=mysql_num_rows($result);
if($num==1){
header("location:admnwelcom.html");
}
if($num < 1) 
 {
$_POST['username'] = addslashes($_POST['username']);
$sql1 = "SELECT * FROM users WHERE username = '$a' AND Password = '$b'";
$result1 = mysql_query($sql1); 
$num=mysql_num_rows($result1);
if($num < 1) //username and password not found
 {
exit("username and password you  entered are not valid.<br>") ;
   
}


else {
    header("Location:wellcomepage.html");
}
   
}




}
?>

sorry i have multiple problems i have this code but doesnt give any out put whats the problem i want to out put the records where a given day,month,year are entered from the form

<?php 
//The code is for selecting all patients records in the database where a particular month and year
//This selects the database and connects to the database
require_once('Connections/Database.php');
mysql_select_db($database_Database, $Database);

$a=$_POST['monapt'];
$b=$_POST['yearapt'];
$c=&_POST['day']
$stat="select * from patients where month='$a',day='$c' AND year='$b'";
$result1=mysql_query($stat)or die('Error, query failed,we cant select any records');
$count=mysql_num_rows($result1);
			
echo "<pre>          $count  record(s) Found</pre>";
echo"<table >";
while ($result=mysql_fetch_array($result1)) 
{

echo"<pre>          Patients number        :$result[pID] <br>
          Patients Names          :$result[pName] $result[pfName] <br>
          Age                     :$result[age] <br>
          Patients lives in       :$result[village] <br> 
          Department Visited      :$result[dept] <br> 
	  Sex                     :$result[sex] <br>
	  Tribe                   :$result[tribe] <br>
	  Presented with          :$result[symptoms] <br>
          Date visited            :$result[month] $result[day] $result[year]<br>
	  Patients Weight         :$result[wgt] Kilograms<br>
	  Patients Height         :$result[hgt] centimetres<br>
	  Temperature             :$result[temp] Degrees centigrade<br>
          Blood Pressure          :$result[bldp]mmhg <br>
	  Doctors ID              :$result[dID] <br>";

}
echo"</table>";


?>

can some one help me tell how to set colors in php,and also how to use the date type in mysql database,
laslt may some one help on how to pick data from multiple tables thanks

Recommended Answers

All 3 Replies

<tr><th></th><th>$stat3[pID]

</th><td></td><td></td><td></td><td></td><td>$stat3[pName]

</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[pfName]

</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[village]</td><td></td><td></td><td></td><td>$stat3[dept]

</td><td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[age]

</td><td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[sex]

</td><td></th><td></td><td></td><td></td><td></td><td>$stat3[tribe]</td><td></td><td></td><td></td><td></td><td></td><td>$stat3[symptoms]</td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[day]</td><td>$stat3[month]</td><td>$stat3[year]</td><td></td><td></td><td></td><td></td><td>$stat3[wgt]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[hgt]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[temp]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[bldp]</td></tr>

What the heck are you doing?!
Why, why, WWWWHHHHHHHHYYYYYYYY?. I'm not helping you until you explain this madness.

alright i see what you are doing with the html part but it is all wrong tables can use height, width, align, valign, and css you do not need all the extra tags so you really need to clean up your html before you work in to php go to w3school.com to help you with the html alright

really very very confused html coding and the selection coding parts...

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.