Forum Moderators: coopster
I am able to get the data to simply display...(which is a good first step)
Now I need to add to the script.
Here is an example of my data that I am pulling to display currently.
id name category clicks date
100092000000 books cat1 3 09.22.04
100092010000 books cat2 7 09.22.04
100092000000 books cat1 8 09.23.04
100092140000 books cat4 4 09.23.04
100092010000 books cat2 9 09.24.04
100092140000 books cat4 4 09.24.04
100092000000 books cat1 2 09.24.04
What I would like to do is write a script that will show a quick summary of TOTAL clicks per DAY depending upon id name category and a specific date range choosen.
The current script I am using shows me a click total for all records fetched, but it does not give me a quick summary for each category's click totals.
Here is the current script:
<?php
echo "<table align=center bgcolor=#EEEEEE width=95%>
<tr>
<form action='$PHP_SELF'>
<td align=left><b>Show Activity:
<br><br>Websites: </b>";
echo drop_id('websites')." <br><b>Vendors: </b> ";
echo drop_id('vendors')."<br><b>Products: </b>";
echo drop_id('products')."</td></tr><tr><td align=left>
<br>
<b>FROM:</b>
<br>";
// Make the months array
$months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
// Make the days and years arrays.
$days = range (1, 31);
$years = range (2004, 2010);
// Make the date pull down menus.
echo '<select name="month1">';
foreach ($months as $key => $value) {
echo "<option value=\"$key\">$value</option>\n";
}
echo '</select>';
echo '<select name="day1">';
foreach ($days as $value) {
echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
echo '<select name="year1">';
foreach ($years as $value) {
echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
echo" <br><b>TO:</b><br>";
echo '<select name="month2">';
foreach ($months as $key => $value) {
echo "<option value=\"$key\">$value</option>\n";
}
echo '</select>';
echo '<select name="day2">';
foreach ($days as $value) {
echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
echo '<select name="year2">';
foreach ($years as $value) {
echo "<option value=\"$value\">$value</option>\n";
}
echo '</select>';
echo "<br><input type=submit name=submit value='Submit'></td></form>
</tr>
</table>";
if(isset($submit))
{
$date1=$year1."-".$month1."-".$day1;
$date2=$year2."-".$month2."-".$day2;
$id="$websites"."$vendors"."$products";
$query="select * from DATABASE where id like '$id'";
$res=mysql_query($query);
echo "<center><h3>Showing activity between $date1 and $date2</H3></center>";
echo "<table align=center border=1 width=90% bordercolor=#CCCCCC>
<tr><td>Date</td><td>ID</td><td>Name</td><td>Website Name</td><td>Clicks</td></tr>";
$date1=$date1." 00:00:00";
$date2=$date2." 00:00:00";
$tclick="";
while($row=mysql_fetch_array($res))
{
$query="select * from database_detail where id like '$row[id]' and ndate>='$date1' and ndate<='$date2'";
$res1=mysql_query($query);
while($row1=mysql_fetch_array($res1))
{
$tclick=$tclick+$row1[clicks];
echo "<tr><td>".substr($row1[ndate],0,10)."</td><td>$row[id]</td><td>$row[nom]</td><td>$row[cat]</td><td>$row1[clicks]</td></tr>";
}
}
echo "<tr><td></td><td></td><td></td><td></td><td><b>$tclick</b></td></tr>";
echo "</table>";
}
?>
Any guidance is appreciated!
Thanks,
Christian
welcome to ww and have a look at the forum charter: [webmasterworld.com...] .
I'll give you a basic answer to the question, but sort of in the spirit of the charter, it'll require you to go to the php manual and figure some things out. If you want a more extensive answer, it might be best to post your question on Macromedia's Dreamweaver forums: [macromedia.com...] I'd guess that not many of us use dreamweaver to create php code, and it can be difficult answering people's questions who create a bit of php code with dreamweaver, and then find it doesn't work or doesn't do what they want it to. The code produced often isn't that easy to read, and the person asking the question often has no idea of what's working and isn't working, so just posts the whole bit of code. There are a lot of people here who go the extra mile to help people in php coding, but this fact might attract the type of posts that our charter discourages.
Basic answer is: I see you are already getting an element of your array called $row1['clicks']. I haven't gone through all the code to see exactly what it is, but it's likely to correspond to the value you want - you can just make a variable, and add this value to the variable each time it's gotten from the database.
$totalclicks = $totalclicks + $row1['clicks'];
At the point that all this info has been collected and added up:
echo $totalclicks;
Chances are you'll want to read the excellent beginner's tutorial at php.net .