[SOLVED]Request help with better dbcalltoreduceloading time
Posted: Fri Oct 13, 2006 6:15 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello @all
I'm working on a calendar for wherein the dates act as products.
So when i click on a date was is setted as an event , it will be added to the shoppingcart basket.
This part i have working , except the problem is that it load all dates out of the database @once.
I dont now how to make a better call to the database.
It should give me only the results of the current month's entrys.
i post below my full code for this page , and i really would apreciate the help.
please keep in mind that i will also have to add in short time a extra value that it go look up to what main/aditional product this date belongs to.
This part ive not made yet:
a live example can seen here:
http://www.inteladd.com/modules.php?nam ... e=productsCode: Select all
define('INDEX_FILE', true);
require_once("mainfile.php");
require_once("source/activecalendar.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
global $db;
$myurl= 'modules.php?name=Fly_to_Basket&file=products'; // the links url is this page
$yearID=false; // GET variable for the year (set in Active Calendar Class), init false to display current year
$monthID=false; // GET variable for the month (set in Active Calendar Class), init false to display current month
$dayID=false; // GET variable for the day (set in Active Calendar Class), init false to display current day
extract($_GET);
$products_id = $_GET['products_id'];
$products_id = preg_replace("/[^\d]/si","",$products_id);
$cal=new activeCalendar($yearID,$monthID,$dayID);
$eventID="event"; // sets the name of the generated HTML class on the event day (css layout)
$result = $db->sql_query("SELECT UNIX_TIMESTAMP(calendar_date) AS calendar_date, calendar_id, calendar_price, did FROM calendar");
OpenTable();
while ($row = $db->sql_fetchrow($result, MYSQL_BOTH)){
$products_id = $row["calendar_id"];
$calendar_price = $row['calendar_price'];
$mysqlDay=date("j",$row["calendar_date"]); // makes a day out of the database date
$mysqlMonth=date("n",$row["calendar_date"]); // makes a month out of the database date
$mysqlYear=date("Y",$row["calendar_date"]); // makes a year out of the database date
$mysqlContent= $row["did"]; // gets the event content
//$mysqlLink=$row[$tblLink]; // gets the event link
$mysqlLink = "#\" onclick=\"addToBasket('$products_id');return false;"; // the name of your MySQL Table Link Field
//$cal->setEvent($mysqlYear,$mysqlMonth,$mysqlDay,$eventID); // set the event, if you want the whole day to be an event
$cal->setEventContent($mysqlYear,$mysqlMonth,$mysqlDay,$mysqlContent,$mysqlLink); // set the event content and link
$cal->enableMonthNav($myurl);
?>
<script type="text/javascript" src="modules/Fly_to_Basket/js/ajax.js"></script>
<script type="text/javascript" src="modules/Fly_to_Basket/js/fly_to_basket.js"></script>
<?php
echo"<div id=\"slidingProduct_$products_id\">";
echo "</div>";
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]