Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-09-2004, 10:53 AM
min min is offline
New kid on the block
 
Join Date: Sep 2004
Location: Penang
Posts: 3
Rep Power: 0
min is on a distinguished road
generate report by month and year

leh sesape tolong aku tak...

aku nak combine 2 tables...

1. table register : empname
2. table transaction : empno, access_number, title, category,
entry_date, status

problem aku skarang ialah aku nak display report by month and year...bila aku combine 2 table tu ok tp bila aku letak condition..
WHERE year(entry_date)=$year and month(entry_date)=$month
terus tak dapat...

please somebody help me...

Attach here is my coding for your reference.. thank you!


<body bgcolor="#999999"> <?

include ("connect.php") ;



$month = $HTTP_POST_VARS ['requiredmonth'];
$year = $HTTP_POST_VARS ['requiredyear'];
$status1 = 'BORROW';




$query = "select register.empname, transaction.empno,
transaction.access_number, transaction.title,
transaction.category,
transaction.status1, transaction.entry_date,
transaction.due from register, transaction where
transaction.empno=register.empno
and `status1` = '". $status1 ."'" ;

$result = mysql_query($query);
$num=mysql_num_rows($result);

if(mysql_num_rows($result)==0)
{
print "<SCRIPT LANGUAGE=\"JavaScript\">";
print "alert(\"DATA NOT EXIST IN DATABASE \")";
print "</SCRIPT>";
print "<SCRIPT LANGUAGE=\"JavaScript\">";
print "location.replace
(\"report_borrow_month_year.php\")";
print "</SCRIPT>";


}

else
{

echo " <td><center><font size=\"1\"><font
color=\"blue\">MONTHLY BORROWING REPORT
</center></td>";
echo " <td>MONTH : $month</td>\n";
echo " <td><br>YEAR : $year <br></td>\n";
echo " <td><br></td>\n";
echo "<table width=\"900\" border=\"1\"
align=\"center\"";
echo " <tr bgcolor=\"#DDDDDD\">";
echo " <td width=\"30\"> <center> <font size=\"1
\"> BIL </td>";
echo " <td width=\"200\"> <center> <font size=\"1\">
NAME </td>";
echo " <td width=\"50\"> <center> <font size=\"1\">
EMPLOYEE NUMBER</td>";
echo " <td width=\"150\"> <center> <font size=\"1\">
ACCESS NUMBER </td>";
echo " <td width=\"80\"> <center> <font size=\"1\">
TITLE </td>";
echo " <td width=\"80\"> <center> <font size=\"1\">
CATEGORY </td>";
echo " <td width=\"80\"> <center> <font size=\"1\">
STATUS </td>";
echo " <td width=\"60\"> <center> <font size=\"1\">
ENTRY DATE </td>\n";
echo " <td width=\"80\"> <center> <font size=\"1\">
DUE </td>\n";
echo " </tr>\n";


for($a = 1; $a <= $num; $a++)
{

if ($row=mysql_fetch_row($result))


{
echo "<tr bgcolor=\"#EEEEEE\">\n";
echo " <td> <font size=\"1\"> <center>$a</center></td>\n";
echo " <td> <font size=\"1\"> $row[0]</td>\n";
echo " <td> <center> <font size=\"1\"> $row[1]</td>\n";
echo " <td><font size=\"1\"> $row[2]</td>\n";
echo " <td><center><font size=\"1\"> $row[3]</td>\n";
echo " <td> <font size=\"1\"> $row[4]</td>\n";
echo " <td> <center> <font size=\"1\"> $row[5]</td>\n";
echo " <td> <center> <font size=\"1\"> $row[6]</td>\n";
echo " <td> <center> <font size=\"1\" color=\"red\"> $row[7]</td>\n";

echo " </tr>\n"; }
}

}

echo "</table> \n";
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-09-2004, 12:38 PM
heterozigot's Avatar
Novice Webmaster
 
Join Date: Jan 2003
Location: PJ
Posts: 51
Rep Power: 70
heterozigot is on a distinguished road
Send a message via ICQ to heterozigot Send a message via Yahoo to heterozigot
WHERE year(entry_date)=$year and month(entry_date)=$month

code ko dah betul

ko try: echo $query;

pastu copy query tu dan paste kat mysql..run query..error ke tak?
__________________
Try and Support Malaysia Product.
http://foto.home.net.my
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-09-2004, 02:00 PM
min min is offline
New kid on the block
 
Join Date: Sep 2004
Location: Penang
Posts: 3
Rep Power: 0
min is on a distinguished road
thanks heterozigot for helping me..

aku dah buat apa ko suruh tu tp still tak dpt...
ada cara lain tak ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-09-2004, 06:42 PM
lcf's Avatar
lcf lcf is offline
Pro-Blogger
 
Join Date: Feb 2003
Location: Kluang, Johor
Posts: 2,376
Rep Power: 115
lcf will become famous soon enough
Send a message via ICQ to lcf Send a message via MSN to lcf Send a message via Yahoo to lcf
what error message you get?
what are the table structure(fields) for both tables?
__________________
LiewCF | Malaysia Bloggers Forum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-09-2004, 10:10 AM
min min is offline
New kid on the block
 
Join Date: Sep 2004
Location: Penang
Posts: 3
Rep Power: 0
min is on a distinguished road
thanks lcf....

i got this error......

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\library\report_borrow_month_yea r_action.php on line 19
select register.empname, transaction.empno, transaction.access_number, transaction.title, transaction.category, transaction.status1, transaction.entry_date, transaction.due from register, transaction where year(entry_date)=2004 and month(entry_date)=7 and transaction.empno=register.empno and `status1` = 'BORROW'
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\library\report_borrow_month_yea r_action.php on line 24

my table structure(fields) is like this.....

1. register table
- empname
- empno
- address
- phoneno
- position
- gender
- entry_date (structure type: date like (2004-06-27))

2. tranaction table

- empno
- category
- title
- access_number
- status1
- entry_date
- duedate
- due
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-09-2004, 04:49 PM
Gemp-X's Avatar
Novice Webmaster
 
Join Date: Apr 2002
Location: kuantan, pahang
Posts: 58
Rep Power: 79
Gemp-X is on a distinguished road
Send a message via Yahoo to Gemp-X
cuba buat
WHERE entry_date LIKE "$year-$month%"
__________________
http://sidik.org/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using MySpace to generate Traffic limcs Other Internet Marketing Methods 9 28-01-2008 06:18 PM
AsiaWebserver - Hosting RM 4 p/month / RM40 p/year AsiaWebserver Web Hosting Offers 0 06-09-2006 06:21 PM
crytal report linux_rock Website Programming 1 23-08-2005 05:22 PM
Limited Time Offer - 4GB Space Reseller Hosting - Only $19.95/month - Month to Month Cash Other Webmaster-related Services and Promotion 0 13-04-2005 08:05 PM
Shared Hosting from $1.95/month & $19.50/year Wickedboy Other Webmaster-related Services and Promotion 0 23-03-2005 02:09 AM



All times are GMT +8. The time now is 11:52 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59