I am keenly aware that my coding skills are extremely noob but please indulge me a second.. Take a look at these queries.. - $sql = "SELECT DISTINCT year FROM _current_floats_config WHERE active = 'yes' ORDER BY year DESC LIMIT 2, 1";
-
$result = mysql_query($sql);
-
while($fetched = mysql_fetch_array($result)) {
-
$ceiling = $fetched["year"];
-
}
-
$sql = "SELECT * FROM _current_floats WHERE active = 'yes' AND yearID <= $ceiling ORDER BY yearID DESC, name ASC";
As you can see in the first $sql query I'm ordering the query DESC and skipping the first two distinct results. This is because my client wants to features the first two years in the site's navigation. So we pick up the query at result 2 and assign the var $ceiling to the result.
I'm then creating another $sql query selecting all results in DESC order less than or equal to $ceiling.
What I need to do now is group these results by years, like this below:
2006
result, result, result, result, result, result, result, result, result
2005
result, result, result, result, result, result, result, result, result
2004
result, result, result
2003
result, result, result, result, result, result
etc, etc..
Here's the snippet that returns all the results without grouping them by year.. - $display = 3;
-
$cols = 0;
-
$sql = "SELECT DISTINCT year FROM _current_floats_config WHERE active = 'yes' ORDER BY year DESC LIMIT 2, 1";
-
$result = mysql_query($sql);
-
while($fetched = mysql_fetch_array($result)) {
-
$ceiling = $fetched["year"];
-
}
-
$sql = "SELECT * FROM _current_floats WHERE active = 'yes' AND yearID <= $ceiling ORDER BY yearID DESC, name ASC";
-
echo $sql."<br /><br />";;
-
$result = mysql_query($sql);
-
if (mysql_num_rows($result) > 0 ) {
-
-
/* while($fetched = mysql_fetch_array($result)) {
-
echo $fetched["yearID"]."<br />";
-
} // end WHILE statement
-
} else { echo "Ooops!"; } // end IF statement
-
-
*/
-
echo "<table width='100%' border='0' cellspacing='10' cellpadding='0' style='padding:10px;'>";
-
-
//$num = 1;
-
while($fetched = mysql_fetch_array($result)){
-
$num = $fetched["ID"];
-
if($cols == 0){
-
echo "<tr>\n";
-
}
-
// put what you would like to display within each cell here
-
-
if (((!empty($fetched["rendering"])) AND (!empty($fetched["rendering2"]))) OR ((!empty($fetched["rendering"])) AND (!empty($fetched["parade_pic"]))) OR ((!empty($fetched["parade_pic"])) AND (!empty($fetched["parade_pic2"])))) {
-
-
echo "<td valign=\"top\" align=\"center\" width=\"33%\"><h1 style=\"font-size:96%;\"><a title=\"$fetched[name]\" href=\"current.php?year=$fetched[yearID]&id=$fetched[ID]\">$fetched[name]</a></h1><br /><script type=\"text/javascript\">new fadeshow(fadeimages".$num.", 150, 150, 0, 5000, 0)</script></td>\n";
-
$cols++;
-
} elseif (!empty($fetched["rendering"])) {
-
echo "<td valign=\"top\" align=\"center\" width=\"33%\"><h1 style=\"font-size:96%;\"><a title=\"$fetched[name]\" href=\"current.php?year=$fetched[yearID]&id=$fetched[ID]&viewing=rendering\">$fetched[name]</a></h1><img class=\"reflect ropacity25 rheight15\" alt=\"$fetched[name]\" src=\"dynamic/images/show_image.php?filename=$fetched[rendering]&width=150&height=150\"></td>\n";
-
$cols++;
-
} elseif (!empty($fetched["parade_pic"])) {
-
echo "<td valign=\"top\" align=\"center\" width=\"33%\"><h1 style=\"font-size:96%;\"><a title=\"$fetched[name]\" href=\"current.php?year=$fetched[yearID]&id=$fetched[ID]&viewing=parade_pic\">$fetched[name]</a></h1><img class=\"reflect ropacity25 rheight15\" alt=\"$fetched[name]\" src=\"dynamic/images/show_image.php?filename=$fetched[parade_pic]&width=150&height=150\"></td>\n";
-
$cols++;
-
} else {
-
echo "<td valign=\"top\" align=\"center\" width=\"33%\"><h1 style=\"font-size:96%;\"><a title=\"$fetched[name]\" href=\"current.php?year=$fetched[yearID]&id=$fetched[ID]\">$fetched[name]</a></h1><img class=\"reflect ropacity25 rheight15\" alt=\"$fetched[name]\" src=\"dynamic/images/show_image.php?filename=none.jpg&width=150&height=150\"></td>\n";
-
$cols++;
-
}
-
if($cols == $display){
-
echo "</tr>\n\n";
-
$cols = 0;
-
}
-
-
} // end IF statement
-
-
// added the following so it would display the correct html
-
if($cols != $display && $cols != 0){
-
$neededtds = $display - $cols;
-
for($i=0;$i<$neededtds;$i++){
-
echo "<td> </td>\n";
-
}
-
echo "</tr>\n</table>\n";
-
} else {
-
echo "</table>\n";
-
-
} // end WHILE statement
-
-
//
-
// THERE ARE NO RESULTS FOR THE GIVEN YEAR
-
//
-
-
-
} else { echo "<p style=\"font-size:2.4em;color:#FF0C12;margin-bottom:-25px;\">Oops!</p><p>We couldn't find any floats in our database beyond the past two years.</p><p>You can check back later or select a year under the <strong>Our Floats</strong> heading on the left to continue.</p>"; }
-
-
}
Can someone steer me in the right direction? Thanks!
1 2000
Anyone, Bueller.. Bueller?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mike |
last post by:
I am sure that I am making a simple boneheaded mistake and I would
appreciate your help in spotting in. I have just installed
apache_2.0.53-win32-x86-no_ssl.exe
php-5.0.3-Win32.zip
Smarty-2.6.7.tar.gz
on a system running WindowsXP SP2.
Apache and PHP tested out fine. After adding Smarty, I ran the
following http://localhost/testphp.php
|
by: wxbuff |
last post by:
I have a report based on our product names that consists of two parts.
Both insert data into a temporary table.
1. A single grouped set of results based on all products
2. Multiple tables based on individual product names.
I am getting data by calling the same stored procedure multiple
times... for the single set of data I use "product like '%'"
To get the data for individual products, I am using a cursor to parse
|
by: Terri |
last post by:
I have a table called Transactions with 3 fields: ID, Date, and Amount. Each
ID can have multiple transactions in one particular year. An ID might not
have had any transactions in recent years.
For each ID I would like to sum all the transactions for the most recent
year in which one or more transactions have occurred.
Thanks for any help and for all previous help.
|
by: SueB |
last post by:
Greetings. I have a report based on the following query (hang in there
... it's quite long):
SELECT Year(.) AS Yr, tblEvents.eventID,
tblEvents.eventname, tblEvents.eventhost, tblEvents.eventcity,
tblEvents.eventstate, tblEvents.eventstartdt, tblEvents.eventenddt,
tblTrials.trialnbr, tblTrials.trialdt, tblTrialClass.trialclassID,
tblClasses.class, tblScores.score, tblScores.level, .
& (" "+.+".") & " " & . & ("
"+.+".") & " (" & . & ",...
|
by: name |
last post by:
The piece of code is for a Web Form Page. Who can tell me why? Thanks a lot!
------------------------------------------------
VB.Net Code:
Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
If (TypeOf obj Is LiteralControl) Then
Dim lc As LiteralControl = obj
Dim text As String = lc.Text.ToLower()
| |
by: Steve Franks |
last post by:
Can someone please recommend a good way in ASP.NET 1.1 to dynamically create
a HTML table to display some results I have in local variables?
For example, I want my HTML output to look like this:
Magazines (table header)
avg price: 4.50
total sold: 200
left in stock: 130
|
by: Rob Meade |
last post by:
Hi all,
I'm working on a project where there are just under 1300 course files, these
are HTML files - my problem is that I need to do more with the content of
these pages - and the thought of writing 1300 asp pages to deal with this
doesn't thrill me.
The HTML pages are provided by a training company. They seem to be
"structured" to some degree, but I'm not sure how easy its going to be to
parse the page.
|
by: Sebastian |
last post by:
Hello all
I have a report where I have two nested groups.
I know there are only three standard options for running sum: None,
Over Group and Over All.
I have a MyTextBox in detail section where the data is summed over
group.
But the data is summed over the second group. When a new group begins
MyTextBox value is resetting to zero. I need a running sum over the
first group so when another second group begins MyTextBox value will
|
by: KTosser |
last post by:
I have two tables, one contains contacts and the other has all the
events and years that the contacts participated in. What I want is to
be able to choose the years, say 2005 and 2006, and get all the
contacts that attended in both 2005 and 2006.
Table1
ContactID ContactName
1 John
2 Bob
3 Amy
|
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...
|
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,...
| |
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |