Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 24th, 2003, 07:45 PM
JenniferKearns JenniferKearns is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 8 JenniferKearns User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Not Returning Anything

Hi
I'm having a bit of a problem with a PHP page. It is supposed to select data from the database and return it to the appropriate text boxes in a HTML page.

The code is as follows. If anyone can help, please.

php Code:
Original - php Code
  1.  
  2.  
  3. <html>
  4. <body background=green_ba.jpg>
  5. <img src="whitelogo.bmp" align= "right">
  6.  
  7. <?
  8.  
  9. $Emp_No=$_POST['Emp_No'];
  10. $Wk_No=$_POST['Wk_No'];
  11.  
  12. $connection=mysql_connect (localhost)
  13. or die("cannot make the connection");
  14.  
  15. $db = mysql_select_db ("payroll", $connection)
  16. or die ("Cannot connect to the database");
  17.  
  18. $query= "SELECT * FROM personaldetails WHERE Emp_No='$Emp_No' ";
  19. $result=mysql_query($query);
  20. $num=mysql_num_rows($result);
  21.  
  22. $i=0;
  23. while ($i < $num)
  24. {
  25. $Emp_No=mysql_result($result,$i,"Emp_No");
  26. $Employee_Surname=mysql_result($result,$i,"Employee_Surname");
  27. $Employee_Firstname=mysql_result($result,$i,"Employee_Firstname");
  28. $Employee_Address=mysql_result($result,$i,"Employee_Address");
  29. $Dept_Id=mysql_result($result,$i,"Dept_Id");
  30. $PPS_No=mysql_result($result,$i,"PPS_No");
  31. $PRSI_Class_ID=mysql_result($result,$i,"PRSI_Class_ID");
  32. $CC_ID=mysql_result($result,$i,"CC_ID");
  33. ?>
  34.  
  35.  
  36. <p>
  37. Employee Number: <input type="text" name="Emp_No" value="<? echo "$Emp_No"; ?>"><p>
  38. Employee Surname: <input type="text" name="Employee_Surname" value="<? echo "$Employee_Surname" ?> "><br>
  39. Employee Firstname: <input type="text"  name="Employee_Firstname" value="<? echo "$Employee_Firstname" ?>"> <br>
  40. Employee_Address: <input type="text"  name="Employee_Address" value="<? echo "$Employee_Address" ?>"> <br>
  41. Dept_Id: <input type="text"  name="Dept_Id" value="<? echo "$Dept_Id" ?>"> <br>
  42. PPS_No: <input type="text"  name="PPS_No" value="<? echo "$PPS_No" ?>"> <br>
  43. PRSI_Class_ID: <input type="text"  name="PRSI_Class_ID" value="<? echo "$PRSI_Class_ID" ?>"> <br>
  44. CC_ID: <input type="text"  name="CC_ID" value="<? echo "$CC_ID" ?>"> <br>
  45.  
  46.  
  47. <?
  48. ++$i;
  49. }
  50.  
  51. ?>
  52. </body>
  53. </html>
  54.  

Reply With Quote
  #2  
Old March 25th, 2003, 01:32 AM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: PHP Not Returning Anything

First Connection should be
Code:
$connection = mysql_connect ("localhost", "username", "passwd") or die ("Unable to connect");

not

$connection=mysql_connect (localhost)


Then make your result easier like
Code:
$result = @mysql_query($sql,$connection)
        or die (mysql_error());

while ($row = mysql_fetch_array($result)) {

$Emp_No =$row['Emp_No'];

$Employee_Surname =$row['Employee_Surname'];

and so on

}

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > PHP Not Returning Anything


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT