473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

No clue, I am new....need a way to get data out of mysql

Hi,
First, I apologize, but I am a biologist not a programmer!

Second, I made a web-based scheduling system in mysql. It works great but I need to generate a report by specifying a range of dates on another webpage.

I made the query to give me the columns I want, but I don't know how to create the front-end page on which I would like select the range of dates to show me. Here is the query that returns ALL records:

<?
// script to display all reservations

// connection information
$hostName = "localhost";
$userName = "*********";
$password = "**********";
$dbName = "************";

// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");

mysql_select_db($dbName) or die( "Unable to select database $dbName");

// Select all the fields in all the records of the Computers table
$query = "SELECT li.fname Name, li.lname Last_Name, rs.name Equipment, rv.summary Project, (TO_DAYS( from_unixtime( rv.end_date ) ) - TO_DAYS( from_unixtime( rv.start_date ) )) + 1 Days_Out , rs.notes ID_Cost
FROM reservations rv, resources rs, reservation_users ru, login li
WHERE rs.machid = rv.machid
AND ru.resid = rv.resid
AND li.memberid = ru.memberid
AND from_unixtime( rv.end_date ) <= CURRENT_DATE( )
UNION
SELECT li.fname Name, li.lname Last_Name, rs.name Equipment, rv.summary Project, (TO_DAYS( CURRENT_DATE( ) ) - TO_DAYS( from_unixtime( rv.start_date ))) + 1 Days_Out, rs.notes ID_Cost
FROM reservations rv, resources rs, reservation_users ru, login li
WHERE rs.machid = rv.machid
AND ru.resid = rv.resid
AND li.memberid = ru.memberid
AND from_unixtime( rv.end_date ) > CURRENT_DATE( )
AND from_unixtime( rv.start_date ) < CURRENT_DATE()
ORDER BY 4
LIMIT 0 , 30";
$result = mysql_query($query);

// Determine the number of computers
$number = mysql_numrows($result);

// print the computer names

print "<h2>There are $number equipment charge-outs between your specified date and now:</h2>
<table cellpadding=5>
<tr bgcolor=black>
<td><font color=white><b>Name</b></font></td>
<td><font color=white><b>Equipment</b></font></td>
<td><font color=white><b>Project</b></font></td>
<td><font color=white><b>Days_Out</b></font></td>
<td><font color=white><b>ID_Cost</b></td></font></tr>";

for ($i=0; $i<$number; $i++) {
$Name = mysql_result($result,$i,"Name");
$Last_Name = mysql_result($result,$i,"Last_Name");
$Equipment = mysql_result($result,$i,"Equipment");
$Project = mysql_result($result,$i,"Project");
$Days_Out = mysql_result($result,$i,"Days_Out");
$ID_Cost = mysql_result($result,$i,"ID_Cost");
// print "$a $b $c $d $e $f $g<br>";

if ($i%2 == 0) {
print "<tr bgcolor=lightgrey>";
} else {
print "<tr>";
}
print "<td>$Name $Last_Name</td>
<td>$Equipment</td>
<td>$Project</td>
<td>$Days_Out</td>
<td>$ID_Cost</td></tr>";
}
print "</table>";
// Close the database connection
mysql_close();
?>

<p>
Oct 11 '07 #1
3 1264
Can't you pass the start date and end date to the page that executes the query via a form and select only those reservations that fall within that range with mySQL?
Oct 11 '07 #2
Yes, but I don't know how to make that form.
Oct 11 '07 #3
Motoma
3,237 Expert 2GB
Take a look at this tutorial on PHP POST. It will give you the basics behind building user driven content. Next you will want to built two entry boxes that allow the user to specify the date range. Your page with then post the range to your PHP script, which will place those dates as restrictions on the dataset in your MySQL query.
Oct 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: NotGiven | last post by:
I have used dreamweaver to do a lot of php "programming" but now I need to write a real php function. I have a hosted mysql database that I need to export to MS Access. I can't use myODBC to do...
2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
0
by: Creigh Shank | last post by:
Using an Apache/PHP/MySQL/Linux (Redhat 8.0) solution, PHPList, to create an e-mailing list for our 5.6 million book club members. Unfortunately, the import speed for importing records (at record...
6
by: NotGiven | last post by:
I have a db that I need to dump into a format that can be easily read my MS Access. I tried the dump with regular PHPAdmin. Then I used the dump to run a query in MS Access. Errors occurred...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: nurcan.kurtoglu | last post by:
Hi, I have a .php site which uses a mysql database. I would like some info on how I can download (preferably free and simple) and use a GUI. As in, I know they exist, but do I need to put it...
1
by: Megi | last post by:
welcome, I input data form file to mysql with command: load data local infile.. The efect is that the data are duplicated or trippled..etc with every re-loading the script, but I need to load...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.