I'm using ODBC to read a office access db
the db have almost 10,000 rows so I want to split it into pages
The first page load nice and quick, but in other pages i get: - Maximum execution time of 30 seconds exceeded in c:\apache\htdocs\eyal\new.php on line 100
the line 100 is the odbc_exec command.
in the top of the page i get: -
Warning: Use of undefined constant id - assumed 'id' in c:\apache\htdocs\eyal\new.php on line 7
-
Warning: Use of undefined constant pname - assumed 'pname' in c:\apache\htdocs\eyal\new.php on line 8
-
Warning: Use of undefined constant lname - assumed 'lname' in c:\apache\htdocs\eyal\new.php on line 9
-
Warning: Use of undefined constant addr - assumed 'addr' in c:\apache\htdocs\eyal\new.php on line 10
-
Warning: Use of undefined constant city - assumed 'city' in c:\apache\htdocs\eyal\new.php on line 11
-
Warning: Use of undefined constant phone - assumed 'phone' in c:\apache\htdocs\eyal\new.php on line 12
-
Warning: Use of undefined constant cphone - assumed 'cphone' in c:\apache\htdocs\eyal\new.php on line 13
-
Warning: Use of undefined constant jdate - assumed 'jdate' in c:\apache\htdocs\eyal\new.php on line 14
the lines: -
$fields = array(id => "מספר כרטיס",
-
pname => "שם פרטי:",
-
lname => "שם משפחה:",
-
addr => "כתובת:",
-
city => "עיר מגורים:",
-
phone => "מספר טלפון:",
-
cphone => "מספר פלאפון:",
-
jdate => "תאריך הצטרפות:");
-
the main of my code: -
switch ($do) {
-
case "list":
-
if ($page > 0) {
-
$npage = $page + 1;
-
$ppage = $page - 1;
-
}
-
else {
-
$page = 0;
-
$npage = 1;
-
}
-
$gpage = $page * 50;
-
print("<table dir=\"rtl\" cellspacing=0 cellpadding=5>
-
<tr dir=\"rtl\">");
-
foreach ($fields as $key => $value) {
-
$value = str_replace(":", " ", $value);
-
print("<th class=main>$value</th>");
-
}
-
print("<th class=endmain>ניהול</th>
-
</tr>");
-
if ($gpage == 0) {
-
$sql_query = "SELECT TOP 50 * FROM tbl_clients";
-
}
-
else {
-
$sql_query = "SELECT TOP 50 * FROM tbl_clients where ( ID NOT IN ( SELECT TOP $gpage id FROM tbl_clients ORDER BY id ASC ) ) ORDER BY id ASC";
-
}
-
$do_query = odbc_exec($conn, $sql_query);
-
while (odbc_fetch_row($do_query)) {
-
print("<tr>");
-
foreach ($fields as $key => $value) {
-
$text = odbc_result($do_query,$key);
-
if ($key == "id") { $text = round($text); }
-
if($key == "jdate") { $text = ereg_replace(" 00:00:00" , "", $text); }
-
print("<td class=main> $text</td>");
-
}
-
print("<td class=endmain> " . dolink("$_SERVER[PHP_SELF]?do=edit", "עריכה"));
-
print("</tr>");
-
}
-
print("<tr>");
-
if (empty($page) OR !isset($page)) {
-
$form = $_SERVER['QUERY_STRING'];
-
if ($page == 0) {
-
$form = ereg_replace("page=0", "page=$npage", $form);
-
-
}
-
else {
-
$form .= "&page=1";
-
}
-
echo $form;
-
print("<td>");
-
pp($form, "next");
-
print("</td>");
-
}
-
else {
-
if ($page > 0) {
-
$form = $_SERVER[QUERY_STRING];
-
$form = ereg_replace("page=$page", "page=$ppage", $form);
-
print("<td>");
-
pp($form, "prev");
-
print("</td>");
-
}
-
print("<td> </td>");
-
if (($page > 0) AND ($page < $count)) {
-
$form = $_SERVER[QUERY_STRING];
-
$form = ereg_replace("page=$page", "page=$npage", $form);
-
print("<td>");
-
pp($form, "next");
-
print("</td>");
-
}
-
}
-
print("</tr>");
-
doexit();
-
}
-
Help
Thanks :)
5 2240
That helps, thanks.
But why is it taking so long (about 3 min) for the page to load?
I don't think it's my comp... duel core with 2gb ram...
maybe something in the code?
Atli 5,058
Expert 4TB
Hi.
First, your array keys are defined incorrectly. Assuming they are meant to be strings, they should be quoted. -
// This is incorrect. It will try to load the value for the
-
// constant named id, but if it fails to find it, it will
-
// assume it was meant to be a string and show a warning.
-
$arr = array(id => 'some value');
-
-
// This is how it should be done
-
$arr = array('id' => 'some value'); //Correct
-
As to the execution time, I would assume it is database related. The PHP code itself should not take anywhere near that long to execute.
The SQL query, however, could be taking some time on a large table. Especially if that table was not designed for such a query on a large amount of data.
How to fix such a problem I do not know. I don't know enough about Access to really know that. Maybe it has something to do with the sub-query? I know they can cause performance issues on other SQL servers.
Thanks, it solved my array error.
Do you know another way for me to use instead of sub-query?
I searched google alot to find this solution for paging in mssql.
Okay do I decided to do the page system the "long" way: selecting all the db and just printing the "right" page.
The problem now is that It's skipping rows (id 1, 3, 5, 7 and so on)
Here's the code: -
if ($page > 0) {
-
$npage = $page + 1;
-
$ppage = $page - 1;
-
}
-
else {
-
$page = 0;
-
$npage = 1;
-
}
-
$gpage = $page * 50;
-
print("<table dir=\"rtl\" cellspacing=0 cellpadding=5>
-
<tr dir=\"rtl\">");
-
foreach ($fields as $key => $value) {
-
$value = str_replace(":", " ", $value);
-
print("<th class=main>$value</th>");
-
}
-
print("<th class=endmain>ניהול</th>
-
</tr>");
-
$sql_query = "SELECT * FROM tbl_clients ORDER BY id ASC";
-
$do_query = odbc_exec($conn, $sql_query);
-
$target = $gpage + 50;
-
$row_count = 0;
-
while (odbc_fetch_row($do_query)) {
-
if ($row_count < $gpage) {
-
$row_count++;
-
continue;
-
}
-
else {
-
if ($gpage < $target) {
-
print("<tr>");
-
foreach ($fields as $key => $value) {
-
$text = odbc_result($do_query,$key);
-
if ($key == "id") { $text = round($text); }
-
if($key == "jdate") { $text = ereg_replace(" 00:00:00" , "", $text); }
-
print("<td class=main> $text</td>");
-
}
-
print("<td class=endmain> " . dolink("$_SERVER[PHP_SELF]?do=edit", "עריכה"));
-
print("</tr>");
-
$gpage++;
-
}
-
else if ($gpage > $target) {
-
break;
-
}
-
}
-
}
-
Why?
Thanks :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: WindAndWaves |
last post by:
Hi Gurus
I am keen to make a search page on a website, but I have absolutely zero
experience with PHP. I am going to hire an expert, but I thought that it
may pay to try it a bit first myself...
|
by: Wolfgang Kaml |
last post by:
Hello All,
I have been working on this for almost a week now and I haven't anything up
my sleeves anymore that I could test in addition or change....
Since I am not sure, if this is a Windows...
|
by: Paul Robinson |
last post by:
I am developing a website in ASP that connects to a Sybase database.
However, when I try to open a connection to the database the page will not
load. The script does not timeout, nor the...
|
by: Eirik Tryggeseth |
last post by:
During deployment of an application using distributed transactions managed
under COM+ on an Oracle 9i RAC database, we encounter situations where the
load balancing mechanisms in the RAC result in...
|
by: martin |
last post by:
Hi,
I am a web page and a web user control. My web user control is placed in my
web page using the following directive
<%@ Register TagPrefix="uc1" TagName="Header"...
|
by: J-T |
last post by:
Hi All,
There is a picture on the following URL which I want to have it in one of
my asp.net pages .I mean I want to embed the content of this page in my own
page and get its image.Is there a...
|
by: abcd |
last post by:
I have asp.net web page written in C# it works great on Windows XP. Now I am
testing that on Windows 2K. For that I have set a virtual machine and it has
W2K with SP4 and .net runtime ...
The...
|
by: frizzle |
last post by:
Hi there,
I need a function to prevent a page from being loaded too often too
fast.
So say, one is only allowed to refresh a single page 5 times in 10
seconds, or 10 times in 5 seconds (or...
|
by: Harmony504 |
last post by:
HELP!
Setup: PHP5.2.5, IIS 5.1, XP, AS/400 (DB/400 or DB2)
I am trying to connect to a DB2 database from my computer. I installed DB2 Connect and set up the ODBC Driver in the Data Source...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
| |