Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-21-2008, 07:16 AM   PM User | #1
sudhakararaog
Regular Coder

 
Join Date: Sep 2007
Posts: 137
Thanks: 1
Thanked 0 Times in 0 Posts
sudhakararaog is an unknown quantity at this point
question about select query

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.
sudhakararaog is offline   Reply With Quote
Old 01-21-2008, 07:25 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
The answer to the question "Is the query correct?" would be, "Does the query work?"

If yes, then the query is right. If no, then it isn't.
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

Forum Jump


All times are GMT +1. The time now is 08:13 PM.


Advertisement
Log in to turn off these ads.