login,display,selecting data from database querries

Reply

Join Date: Apr 2009
Posts: 10
Reputation: mbabaali is an unknown quantity at this point 
Solved Threads: 0
mbabaali mbabaali is offline Offline
Newbie Poster

login,display,selecting data from database querries

 
0
  #1
Jun 15th, 2009
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
  1. <?php
  2. //The code is for selecting all patients records in the database
  3. //This selects the database and connects to the database
  4. require_once('Connections/Database.php');
  5. mysql_select_db($database_Database, $Database);
  6. $stat="select * from patients";
  7. $stat2=mysql_query($stat) or die('Error, query failed,we cant select any records');
  8. echo"<table>";
  9. 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>
  10.  
  11. <th>DEPARTMENT</th><th></th><th>AGE</th><th></th><th>SEX</th><th></th><th>TRIBE</th><th></th><th></th><th></th
  12.  
  13. ><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>";
  14. echo"</table>";
  15. echo"<table>";
  16. while ($stat3=mysql_fetch_array($stat2))
  17. {
  18. echo"<tr><th></th><th>$stat3[pID]
  19.  
  20. </th><td></td><td></td><td></td><td></td><td>$stat3[pName]
  21.  
  22. </td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[pfName]
  23.  
  24. </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]
  25.  
  26. </td><td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[age]
  27.  
  28. </td><td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[sex]
  29.  
  30. </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>";
  31.  
  32. }
  33. echo"</table>";
  34.  
  35.  
  36. ?>


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
  1. <?php
  2. // This code will use the username entered to open the wellcome page for kawempe health centre
  3. require_once('Connections/Database.php');
  4. mysql_select_db($database_Database, $Database);
  5. //This makes sure they did not leave any fields blank
  6. if (!$_POST['username'] | !$_POST['password'] )
  7. {
  8. die('You did not complete all of the required fields');
  9. }
  10. $a=$_POST['username'];
  11. $b=$_POST['password'];
  12. //This code runs if the form has been submitted
  13.  
  14. if (isset($_POST['SUBMIT']))
  15. {
  16.  
  17. $_POST['username'] = addslashes($_POST['username']);
  18. $sql = "SELECT * FROM admin WHERE username = '$a' AND Password = '$b'";
  19. $result = mysql_query($sql);
  20. $num=mysql_num_rows($result);
  21. if($num==1){
  22. header("location:admnwelcom.html");
  23. }
  24. if($num < 1)
  25. {
  26. $_POST['username'] = addslashes($_POST['username']);
  27. $sql1 = "SELECT * FROM users WHERE username = '$a' AND Password = '$b'";
  28. $result1 = mysql_query($sql1);
  29. $num=mysql_num_rows($result1);
  30. if($num < 1) //username and password not found
  31. {
  32. exit("username and password you entered are not valid.<br>") ;
  33.  
  34. }
  35.  
  36.  
  37. else {
  38. header("Location:wellcomepage.html");
  39. }
  40.  
  41. }
  42.  
  43.  
  44.  
  45.  
  46. }
  47. ?>


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
  1. <?php
  2. //The code is for selecting all patients records in the database where a particular month and year
  3. //This selects the database and connects to the database
  4. require_once('Connections/Database.php');
  5. mysql_select_db($database_Database, $Database);
  6.  
  7. $a=$_POST['monapt'];
  8. $b=$_POST['yearapt'];
  9. $c=&_POST['day']
  10. $stat="select * from patients where month='$a',day='$c' AND year='$b'";
  11. $result1=mysql_query($stat)or die('Error, query failed,we cant select any records');
  12. $count=mysql_num_rows($result1);
  13.  
  14. echo "<pre> $count record(s) Found</pre>";
  15. echo"<table >";
  16. while ($result=mysql_fetch_array($result1))
  17. {
  18.  
  19. echo"<pre> Patients number :$result[pID] <br>
  20. Patients Names :$result[pName] $result[pfName] <br>
  21. Age :$result[age] <br>
  22. Patients lives in :$result[village] <br>
  23. Department Visited :$result[dept] <br>
  24. Sex :$result[sex] <br>
  25. Tribe :$result[tribe] <br>
  26. Presented with :$result[symptoms] <br>
  27. Date visited :$result[month] $result[day] $result[year]<br>
  28. Patients Weight :$result[wgt] Kilograms<br>
  29. Patients Height :$result[hgt] centimetres<br>
  30. Temperature :$result[temp] Degrees centigrade<br>
  31. Blood Pressure :$result[bldp]mmhg <br>
  32. Doctors ID :$result[dID] <br>";
  33.  
  34. }
  35. echo"</table>";
  36.  
  37.  
  38. ?>


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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: login,display,selecting data from database querries

 
0
  #2
Jun 15th, 2009
<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.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 26
Reputation: jcanaway is an unknown quantity at this point 
Solved Threads: 0
jcanaway's Avatar
jcanaway jcanaway is offline Offline
Light Poster

Re: login,display,selecting data from database querries

 
0
  #3
Jun 15th, 2009
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
Canaway Productions
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC