PDA

View Full Version : MySQL - PHP output shipping table


rayzun
12-18-2005, 10:20 PM
Anyone could help me with a query to my table to output a shipping table / rate / based on current day.

(product)
ITEM FRI SAT MON TUE WED THU

IF200 8.95 8.95 8.95 8.95 8.95 8.95
IF700 2.95 2.95 2.95 2.95 2.95 4.95
...
Above is my most basic table with the cost of shipping for a item for any given day.

Im looking to query table "product" for the item first, then in a rolling fashion
show the rate for that day - starting from the current day
E.G.
If today was WEDNESDAY:
WED 8.95
THU 8.95
FRI 8.95

The end result will also have the result in calendar format

E.G.
If today was WEDNESDAY, DECEMBER 21:
DECEMBER 21 WED - $8.95
DECEMBER 22 THU - $8.95
DECEMBER 23 FRI - $8.95


I could make different tables and cross-query type stuff, BUT
anyone who has had experience in building such a database...
suggestions are really needed??

Velox Letum
12-18-2005, 11:01 PM
<?php

// Connect to MySQL

$p_query = mysql_query('SELECT * FROM items WHERE item = "IF700"');

$p_result = mysql_fetch_assoc($p_query);

echo 'Monday - $' . $p_result['mon'];
?>

This would print out the value of the mon column in the items table where the item is IF700. You can modify the rest to your liking to produce tables or whatever, but this is the basic concept. But what do you mean by the current day? Just that day and the ones after it?

rayzun
12-19-2005, 02:14 AM
Hey thanx


But what do you mean by the current day?
Just that day and the ones after it?

Sort of ...



The code is not quite the answer because the current date should be the starting point.


$p_query = mysql_query('SELECT * FROM items WHERE item = "IF700"');

$p_result = mysql_fetch_assoc($p_query);

echo 'Monday - $' . $p_result['mon'];
echo 'Tuesday - $' . $p_result['tue'];
echo 'Wednesday - $' . $p_result['wed'];
echo 'Thursday - $' . $p_result['thu'];
echo 'Friday - $' . $p_result['fri'];
echo 'Saturday - $' . $p_result['sat'];
?>

?>