473,729 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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_use rs 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_use rs 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($qu ery);

// 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($r esult,$i,"Name" );
$Last_Name = mysql_result($r esult,$i,"Last_ Name");
$Equipment = mysql_result($r esult,$i,"Equip ment");
$Project = mysql_result($r esult,$i,"Proje ct");
$Days_Out = mysql_result($r esult,$i,"Days_ Out");
$ID_Cost = mysql_result($r esult,$i,"ID_Co st");
// print "$a $b $c $d $e $f $g<br>";

if ($i%2 == 0) {
print "<tr bgcolor=lightgr ey>";
} else {
print "<tr>";
}
print "<td>$Name $Last_Name</td>
<td>$Equipmen t</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 1287
kaioshin00
46 New Member
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
alisonjane
2 New Member
Yes, but I don't know how to make that form.
Oct 11 '07 #3
Motoma
3,237 Recognized Expert Specialist
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
2870
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 it because hosting company denies access to db port. I looked at other ways to dump the data but the escaped characters always threw the import off. There probably a way to do using MySQLDUMP command. HOwever, I remember a long time ago I wrote...
2
3056
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 to have an easier time understanding what I do. Therefore this weekend I'm going to spend 3 days just writing comments. Before I do it, I thought I'd ask other programmers what information they find useful. Below is a typical class I've...
15
7388
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 atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
0
1343
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 number 150,000 the rate is about 2,000 records per hour). We're running on the following: P4 (1.5 Ghz), 1.2 Gbytes RAM (650 Mbytes RAM Disk using ramfs), IDE drive (72,00 rpm) So far we've moved the MySQL data files (var/lib/mysql), PHP /tmp...
6
3868
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 because MySQL inserts a backslash, "\", in front of an apostophe that user enters in a text field and MS Access doesn't know how to interpret that. Any ideas for easily getting whatever kind of data from MySQL to MS Access?
15
4636
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
4
2350
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 into the server (plesk interface), or use it on my pc, and then how do I access the site's database to modify entries. And all this because I'm tired of my web-designer's unresponsiveness.
1
3882
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 there only new values from file. here is the code: #!/usr/bin/perl -w use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.