Hi All,
I have been trying to solve this puzzle all day and just can not see what to do.
My SQL statement below produces what I want, and I am able to create my HTML table
exactly as I want with one problem. I have option menus, but can not figure out how
to get the </option> to appear only after the last selection.
Here is my SQL statement which is fine, and produces this from the command line:
SELECT license_main.title, license_options.option_code, license_options.option_title,
license_price.price, license_main.license_id, license_main.text_id
FROM license_main, license_options, license_price, track_descriptions
WHERE license_main.license_id = license_options.license_id
AND license_options.option_id = license_price.option_id
AND track_descriptions.record_id = '106'
AND license_price.price_class = track_descriptions.price_class
ORDER BY license_main.sort, license_options.sort
+--------------------------+-------------+------------------+-------+------------+----------+
| title | option_code | option_title | price | license_id | text_id |
+--------------------------+-------------+------------------+-------+------------+----------+
| Corporate & Trade Shows | BIZ1 | Single Use | 27.5 | 1 | biz |
| Corporate & Trade Shows | BIZ2 | Unlimited | 55 | 1 | biz |
| Products for Sale | SALE1 | 50,000 Units | 100 | 9 | sale |
| Products for Sale | SALE2 | 100,000 Units | 150 | 9 | sale |
| Products for Sale | SALE3 | 500,000 Units | 200 | 9 | sale |
| Products for Sale | SALE4 | 1 Million Units | 300 | 9 | sale |
| Products for Sale | SALE5 | 2 Million Units | 400 | 9 | sale |
| Products for Sale | SALE6 | Unlimited Units | 450 | 9 | sale |
| Free & Promo Items | GA_RATE1 | 2000 Units | 27.5 | 10 | giveaway |
| Free & Promo Items | GA_RATE2 | 50,000 Units | 55 | 10 | giveaway |
| Free & Promo Items | GA_RATE3 | 100,000 Units | 75 | 10 | giveaway |
| Free & Promo Items | GA_RATE4 | 500,000 Units | 95 | 10 | giveaway |
| Free & Promo Items | GA_RATE5 | 1 Million Units | 115 | 10 | giveaway |
| Internet | NET1 | Single Use | 27.5 | 4 | net |
| Internet | NET2 | Unlimited | 55 | 4 | net |
| Television Show | TV_SHOW_LOC | Local | 27.5 | 11 | tv_show |
| Television Show | TV_SHOW_MM | Major Market | 55 | 11 | tv_show |
| Television Show | TV_SHOW_NAT | National | 150 | 11 | tv_show |
| Television Show | TV_SHOW_WW | World Wide | 200 | 11 | tv_show |
| TV Commercials & Promos | TV_COMM_LOC | Local | 35 | 7 | tv_comm |
| TV Commercials & Promos | TV_COMM_REG | Regional | 55 | 7 | tv_comm |
| TV Commercials & Promos | TV_COMM_NAT | National | 200 | 7 | tv_comm |
| TV Commercials & Promos | TV_COMM_WW | World Wide | 300 | 7 | tv_comm |
| Project Films & Shorts | PROJECT | Project Film | 55 | 2 | project |
| On-Hold & In-House | BGOH1 | 1 Local | 27.5 | 5 | on_hold |
| On-Hold & In-House | BGOH2 | 5 Locals | 55 | 5 | on_hold |
| On-Hold & In-House | BGOH3 | 10 Locals | 75 | 5 | on_hold |
| Live Public Performances | PUBLIC | Live Performance | 35 | 3 | public |
| Radio Broadcast | RADIO_LOC | Local | 27.5 | 6 | radio |
| Radio Broadcast | RADIO_REG | Regional | 55 | 6 | radio |
| Radio Broadcast | RADIO_NAT | National | 100 | 6 | radio |
| Radio Broadcast | RADIO_WW | World Wide | 150 | 6 | radio |
| Major Motion Picture | FILM | Motion Picture | 450 | 12 | movie |
| Academic License | ACDMC | Academic | 27.5 | 8 | academic |
+--------------------------+-------------+------------------+-------+------------+----------+
So far so good, now I want to make a table in HTML as such,
will use first 2 results for example (The None value is hard coded):
<tr><td>Corporate & Trade Shows</td><td><option value=>None
<option value= BIZ1>Single Use - $27.50
<option value= BIZ2>Unlimited - $55.00
</option></td></tr>
I am fine up to </option></td></tr>, which is where I am getting into trouble.
To display Corporate & Trade Shows only once in the first column, I put
$last_license_id = $license_id; at the end of my while loop,
then if that is not the same, I echo
the left side of my HTML table.
The problem is, I need to put </option></td></tr> after the last option selection
available, and just can not figure out how to do so as of yet.
Here is what I have for my while loop, all is well but no end of table data and row or </option>
<?
while ($row = mysql_fetch_array($sql_result)) {
$license_title = $row["title"];
$text_id = $row["text_id"];
$option_code = $row["option_code"];
$option_title = $row["option_title"];
$license_id = $row["license_id"];
$price = $row["price"];
$fmt_price = sprintf("%0.2f",$price);
if ($last_license_id != $license_id) {
echo "
<tr>
<td align=right valign=middle><a href=license_options.php?text_id=$text_id target=license_text>
<font face=Arial,Helvetica,Geneva,Swiss,SunSans-Regular size=2>
$license_title</font></a></td>
<td><font face=Arial,Helvetica,Geneva,Swiss,SunSans-Regular size=2>:</font></td>
<td><font face=Arial,Helvetica,Geneva,Swiss,SunSans-Regular size=2> </font></td>
<td><select name=$text_id size=1>
<option value=>None
";
}
echo "<option value=$option_code>$option_title - \$$fmt_price";
//EVERYTHING FINE TO HERE, BUT NEED</option></td></tr> after last
$last_license_id = $license_id;
}
?>
I tried this if statement placed above where you see EVERYTING FINE TO.. but obviously it is wrong:
if ($last_license_id != $license_id) {
echo "</option></td></tr>";
}
That produces this incorrect mess on the screen:
<option value=>None
<option value= BIZ1>Single Use - $27.50
</option></td></tr>
<option value= BIZ2>Unlimited - $55.00
</option></td></tr>
What I need to produce is this:
<option value=>None
<option value= BIZ1>Single Use - $27.50
<option value= BIZ2>Unlimited - $55.00
</option></td></tr>
This example has two choices. Some have only one, while others have many.
Any help would be greatly appreciated. Sorry if this has been answered before,
I also could not figure out what to call it to search for.
Thank you all,
Mark