![]() |
|
#1
|
|||
|
|||
something wrong with this codeWhy this code can't select the StaffID, if I delete 'where StaffID = $StaffID', this will show all the result, but I want the selected StaffID only. Something wrong with this code?
Thank you for your help! <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = $StaffID"); $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[PayrollNumber]"; } mysql_close(); ?> |
|
#2
|
||||
|
||||
|
Try :
PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
is not an integer, is a string
|
|
#4
|
||||
|
||||
|
Oh OK, then...
PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#5
|
|||
|
|||
|
Here is the complete code. Thank you!!
create table Payroll (PayrollNumber int(5) not null, StaffID varchar(25), GrossPay float, HourlyRate float, YearToDateEarnings float, IncomeTax float, EPFNumber varchar(25), SOCSONumber varchar(25)); insert into Payroll values (10001, 'Ken', 12000.10, 160, 36000.50, 200.30, 'A12121212', 'B23232323'); ---------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><font size="2">Welcome <?php foreach ($HTTP_COOKIE_VARS as $value) print ("$value"); ?> ! </font></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td width="33%">Payroll Number :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[PayrollNumber]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">Staff ID :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? echo $value ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">Gross Pay :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[GrossPay]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">Hourly Rate :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[HourlyRate]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">Year To Date Earnings :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[YearToDateEarnings]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">Income Tax :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[IncomeTax]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">EPF Number :</td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[EPFNumber]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> <tr> <td width="33%">SOCSO Number : </td> <td width="67%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <? $Connect = mysql_connect("localhost","root",""); mysql_select_db("mw"); $StaffID = "$value"; $result=mysql_query("select * from Payroll where StaffID = '$StaffID'") ; $number_of_array = mysql_num_rows($result); while ($number_of_array = mysql_fetch_array($result)){ echo "$number_of_array[SOCSONumber]"; } mysql_close(); ?> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> </html> |
|
#6
|
||||
|
||||
|
What does this mean, you just want to share the code or is there something still that doesn't work?
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parsing PHP code that's stored in a database. | JdS | MySQL / PHP Forum | 3 | 13-May-2004 09:15 |
| problem with C code | belludandy | C Programming Language | 1 | 26-Jan-2004 21:28 |
| Save code option | BobbyDouglas | GIDForums™ | 3 | 08-Nov-2003 23:48 |
| strange compile error - code from reputable author!! | newbie_cpp | CPP / C++ Forum | 0 | 06-Nov-2003 16:15 |
| error handling code.. | daveyp225 | CPP / C++ Forum | 0 | 26-Oct-2003 06:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The