PHP - I Need Urgent Help Representing Grouped Data In A Table
Here is my database:
receipt_id | item_id | something_here 21 1 2 29 1 10 30 1 3 31 2 9 What i would like to do is display the above data from my database in a table looking like this: receipt_id | item_id | total_something_here 21 1 15 31 2 9 in short, i want to show only different item_id with the sum of something_here field for all records where item_id is the same ie 10 + 3 + 2 = 15 in the above example please help me Similar Tutorialsright now it displays the first column of the array as a header for each foreach loop then i've got the data displayed under each header and it has 4 columns or a number of my choosing with data displayed under the Table Headings. I am trying to make it display 4 or so columns but with the each group having a certain number of grouped table (data/header) in each column. a different amount for each column that i can choose IF Possible i'd like the choice of being able to remove the headers eg. Z when there is no data in them. This is an example of how it is being displayed right now Any Help would be greatly appreciated Quote A Airlie Beach Andergrove Alexandra Armstrong Beach Alligator Creek B Bucasia Blacks Beach Beaconsfield Bakers Creek Balberra Bloomsbury Breadalbane Ball Bay Belmunda C Cannonvale Calen Crystal Brook Cremorne Chelona Campwin Beach Cape Hillsborough Conway Heres The Code i have so far. Code: [Select] <?php $file = "widget.csv"; @$fp = fopen($file, "r") or die("Could not open file for reading"); $outputArray = array(); $count = 0; while(($shop = fgetcsv($fp, 1000, ",")) !== FALSE) { $outputArray[array_shift($shop)] = array_filter($shop); } echo "<table>"; foreach ($outputArray as $alphabetical=>$value){ echo "<th colspan='4'><b>" . $alphabetical ."</b></th>"; echo "<tr>"; foreach ($value as $key){ $afterkey=preg_replace('/\s+/','-',$key); if ($count == 4){ echo '</tr><tr><td><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></td>'; $count = 0; }else{ echo '<td><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></td>'; } $count++; } echo "</tr>"; $count = 0; } echo "</table>"; echo "\n<br />"; ?> Heres an example of what i am trying to do. A D K N S AlexandraHeadlands DickyBeach KingsBeach Nambour SandstonePoint Aroona Diddillibah KielMountain Ninderry ShellyBeach Doonan KundaPark NoosaHeads SippyDowns B Dulong Kuluin Ningi SunriseBeach Beachmere DeceptionBay Kilcoy NorthArm SunshineBeach BanksiaBeach Noosaville Scarborough Beerburrum E L Beerwah EerwahVale Landsborough O T Bellara Elimbah Tanawha Bellmere Eudlo M P TowenMountain Birtinya Eumundi Maleny Petrie Tewantin Bongaree Mapleton Palmview TwinWaters Bokarina F Marcoola Palmwoods BribieIslandArea Flaxton MarcusBeach Parklands U Buddina ForestGlen MaroochyRiver Parrearra UpperCaboolture Burnside Maroochydore PeregianBeach Buderim G Minyama Pinbarren V Burpengary GlassHouseMountains MoffatBeach PointArkwright Valdora BliBli Mons PelicanWaters H Montville PacificParadise W C Highworth Mooloolaba WeybaDowns CoolumBeach Hunchy Mooloolah Q Warana Caboolture MountainCreek WestWoombye CabooltureSouth I MountCoolum R Woombye Caloundra ImageFlat Morayfield Rosemount Woorim CastawaysBeach Mudjimba Redcliffe WamuranBasin Chevallum J Woodford CoesCreek WoodyPoint Cooroy Wamuran Currimundi Wurtulla X Y YandinaCreek Yandina Z Ok I have some data that I would like to have grouped by date. There are dates that have multiple entries for the same date. I would like to have that data listed under one date. I would like it to look like this Date Location Weather Location Weather Date Location Weather Here is the code I have so far and it lists the data by date but only the data for first date in the table. If there is data listed for the same date but different location it will not list that data. What am I missing. Any help would be great. ! <?php // Connect to server and select database. include ("opendb.php"); $tbl_name="dbnwaterfowl"; $sql="SELECT huntDate, huntLocation, huntWeather, waterfowlSpecies, waterfowlNumberKilled, waterfowlBandedNumber, DATE_FORMAT(huntDate,'%m %d, %Y') FROM dbnwaterfowl GROUP BY `huntDate` ORDER BY `huntDate` ASC"; $result=mysql_query($sql); ?> <td> <p> </p> <table width="100%" border="2" cellpadding="1" cellspacing="0" bordercolor="#FA6103" bgcolor="#FFFFFF"> <tr> <td colspan="7"><div align="center"> <p><img src="images/hl-logo.jpg" /></p> <p align="center"><strong><a href="login.php">Login</a> | <a href="insert.php">Log Hunt</a> | <a href="logout.php">Logout</a></strong></p> </div></td> </tr> <tr> <td align="center" bordercolor="#FA6103" ><span class="style4">Hunting Date</span></td> <td align="center" bordercolor="#FA6103" ><span class="style4">Hunting Location</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Weather</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Waterfowl Species</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Number Killed</span></td> <td align="center" bordercolor="#FA6103"><span class="style4">Number of Bands</span></td> <td align="center"> </td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><? echo $rows['huntDate']; ?></td> <td><? echo $rows['huntLocation']; ?></td> <td><? echo $rows['huntWeather']; ?></td> <td><? echo $rows['waterfowlSpecies']; ?></td> <td><? echo $rows['waterfowlNumberKilled']; ?></td> <td><? echo $rows['waterfowlBandedNumber']; ?></td> <td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td> </tr> <?php } ?> </table> </td> </tr> </table> <?php mysql_close(); ?> Currently we have a Microsoft Access database which we use to display a report, we are rolling over to PHP/SQL online for greater control e.t.c. So far we have the report pulling all the information from the database however we need to group this information by Day followed by Employee, sorted by time and then totaled for each Employee for each day. Below is the code we have so far which only prints columns how do we go about displaying it like the access screenshot. Attached is an example of the Microsoft Access report we have. Code: [Select] <?php $username='admin'; $password='password'; $database='planner'; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM reservations ORDER BY start_date, machid, starttime"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <?php $i=0; while ($i < $num) { $f0=mysql_result($result,$i,"machid"); $f1=mysql_result($result,$i,"start_date"); $f2=mysql_result($result,$i,"end_date"); $f3=mysql_result($result,$i,"starttime"); $f4=mysql_result($result,$i,"endtime"); $f5=mysql_result($result,$i,"first_name"); $f6=mysql_result($result,$i,"last_name"); $f7=mysql_result($result,$i,"company"); $f8=mysql_result($result,$i,"phone_number"); $f9=mysql_result($result,$i,"site_address"); $f10=mysql_result($result,$i,"site_suburb"); $f11=mysql_result($result,$i,"site_postcode"); $f12=mysql_result($result,$i,"postal_address"); $f13=mysql_result($result,$i,"postal_suburb"); $f14=mysql_result($result,$i,"postal_postcode"); $f15=mysql_result($result,$i,"job_type"); $f16=mysql_result($result,$i,"payment_type"); $f17=mysql_result($result,$i,"payment_status"); $f18=mysql_result($result,$i,"quote_outcome"); $f19=mysql_result($result,$i,"quote_amount"); $f20=mysql_result($result,$i,"quote_employee"); $f21=mysql_result($result,$i,"job_income"); $f22=mysql_result($result,$i,"job_materials"); $f23=mysql_result($result,$i,"invoice_number"); $f24=mysql_result($result,$i,"job_notes"); /* START TIME */ $stime = $f3; $shour = floor($stime/60); $smin = str_pad($stime % 60,2,0,STR_PAD_LEFT); //echo $hour.':'.$min; //echo '<br><br>'; // For AM/PM $shalf = 'am'; if( $shour > 12 ) { $shalf = 'pm'; $shour -= 12; } $stime = $shour.':'.$smin.' '.$shalf; /* END TIME */ $etime = $f4; $ehour = floor($etime/60); $emin = str_pad($etime % 60,2,0,STR_PAD_LEFT); //echo $hour.':'.$min; //echo '<br><br>'; // For AM/PM $ehalf = 'am'; if( $ehour > 12 ) { $ehalf = 'pm'; $ehour -= 12; } $etime = $ehour.':'.$emin.' '.$ehalf; ?> <table width="3500px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="125px"><?php echo $f0; ?></td> <td width="80px"><?php echo date('d-m-y', "$f1"); ?></td> <td width="50px" style="text-align:right;"><?php echo $stime; ?></td> <td width="50px" style="text-align:right; padding-right:20px;"><?php echo $etime; ?></td> <td width="100px"><?php echo $f5; ?></td> <td width="100px"><?php echo $f6; ?></td> <td width="100px"><?php echo $f7; ?></td> <td width="100px"><?php echo $f8; ?></td> <td width="100px"><?php echo $f9; ?></td> <td width="100px"><?php echo $f10; ?></td> <td width="100px"><?php echo $f11; ?></td> <td width="100px"><?php echo $f12; ?></td> <td width="100px"><?php echo $f13; ?></td> <td width="100px"><?php echo $f14; ?></td> <td width="100px"><?php echo $f15; ?></td> <td width="100px"><?php echo $f16; ?></td> <td width="100px"><?php echo $f17; ?></td> <td width="100px"><?php echo $f18; ?></td> <td width="100px"><?php echo $f19; ?></td> <td width="100px"><?php echo $f20; ?></td> <td width="100px"><?php echo $f21; ?></td> <td width="100px"><?php echo $f22; ?></td> <td width="100px"><?php echo $f23; ?></td> <td width="100px"><?php echo $f24; ?></td> <?php $i++; } ?> Once again thanks everyone at phpfreaks! hi i have table in my database holding food items. i need users to be able to order those items individually for example...if apples are third from the top..they should be able to move them up or down the list 1 place at a time perhaps with an up and down arrow. i have a field in my table called item_order the only problem is...users are going to be able to insert new items to the database...but i dont know how they can populate the order field...i cant set it to auto increment because the item_id is the primary key auto incrementing...how can i populate the order field? and then once i have this problem sorted how do i then allow users to change this order? im looking for code if possible please because ive spent WAY to long on this now and im struggling to grasp things people advise me to do. terminology and methods of accomplishing this are just going over my head. please help. I Have Taken The User_name In Session and i want to Make a Table as User_name as Prefix and When The User Logs in i want to show tht Table To the User !!!! in my mysql query, after the results have been grouped is there any way to count the results? i have a end result like this: 784 | x.x.x.x 754 | x.x.x.x 784 | x.x.x.x so how can i count the first column after its been grouped by IPs? here is my query: SELECT * FROM `hits`GROUP BY ip Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. Hi. I have the following code where I grab the names and average overall rating from my database and group by the name. Code: [Select] $sql="SELECT name, AVG(overall) AS overall FROM $tbl_name GROUP BY name ORDER BY AVG(overall) DESC"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ Does anybody know how I can count the number of names that have been grouped together? For instance: Name Overal ratingl John 2 Pete 5 John 8 It should group the john's, calculate the average rating (8+2)/2=5, and then show that there have been 2 johns making up the 5 rating? I've tried using the code below and messed around with it loads but cant get it to work: Code: [Select] $sql="SELECT name, AVG(overall) AS overall FROM $tbl_name COUNT name GROUP BY name ORDER BY AVG(overall) DESC"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ echo $rows['Count name']; Thanks in advance. I am trying to create a quick script to update all my products in my product table, I want to set a prodOrder starting at 1 and incrementing by 1 for each product in the catalogID group. eg if I have 12 product with a catalogID of 1 then I want to number the prodOrder for each product in my table 1-12 and so on for each catalogID group whats the best way to do this here is my starter code but no where near performing this function $sql=("SELECT * FROM product ORDER BY productID ASC GROUP BY catalogID"); $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $catID=$row['catalogID']; $id=$row['productID']; $value='1'; foreach ($catID AS $id => $value) { $qty=("UPDATE product SET prodOrder='$value' WHERE productID='$id'"); $change=mysql_query($qty); echo $row['name']." from $catID - order = $value<br/>"; $value++ } } Howdy, I'm trying to display text from a table in a database. It's a list of quotes, so I just need to pull out the quote and the author name. However, the quote and name are not fields in the same record; they are separate records. Example data: Code: [Select] quoteid name value 1 content You guys are great! Thanks for being awesome. 1 author John Jackson 2 content Gosh you're amazing! Always been so darn helpful! 2 author Peter Davis So, I just need to rip out the data from 'content' and 'author', and then group them together based on the quoteid. This is my code thus far: $testimonial_resource = mysql_query("SELECT name, value FROM quotes GROUP BY quoteid ORDER BY author ASC") or die(mysql_error()); while ($testimonial = mysql_fetch_assoc($testimonial_resource)) { echo '<p>'.$testimonial['value']'.<br /><strong>'.$testimonial['value'].'</strong></p>'; } Any help would be greatly appreciated for this novice. Cheers. I can add and delete data from my table. Now I need to be able to change one or more fields in an entry. So I want to retrieve a row from the db, display that data on a form where the user can change any field and then pass the changed data to an update.php program. I know how to go from form to php. But how do I pass the data from retrieve.php to a form so it will display? Do I use a URL and Get? Can I put the retrieve and form in the same program? Hey everyone. I am creating a website so my family can select from the list of present my daugther has asked for. I have them logging in, and that works. I have the table data set and the search and table display works. But I would like to display the list (as in the code below) but with a checkbox in the first column (add a column). From that the authenticated user can click on the item they have purchased and that selection will be moved to another table (called purchased). I have that code. The only thing I cannot figure out is to present the data in list form with a checkbox (like you would see on an order form). Here is the display code (there is no error checking at this point): <head><LINK REL="SHORTCUT ICON" HREF="cmwschl.ico"></head> <body bgcolor="#C0C0C0"> <font face="Arial" color="#000080">Books from the Selected Series</font> </h1> <hr font color="Navy" font size="3"> <center> <table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"> <tr> <td width="170" bgcolor="#FFCC66"><center><b><font color="navy" size="2" face="Trebuchet MS"><b><center>Book Number</center></font></b></center></td> <td width="140" bgcolor="#FFCC66"><center><b><font color="navy" size="2" face="Trebuchet MS"><b><center>Book Group</center></font></b></center></td> <td width="100" bgcolor="#FFCC66"><center><b><font color="navy" size="2" face="Trebuchet MS"><b><center>Book Title</center></font></b></center></td> </tr> <?php $con = mysql_connect("localhost","twilson","R00tb33r!") or die('Connection: ' . mysql_error());; mysql_select_db("CMWWeb", $con) or die('Database: ' . mysql_error()); ?> <? $group = $_POST['bookgrp']; //if ($Prod <> 0) { $sql = "SELECT * FROM `OpenBooks` WHERE `bookgrp`= '$group'"; $results = mysql_query($sql); if ($results) { //this will check if the query failed or not if (mysql_num_rows($results) > 0) { //this will check if results were returned while($copy = mysql_fetch_array($results)) { $variable1=$copy['booknum']; $variable2=$copy['bookgrp']; $variable3=$copy['booktitle']; //table layout for results print ("<tr>"); print ("<td><center>$variable1</center></td>"); print ("<td><center>$variable2</center></td>"); print ("<td><left>$variable3</left></td>"); print ("</tr>"); } } else { echo "No results returned"; } } else { echo "Query error: ".mysql_error(); } mysql_close($con); ?> </table> </center> Hi All,
I'm looking to update a mysql column weekly, where by 5 randomly selected rows are given a new random number, from between 1 and the num_rows / 5. This cycle is looped again until all the entries have a new random group for the week. It is to help mix up the players for teams for 5 aside. It needs to be able to accomodate the posibillity of the num_rows not dividing exactly by 5, using ceil perhaps?
As an example
Name Group
a 1
b 2
c 1
d 1
e 1
f 3
g 2
h 1
i 2
j 2
k 2
Then Next week
Name Group
a 2
b 1
c 2
d 2
e 1
f 2
g 3
h 1
i 2
j 1
k 1
I hope that makes sense. It'll be automated via cron job.
I've been really struggling with it, this is as far as I have got.
$totalgroupsraw = $num_rows /5; hello friends I'm dealing with this problem for two days. I put here the screenshot for easier understanding.Sorry about my bad english. Here is the ss http://i61.tinypic.com/2rz5q55.jpg I don't want to inner join or table join. All image links which same sku should displayed in single row where products.resimler colon I can join the tables but i want to one table.Because i can import single csv file for e-commerce script.How can I use a update query for list multiple images in table products. Edited by nogai, 10 October 2014 - 07:01 AM. the second database found on the cloud
i try to get JSON data but how to insert and update them to another online database with the same table my php script to return json data <?php include_once('db.php'); $users = array(); $users_data = $db -> prepare('SELECT id, username FROM users'); $users_data -> execute(); while($fetched = $users_data->fetch()) { $users[$fetchedt['id']] = array ( 'id' => $fetched['id'], 'username' => $fetched['name'] ); } echo json_encode($leaders);
i get
{"1":{"id":1,"username":"jeremia"},"2":{"id":2,"username":"Ernest"}} Edited March 24 by mahenda Hi all I am describing my problem below can any body please look into this I have two databases DB1:datain1 DB2:datain2 having the below structure database, table, fields datain1 , student , id,name datain2 , student , id,name the two databases having same structure My query is i want copy all data from datain1 to datain2 on daily process through php script(script will be executed manually on daily) i don't want any duplicate or repeated data in datain2 give me some script to do this kindly help me to solve this its so urgent Hi,
A little new to php programming... I have a question:
I have written this code:
<html> <head> <title>Test</title> </head> <FONT FACE="Verdana, sans-serif"> <H3>Movies</h3> <?php include 'config.php'; include 'opendb.php'; $result = mysql_query("SELECT * FROM DayMovie ORDER BY FileDate") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Filename</th><th>Path</th><th>Date</th><th>Filetype</th> <th>Size</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['FileName']; echo "</td><td>"; echo $row['FilePath']; echo "</td><td>"; echo $row['FileDate']; echo "</td><td>"; echo $row['FileType']; echo "</td><td>"; echo $row['FileSize']; echo "</td></tr>"; } echo "</table>"; include 'closedb.php'; ?>I would like to have a link to these files on all the rows to open the files. How can I do that? I would also like that the link from the mysql row is not shown in the table. Only a text with the text "link" or "view". Hi This may seem pretty standard to some of you but I am having a problem with tables. What I am trying to do is give the user 4 fields to choose from and depending upon which field they enter data into the php will query the mysql database and return all of the data related to that value and place it into a table. Seems fair enough however there could be multiple entries of that value and I want there to maybe be a loop that will check for the information and then when it is done complete the table. My code looks something like this: <html> <?php # Script 14.2 - course_form.php // This page allows the administrator to add a course (product). $con = mysql_connect("localhost","root","millennium"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Validate the print_name, image, artist (existing or first_name, last_name, middle_name), size, price, and description. // Check for a course id. if (!empty($_POST['IpAddress'])) { $ip = ($_POST['IpAddress']); } else { $ip = FALSE; } // Check for a course id. if (!empty($_POST['Identifier'])) { $id = ($_POST['Identifier']); } else { $id = FALSE; } // Check for a course id. if (!empty($_POST['Destination'])) { $de = ($_POST['Destination']); } else { $de = FALSE; } // Check for a course id. if (!empty($_POST['Reply'])) { $re = ($_POST['Reply']); } else { $re = FALSE; } // Add the course to the database. mysql_select_db("accs", $con); $result = mysql_query("SELECT * FROM smsaudit WHERE smsreply='$re' || smsorigip='$ip' || smsidentifier='$id' || smsdest='$de'"); $tdcount = 1; $numtd = 4; // number of cells per row echo "<table border='1'>"; while($row = mysql_fetch_array($result)) { if ($tdcount == 1) echo "<tr>"; echo "<td>IP Address: $ip </td>"; // display as you like echo "<td>Identifier: $id </td>"; echo "<td>Destination: $de </td>"; echo "<td>Reply: $re </td>"; if ($tdcount == $numtd) { echo "</tr>"; $tdcount = 1; } else { $tdcount++; } // time to close up our table if ($tdcount!= 1) { while ($tdcount <= $numtd) { echo "<td> </td>"; $tdcount++; } echo "</tr>"; } echo "</table>"; } echo "<br />"; $result2 = mysql_query("SELECT totalsms FROM smsaudit ORDER BY totalsms DESC LIMIT 1"); while($row = mysql_fetch_array($result2)) { echo 'You have used ' . $row['totalsms'] .' sms messages'; } } else { // Display the form. ?> <form action="form1.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288"> <p> </p> <table width="449" border="0"> <td><h1>SMS Information</h1></td> <td> </td> <td> </td> <td> </td> </tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td width="160"><strong>IP Address</strong></td> <td width="95"> </td> <td width="167"><strong>Identifier</strong></td> </tr> <tr> <td><input name="IpAddress" type="text" id="IpAddress" /></td> <td> </td> <td><input name="Identifier" type="text" id="Identifier" /></td> <td width="9"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><strong>Destination</strong></td> <td> </td> <td><strong>Reply</strong></td> <td> </td> </tr> <tr> <td><input name="Destination" type="text" id="Destination" /></td> <td> </td> <td><input name="Reply" type="text" id="Reply" /></td> <td> </td> </tr> <tr> <td><input type="submit" name="Submit" id="Submit" value="Submit" /></td> <td> </td> <td> </td> <td> </td> </tr> </table> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php } // End of main conditional. ?> </html> Can anyone please let me know of a way to achieve this? Thanks First I need to create a table or add to an existing table - the table needs to contain a date -msg last sent date Then run the following email script for each record if the value of the msg last sent date is greater than >30 days??? after the script is run, it updates the records it emailed to todays date... <?php include "vsadmin/db_conn_open.php"; $allprods=mysql_query("select pID, pName, pPrice, pDropship, dsID, dsName, dsEmail from products, dropshipper where pDropship = dsID"); while ($yarr=mysql_fetch_assoc($allprods)){ $aname=$yarr["pID"]; $bname=$yarr["pName"]; $cname=$yarr["dsName"]; $dname=$yarr["dsEmail"]; $ename=$yarr["pPrice"]; $to = $dname; $subject = ("Your Ebook: " . $bname); $body = ("Hello " . $cname .",\n\nYou have the following ebook listed for sale on www.insertwebsite.com (". $bname ."). \nYour Ebook (product) is currently listed at the retail price of $" . $ename . "\n\nThe following link is provided to you as a marketing tool for your current or future email campaigns. This link is a direct link to your ebook on the Enlightened Ebooks site. \n www.www.insertwebsite.com/proddetail.php?prod=". $aname . "\n\nOnline sales is a safe secure way to increase your ebook sales. Simply provide the link in all your correspondences and you sales will increase. You are your own best promoter."); $headers = "From: neil@me.com\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo("<p><b>Message sent to.</b></P>". $cname . " for the following ebook " . $bname ); } else { echo("<p>Message delivery failed...</p>"); }} ?> What I'm wanting to do is instead of March-July have it always display the last 5 months and for the Visits th have it display the number of hits to my main page for each month and display the number of logins for each month to my CMS script. Can someone point me in the right direction? Code: [Select] <?php function get_visit_data_table() { echo "<table class=\"visualize_dashboard\">"; echo "<caption>Dashboard Chart Example</caption>"; echo "<thead>"; echo "<tr>"; echo "<td></td>"; echo "<th scope=\"col\">March</th>"; echo "<th scope=\"col\">April</th>"; echo "<th scope=\"col\">May</th>"; echo "<th scope=\"col\">June</th>"; echo "<th scope=\"col\">July</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; echo "<tr>"; echo "<th scope=\"row\">Visits</th>"; echo "<td>175</td>"; echo "<td>145</td>"; echo "<td>212</td>"; echo "<td>175</td>"; echo "<td>182</td>"; echo "</tr>"; echo "<tr>"; echo "<th scope=\"row\">Logins</th>"; echo "<td>94</td>"; echo "<td>53</td>"; echo "<td>124</td>"; echo "<td>92</td>"; echo "<td>105</td>"; echo "</tr>"; echo "</tbody>"; echo "</table>"; } ?> |