Plz help -creatin a report module

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alexrho
Forum Newbie
Posts: 3
Joined: Wed Dec 14, 2005 11:39 am

Plz help -creatin a report module

Post by alexrho »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hello

I am new in php and i want to ask you something

I want to create a script that the admin  will choose a date e.x 12 December 2005

and click sumbit and show him the result only for 12 december 2005

I have created the arrays for day month and year and i want now someone to help me how i can add the things that i told you before.
i have uploaded the script at http://www.greekfrape.com/mod_report.php

This is the code that i have written :

Code: Select all

?><html>

<head>
  <title></title>
</head>

<body>

<?php
/* Program name: report.php
* Description: Program displays a selection list that
* customers can use to select a date.
*/
$link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
  or die ("Could not connect to MySQL");

mysql_select_db ("my_database")
  or die ("Could not select database");
echo "<html>
<head><title>Select a date</title></head>
<body>";
/* create an array of months*/
$monthName = array(1=> "January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December");
$today = time(); //stores today's date
$f_today = date("M-d-Y",$today); //formats today's date
echo "<div align='center'>\n";
/* display today's date */
echo "<p>&nbsp;<h3>Today is $f_today</h3><hr>\n";
/* create form containing date selection list */
echo "<form action='processform.php' method='POST'>\n";
/* build selection list for the month */
$todayMO = date("m",$today); //get the month from $today
echo "<select name='dateMO'>\n";
for ($n=1;$n<=12;$n++)
{
echo "<option value=$n\n";
if ($todayMO == $n)
{
echo " selected";
}
echo "> $monthName[$n]\n";
}
echo "</select>";
/* build selection list for the day */
$todayDay= date("d",$today); //get the day from $today
echo "<select name='dateDay'>\n";
for ($n=1;$n<=31;$n++)
{
echo " <option value=$n";
if ($todayDay == $n )
{
echo " selected";
}
echo "> $n\n";
}
echo "</select>\n";
/* build selection list for the year */
$startYr = date("Y", $today); //get the year from $today
echo "<select name='dateYr'>\n";
for ($n=$startYr;$n<=$startYr+1;$n++)
{
echo " <option value=$n";
if ($startYr == $n )
{
echo " selected";
}
echo "> $n\n";
}
echo "</select>\n";
echo "</form>\n";

?>
</body>

</html>
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
Bomas
Forum Newbie
Posts: 24
Joined: Sun Oct 17, 2004 2:41 am
Location: Heverlee, Belgium

Post by Bomas »

are you using a database, containing all reports?

if so, you have to need a table with a col with the dates in it. Then you just select everything from the table where date="$selecteddate";
or in php:

Code: Select all

$sql = "SELECT * FROM mytable WHERE date='".$_POST[year].$_POST[month].$_POST[day]."'";
$res = mysql_query($sql);
while( $all =mysql_fetch_row($sql)){
echo $all[col1]." -- ".$all[col2]; // just edit to your needs: numbers of cols and the fieldnames
}
Greetz,
UnrealEd
alexrho
Forum Newbie
Posts: 3
Joined: Wed Dec 14, 2005 11:39 am

Nothing Plz help

Post by alexrho »

Look i ll be more specific
I am using joomla and i have added the comport virua mart(online shop)
I want someone to tell me the code that i would select a specific day and will export me the result for example the total orders of the day........
The strange is that i look the database and i saw that the date is Integer!!!
And also to have two options : One to view the results and second to download it in txt

My code is above so.... if you can add the part of code that i ned very nice!!!
check what the above code do here http://www.greekfrape.com/mod_report.php
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

The strange is that i look the database and i saw that the date is Integer!!!
Date is being stored as a timestamp. See mktime() to translate dates into timestamps.

I don't use Joomla, however, and I can't be more specific. Does this help?
Last edited by Ambush Commander on Thu Dec 15, 2005 5:23 pm, edited 1 time in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Please show your table structure.

EX:

Code: Select all

TABLE1

ID    INT
DTTM    DATETIME
SUBJECT        TEXT

This way we can help you with your SELECT Query.


Note: Talked via IM
alexrho
Forum Newbie
Posts: 3
Joined: Wed Dec 14, 2005 11:39 am

here is the query

Post by alexrho »

HawleyJR | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Code: Select all

order_id   int(11) NO
user_id   int(11) NO  0  
vendor_id   int(11) NO  0  
order_number   varchar(32) YES  NULL  
user_info_id   varchar(32) YES  NULL  
order_total   decimal(10,2) NO  0.00  
order_subtotal   decimal(10,5) YES  NULL  
order_tax   decimal(10,2) YES  NULL  
order_shipping   decimal(10,2) YES  NULL  
order_shipping_tax   decimal(10,2) YES  NULL  
coupon_discount   decimal(10,2) NO  0.00  
order_discount   decimal(10,2) NO  0.00  
order_currency   varchar(16) YES  NULL  
order_status   char(1) YES  NULL  
cdate   int(11) YES  NULL  
mdate   int(11) YES  NULL  
ship_method_id   varchar(255) YES  NULL  
customer_note   text NO 
ip_address   varchar(15) NO
HawleyJR | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Ambush Commander wrote: Date is being stored as a timestamp. See mktime() to translate dates into timestamps.
Post Reply