473,513 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question about select query

54 New Member
hi

i have an enquiry table which collects information about users
making an online travel enquiry

the fields in the table are = StoryTitle, EndCity, mode, PricedFrom,
numAdults, numChildren, numInfants

presently the select query is

<?php

$sql = SELECT Count(*) as Counts, StoryTitle, EndCity, mode,
PricedFrom, numAdults, numChildren, numInfants, ReturnLocation FROM
`enquiry` WHERE date_format(en_date,'%Y-%m-%d') BETWEEN '" .
$startDate . "' AND '" . $endDate . "' " . $enquiryText . "
Group By StoryTitle, EndCity, mode, PricedFrom, numAdults,
numChildren, numInfants, ReturnLocation
Order By Counts Desc, StoryTitle Desc, mode, PricedFrom, numAdults,
numChildren, numInfants, ReturnLocation";

while ($row_rs_newEnquiries
= mysql_fetch_assoc($rs_newEnquiries))
{
$echoStr .= "
<tr bgcolor='#ebebeb'
class='default'><td>".$row_rs_newEnquiries['Counts']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['StoryTitle']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['EndCity']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['mode']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['PricedFrom']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['numAdults']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['numChildren']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['numInfants']."</td>
<td class='default'>&nbsp; <a href=".$row_rs_newEnquiries
['ReturnLocation'].">".$row_rs_newEnquiries
['ReturnLocation']."</a></td>
</tr>";
$total = $total +
$row_rs_newEnquiries['Counts'];
}

$totalamount=$row_rs_newEnquiries['totalvalue'];

echo "value of total enquiry is $ ". $totalamount;

?>

i have used $totalamount=$row_rs_newEnquiries['totalvalue']; both
inside the while loop and outside the while loop however this is not
working.

here Counts is the column which collects the number of times an
enquiry was made to a particular city example Sydney however Counts
DOES NOT exist as a field in the table and PricedFrom collects the
value of the $ amount to a city and this field exists in the table,
so multiplying Counts and PricedFrom should give the result

is the syntax of the select query correct as there is a comma before
Count(*) & am i reading the value of this multiplied value correctly

please advice.

thanks.
Jan 21 '08 #1
2 1115
Markus
6,050 Recognized Expert Expert
Please use code tags when posting code.

Expand|Select|Wrap|Line Numbers
  1.  php goes here... 
[php]
<?php

$sql = SELECT Count(*) as Counts, StoryTitle, EndCity, mode,
PricedFrom, numAdults, numChildren, numInfants, ReturnLocation FROM
`enquiry` WHERE date_format(en_date,'%Y-%m-%d') BETWEEN '" .
$startDate . "' AND '" . $endDate . "' " . $enquiryText . "
Group By StoryTitle, EndCity, mode, PricedFrom, numAdults,
numChildren, numInfants, ReturnLocation
Order By Counts Desc, StoryTitle Desc, mode, PricedFrom, numAdults,
numChildren, numInfants, ReturnLocation";

while ($row_rs_newEnquiries = mysql_fetch_assoc($rs_newEnquiries)){
$echoStr .= "<tr bgcolor='#ebebeb'
class='default'><td>".$row_rs_newEnquiries['Counts']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['StoryTitle']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['EndCity']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['mode']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['PricedFrom']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['numAdults']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['numChildren']."</td>
<td
class='default'>&nbsp; ".$row_rs_newEnquiries['numInfants']."</td>
<td class='default'>&nbsp; <a href=".$row_rs_newEnquiries
['ReturnLocation'].">".$row_rs_newEnquiries
['ReturnLocation']."</a></td>
</tr>";
$total = $total +
$row_rs_newEnquiries['Counts'];
}

$totalamount=$row_rs_newEnquiries['totalvalue'];

echo "value of total enquiry is $ ". $totalamount;

?>
[/php]
Jan 21 '08 #2
stepterr
157 New Member
Runway27, if i'm understanding what you are looking for correctly, don't you want your $totalamount to = $total instead of $row_rs_newEnquiries['totalvalue']?
Jan 22 '08 #3

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

Similar topics

4
1707
by: cwhite | last post by:
Hi I have another drop list question. I have a table like this: computer dell computer ibm computer hp
4
2643
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I...
8
3226
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
3
6426
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
4
1903
by: Lauren Quantrell | last post by:
In my old MDB databases, I constructed a lot of "subQueries" to filter out records, then based a new query on the subQuery. This results in huge speed increases on large datasets. However... In...
3
1947
by: cover | last post by:
I have a table with 50 fields that receive input depending on whether that input came in from a 'shaker' form or a 'conveyor' form. Input from the 'conveyor' form might populate 25 fields while...
10
2078
by: Robert | last post by:
I am an attorney in a non-profit organization and a self-taught programmer. I'm trying to create a client db that will allow me to search for potential conflicts of interest based either on Social...
5
2345
by: ric_deez | last post by:
Hi there, I would like to create a simple search form to allow users to search for a job number based on a number of parameters. I think I understand how to use parameteres associated with Stored...
8
2789
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table,...
5
3816
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
0
7265
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,...
0
7171
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...
0
7388
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,...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1605
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 ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
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...

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.