Re: [PHP-DB] first 10 or so words
Or rather SUBSTRING_INDEX(str,delim,count) Because you want to use a custom delimiter (space, comma) Ignatius - Original Message - From: Peter Lovatt [EMAIL PROTECTED] To: Bruce Levick [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 13, 2003 11:40 PM Subject: RE: [PHP-DB] first 10 or so words try SUBSTRING http://www.mysql.com/doc/en/String_functions.html Peter -Original Message- From: Bruce Levick [mailto:[EMAIL PROTECTED]] Sent: 13 February 2003 22:23 To: [EMAIL PROTECTED] Subject: [PHP-DB] first 10 or so words Howdy, I have a SELECT query displaying the results in repeated rows in a table. I have a COMMENTS column coming out of the database table which will likely contain a paragraph of information. I would like to display only the first 10 or so words and then have a more link that people can click on to display all the info. Is there a simple method for this?? Cheers -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] The lists commands?
If you go the lists page (www.php.net/mailing-lists.phpand) there is a HERE link to get the command for managing your mailing list options. This link gives you a 404 error. There is an optional email address given that is supposed to cause the server to email back the commands, but instead it sends you a general help response, telling you to send email to the *same* address to get the commands. Which I did, which got me the same general help file. All I want to do is change my parameters so that I get the mailing list as all text, no attachments. Can someone tell me how to do that please? :) Brett -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL problem -- new to PHP
Thanks for all the help everyone sent me on this. However, nothing seems to make any difference whatsoever (except putting the 'localhost' part in quotes). I am still getting permission denied errors based on the user credentials. I have entered a user into the user table with host='localhost', user='php' and a password. I have entered these credentials into the db table also, and given the various privileges for this user to the specific database. I have run both mysqladmin reload and mysqladmin flush-privileges. I have even rebooted the machine. I have also tried typing GRANT SELECT,INSERT,DELETE,UPDATE TO php@localhost IDENTIFED BY ***, but this just throws up an error at the MySQL prompt. My PHP page can still not connect to the database. It just says: MySQL Connection Failed: Access denied for user: 'php@localhost' (Using password: YES) I know the problem is a permissions thing, because if I connect to the test database as 'nobody', there is no problem. Again, any and all help will be appreciated. This is ridiculously frustrating, especially since I have no problem connecting to the database from a perl script. I am tempted to stop trying to learn PHP and build my entire web site using perl cgi instead. Thanks Evan Morris [EMAIL PROTECTED] Tel: +27 11 792 2777 Fax: +27 11 792 2711 Cell: +27 82 926 3630 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How to access a MS Access DB
to set up a DSN go to control panel and then Administrative Tools then into Data Sources and then add a new system DSN. you can probably work the rest out as its fairly straight forward. -Original Message- From: Jonathan Villa [mailto:[EMAIL PROTECTED]] Sent: 13 February 2003 22:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] How to access a MS Access DB I need to know exactly how to hook up to an Access database under Office Xp. I normally use MySQL, but the current site sits on Windows servers. I am using php 4.3.0 Office Xp Pro w/ Access I'm running Apache 2.0.43 I need to know how to check if ODBC is set up on my machine (I hear that by default it is) and what's this about a driver? All I know at this point is odbc_connect(XXX,username,password); Where XX is the DSN name I will be using, (how do this, i.e. set up a DSN name) Thanks much and in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: TXT files with fixed width
[EMAIL PROTECTED] (Pedro Oliveira) writes: I need to import a fixed width txt to a my sql database, I know how to do that with a coma separated value. any1 knows how i can do this easilly or know some software to do this? any help would be appreciated. *nix or windows? If the file is tab separated, I guess you can use excel or something and export it to comma separated. On *nix, you have an abundance of utilities, e.g. tr(1). When you say fixed width, I guess it's not tab separated, however, maybe: # 345678901234567890123456789012345678901234567890 word1word2 word3 someword4 another5 or something like that. Then you can e.g. use perl (or for that sake PHP) and the substr function to parse the data and spit them out either in sql, directly into the database or comma separated (or in whichever format you desire). -- --Fredrik Subtlety is the art of saying what you think and getting out of the way before it is understood. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL problem -- new to PHP
On Fri, 14 Feb 2003 11:30:03 +0200 [EMAIL PROTECTED] (Evan Morris) wrote: Thanks for all the help everyone sent me on this. However, nothing seems to make any difference whatsoever (except putting the 'localhost' part in quotes). I am still getting permission denied errors based on the user credentials. I have entered a user into the user table with host='localhost', user='php' and a password. I have entered these credentials into the db table also, and given the various privileges for this user to the specific database. I have run both mysqladmin reload and mysqladmin flush-privileges. I have even rebooted the machine. I have also tried typing GRANT SELECT,INSERT,DELETE,UPDATE TO php@localhost IDENTIFED BY ***, but this just throws up an error at the MySQL prompt. Try: GRANT ALL PRIVILEGES ON *.* TO php@localhost IDENTIFIED BY 'pass' WITH GRANT OPTION; To give user php admin access for testing (you may want to revoke this later). Remember to: FLUSH PRIVILEGES; to put the new privileges into affect. My PHP page can still not connect to the database. It just says: MySQL Connection Failed: Access denied for user: 'php@localhost' (Using password: YES) I know the problem is a permissions thing, because if I connect to the test database as 'nobody', there is no problem. Can you connect as php from the prompt? Again, any and all help will be appreciated. This is ridiculously frustrating, especially since I have no problem connecting to the database from a perl script. I am tempted to stop trying to learn PHP and build my entire web site using perl cgi instead. You might want to create a new user for testing using the GRANT command above, don't enter anything into the host or db tables as I suspect this is where things are fouled. -- Mike Registered Linux User #247123 It was all very well going about pure logic and how the universe was ruled by logic and the harmony of numbers, but the plain fact was that the disc was manifestly traversing space on the back of a giant turtle and the gods had a habit of going round to atheists' houses and smashing their windows. (Colour of Magic) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] dump data, and save as a file
Header(Content-type: text/plain); Header(Content-Disposition: attachment; filename=topsellers_dvd.csv); Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 Pay It Forward mailto:[EMAIL PROTECTED] http://accessingram.com Hi everyone, I want to dump some data from mysql into a file, and use php to force the browser to pop a download file window. This seems a simple procedure, but I am having trouble to make it work with IE. The following is what I did: ob_start(); $query = SELECT * FROM table; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['data']; } header(Cache-control: private); header(Content-Type: application/txt); header(Content-Disposition: attachment; filename=test.txt); //Note: I also tried: header(Content-Disposition: inline; filename=test.txt); ob_end_flush(); * It seems OK with Netscape, but with IE, all I got is all data displayed on the screen even with ob_start(). I also tried echo the data after header(), I have the same result. I have spent a long time on this, and searched for information on www.php.net, but can not find an answer. Your help is highly appreciated. Thanks in advance. Ruth
Re: [PHP-DB] dump data, and save as a file
On Fri, 2003-02-14 at 03:09, Ruth Zhai wrote: Hi everyone, I want to dump some data from mysql into a file, and use php to force the browser to pop a download file window. This seems a simple procedure, but I am having trouble to make it work with IE. The following is what I did: ob_start(); $query = SELECT * FROM table; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['data']; } header(Cache-control: private); header(Content-Type: application/txt); header(Content-Disposition: attachment; filename=test.txt); Did you try with header(Content-Type: application/octet-stream); header(Content-transfer-encoding: binary\n); ? //Note: I also tried: header(Content-Disposition: inline; filename=test.txt); ob_end_flush(); * It seems OK with Netscape, but with IE, all I got is all data displayed on the screen even with ob_start(). I also tried echo the data after header(), I have the same result. I have spent a long time on this, and searched for information on www.php.net, but can not find an answer. Your help is highly appreciated. Thanks in advance. Ruth -- Stephane [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Question about replacing large textfields
Hi there, I'm looking for a way to let people without any knowledge of coding replace large fields of text and images on their website. Is there anyone who knows some way to do this with MySQL and PHP ? Maybe someone knows where I can find an online tutorial about this? Thanks a bunch
[PHP-DB] Re: Question about replacing large textfields
Wart, You can use Horde and Giapeto to achieve this. Giapeto is a Horde component that is written to give end users the ability to create and modify web sites through their web browser. You can obtain Horde and Giapeto from http://www.horde.org. You will have to obtain both from their public CVS server (since Giapeto is not quite released code yet) Thanks, Mike Hilty Wart Van Ingen [EMAIL PROTECTED] wrote in message 153E04744A5AD5118FC900306E001A7202159561@FMEMAIL1">news:153E04744A5AD5118FC900306E001A7202159561@FMEMAIL1... Hi there, I'm looking for a way to let people without any knowledge of coding replace large fields of text and images on their website. Is there anyone who knows some way to do this with MySQL and PHP ? Maybe someone knows where I can find an online tutorial about this? Thanks a bunch -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How to access a MS Access DB
Ok, this is what I did... Keep in mind I have Xp so I don't know how this all pans out. 1. I opened the ODBC Data Source Administrator 2. My default view was User DSN 3. I clicked on System DSN 4. Clicked on Add 5. Choose Microsoft Access Driver (*.mdb) 6. Gave it a name of Killerspin_com2 7. Clicked on Create 8. Saved it the directory which my source code will reside in. 9. Set up username/password 10. created test_connect.php page. 11. Inserted the following code: if (odbc_connect(killerspin_com,username,password) == 0) die(failed); else die(success); 12. Received this error. Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in D:\is\clients\eki\killer_spin\new_web\test_connect.php on line 3 Failed. I'm not to sure how to set this up to work with PHP --- Jonathan -Original Message- From: Griffiths, Daniel [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 3:38 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] How to access a MS Access DB to set up a DSN go to control panel and then Administrative Tools then into Data Sources and then add a new system DSN. you can probably work the rest out as its fairly straight forward. -Original Message- From: Jonathan Villa [mailto:[EMAIL PROTECTED]] Sent: 13 February 2003 22:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] How to access a MS Access DB I need to know exactly how to hook up to an Access database under Office Xp. I normally use MySQL, but the current site sits on Windows servers. I am using php 4.3.0 Office Xp Pro w/ Access I'm running Apache 2.0.43 I need to know how to check if ODBC is set up on my machine (I hear that by default it is) and what's this about a driver? All I know at this point is odbc_connect(XXX,username,password); Where XX is the DSN name I will be using, (how do this, i.e. set up a DSN name) Thanks much and in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question about replacing large textfields
http://www.hotscripts.com/PHP/ One example: http://www.hotscripts.com/Detailed/9026.html Good luck, Doug On Fri, 14 Feb 2003 16:09:34 +0100, Ingen, Wart van wrote: Hi there, I'm looking for a way to let people without any knowledge of coding replace large fields of text and images on their website. Is there anyone who knows some way to do this with MySQL and PHP ? Maybe someone knows where I can find an online tutorial about this? Thanks a bunch -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How to access a MS Access DB
Not sure if it's at typo, but the DSN you created was Killerspin_com2 and the DSN you're trying to reference is killerspin_com. Also, if the Database already exists, don't use Create. Click Select. The location ofhte database isn't important, as long as the DSN can see it. You might want to put it outside the source code dir to prevent it from being downloadable. I was just able to do this using Access 97 (ick!) on Win2k (but the ODBC widget seems to be the same as XP). --- Jonathan Villa [EMAIL PROTECTED] wrote: Ok, this is what I did... Keep in mind I have Xp so I don't know how this all pans out. 1. I opened the ODBC Data Source Administrator 2. My default view was User DSN 3. I clicked on System DSN 4. Clicked on Add 5. Choose Microsoft Access Driver (*.mdb) 6. Gave it a name of Killerspin_com2 7. Clicked on Create 8. Saved it the directory which my source code will reside in. 9. Set up username/password 10. created test_connect.php page. 11. Inserted the following code: if (odbc_connect(killerspin_com,username,password) == 0) die(failed); else die(success); 12. Received this error. Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in D:\is\clients\eki\killer_spin\new_web\test_connect.php on line 3 Failed. I'm not to sure how to set this up to work with PHP --- Jonathan -Original Message- From: Griffiths, Daniel [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 3:38 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] How to access a MS Access DB to set up a DSN go to control panel and then Administrative Tools then into Data Sources and then add a new system DSN. you can probably work the rest out as its fairly straight forward. -Original Message- From: Jonathan Villa [mailto:[EMAIL PROTECTED]] Sent: 13 February 2003 22:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] How to access a MS Access DB I need to know exactly how to hook up to an Access database under Office Xp. I normally use MySQL, but the current site sits on Windows servers. I am using php 4.3.0 Office Xp Pro w/ Access I'm running Apache 2.0.43 I need to know how to check if ODBC is set up on my machine (I hear that by default it is) and what's this about a driver? All I know at this point is odbc_connect(XXX,username,password); Where XX is the DSN name I will be using, (how do this, i.e. set up a DSN name) Thanks much and in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a right unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] When to do free()?
Hello, I'm currently using pear DB to abstract out use of my mysql database. Everything is generally working fine, except that it seems that performance seems to degrade the more it is used, then I get my ISP to restart mysql and everything seems to be good again for a while, then it degrades, lather-rinse-repeat. I'm currently one of the only ones using mysql at my ISP, so it seems that whatever I'm doing is causing issues. For the most part I'm not doing anything complex, queries are relatively simple and the dbases are currently pretty small. So while thinking about the issue, one thing that occured to me is that I'm not doing a free() on the query results when I'm done with them. That's mostly because very few of the examples I've seen ever do this, so I assumed it was an optimization that generally wasn't necessary. Furthermore, I figured that after my page got loaded, the connection to the db would be terminated and the resources freed, so the extent of the resource leak would be pretty minimal. Well, now I'm questioning the validity of those assumptions and I'm wondering if I need to start adding liberal use of free(), and I'm wondering to what extent it needs to be done? So first question, for those familiar with pearDB. It seems that certainly after doing a query() I should do a free(). What about getAll() (and related question, is there much difference between doing a query() and getAll())?). The docs seem to indicate a getOne() automatically frees resources, so I don't need to do it there. Next question is, what happens when no one refers to a result any more? Will a destructor get called that automatically frees the result? Or should I make sure to do the free before the reference is lost? How long are resources held if you don't free them? Finally, I assume that when you fetch data from a result that the data is copied and that it's not a reference, right? So as soon as I've done the necessary fetchRows() or whatever, I can safely free the result, right? Any other ideas what might be causing problems for mysql and/or how to track the problems? I believe my ISP is using linux with apache, and a fairly recent PHP and mysql. I can get more details on exact versions if that helps. Also, just as a general note, the basic format for most of my pages is: 1) connect to database 2) do some queries from PHP using pearDB 3) display results I don't specifically call disconnect() when I'm done. Should I? Sorry for the abundance of questions, and thanks for any help. Regards, Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Storing Boolean Values
I've been storing checkbox values in MySQL as Enum's for a while, I was wondering if there's a better way to do things. Is this the most compact way to store a boolean value? -Micah
RE: [PHP-DB] Storing Boolean Values
I would say using a 'tinyint' as either a 1 or 0 would be the same ... thats basically all a boolean TRUE or FALSE is, anyway. Regards, Matthew Moldvan --- System Administrator Trilogy International, Inc http://www.trilogyintl.com/ecommerce/ --- -Original Message- From: Micah Stevens [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 3:36 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Storing Boolean Values I've been storing checkbox values in MySQL as Enum's for a while, I was wondering if there's a better way to do things. Is this the most compact way to store a boolean value? -Micah -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: your odbc problem can be solved
Great, the error message is gone so I am assuming that it have it right so far. Now, my question is on syntax and logic. I have a RecordSet class I use when I connection to a MySQL. It's basically like this: class RecordSet { //var name function RecordSet($sql) { $this-setDBConn(mysql_connect(localhost, username, password)); mysql_select_db($this-getDBName(), $this-getDBConn()); $this-setResultID(mysql_query($sql, $this-getDBConn())); } //Appropriate Gets and Sets } I then do something like this $objRecordSet = new RecordSet($sql); if (mysql_num_rows($objRecordSet-getResultID()) != 1) { blah blah blah } I want to do the same with the ODBC functions. So basically, just be able to create a new RecordSet class and pass it a query. I'm pretty hard pressed for time and have not found the right info on the web which is why I am asking what I am asking. Thanks in advance. --- Jonathan -Original Message- From: John A DAVIS [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 10:45 AM To: [EMAIL PROTECTED] Subject: your odbc problem can be solved That's fine, but you need to do this on the machine that has the web server, even if it's pointing at another machine that has the database. Why? Because the web server is the one trying to access the database with an ODBC driver (Open Database Connectivity), not the user. For some reason, my answer wasn't posted yesterday. Ok, this is what I did... Keep in mind I have Xp so I don't know how this all pans out. 1. I opened the ODBC Data Source Administrator 2. My default view was User DSN 3. I clicked on System DSN 4. Clicked on Add 5. Choose Microsoft Access Driver (*.mdb) 6. Gave it a name of Killerspin_com2 7. Clicked on Create 8. Saved it the directory which my source code will reside in. 9. Set up username/password 10. created test_connect.php page. 11. Inserted the following code: if (odbc_connect(killerspin_com,username,password) == 0) die(failed); else die(success); 12. Received this error. Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in D:\is\clients\eki\killer_spin\new_web\test_connect.php on line 3 Failed. I'm not to sure how to set this up to work with PHP --- Jonathan -Original Message- From: Griffiths, Daniel [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 3:38 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] How to access a MS Access DB to set up a DSN go to control panel and then Administrative Tools then into Data Sources and then add a new system DSN. you can probably work the rest out as its fairly straight forward. -Original Message- From: Jonathan Villa [mailto:[EMAIL PROTECTED]] Sent: 13 February 2003 22:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] How to access a MS Access DB I need to know exactly how to hook up to an Access database under Office Xp. I normally use MySQL, but the current site sits on Windows servers. I am using php 4.3.0 Office Xp Pro w/ Access I'm running Apache 2.0.43 I need to know how to check if ODBC is set up on my machine (I hear that by default it is) and what's this about a driver? All I know at this point is odbc_connect(XXX,username,password); Where XX is the DSN name I will be using, (how do this, i.e. set up a DSN name) Thanks much and in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] efficient next/prev page generation
Hey, One more on efficiency. Basically all the examples I've seen for doing 'windowed dbase queries' (i.e., displaying a limited set of results and providing next/prev paging capabilities) have the same basic format: 1.SELECT * FROM table 2. get the number of rows from result 3. figure out paging scheme 4. SELECT desired data FROM table LIMIT startPoint,numEntries It seems to me this is annoyingly inefficient forcing every page to query for the entire list first, then re-running the query for the desired subset. I guess there's no way around that, right? My real question is, is there any particular reason (other than laziness) that the first query (which fetches all results) is done with a '*'. It seems to me that especially if you have a lot of data in your table, that's unnecessarily inefficient since it's got to retrieve and store in memory all the fields. Since you only really need to know how many rows there are, wouldn't it be much more efficient to just pick one particular column, and make that column the smallest one available? -Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: efficient next/prev page generation
Just reviewed my post (should do that *before* hitting submit ... sigh ). One minor note, which should be obvious, but just for completeness: David Chamberlin wrote: 1.SELECT * FROM table 2. get the number of rows from result 3. figure out paging scheme 4. SELECT desired data FROM table LIMIT startPoint,numEntries I forgot to include the query criteria. i.e., 1. SELECT * FROM table WHERE/LIKE criteria 2. get the number of rows from result 3. figure out paging scheme 4. SELECT desired data FROM table WHERE/LIKE criteria LIMIT startPoint,numEntries -Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] efficient next/prev page generation
I think the first item should be COUNT(*), because as you mentioned it would be pretty inefficient to pull all the data just to get a count. In MySQL 4 you can move step 4 to step 1 with a slight modification and leave it at three steps. Lookup the FOUND_ROWS() function to find out all the details. This feature was not available in v3 so you needed to do two queries. I actually just did what you are trying to do. On Friday, February 14, 2003, at 03:59 PM, David Chamberlin wrote: Hey, One more on efficiency. Basically all the examples I've seen for doing 'windowed dbase queries' (i.e., displaying a limited set of results and providing next/prev paging capabilities) have the same basic format: 1.SELECT * FROM table 2. get the number of rows from result 3. figure out paging scheme 4. SELECT desired data FROM table LIMIT startPoint,numEntries It seems to me this is annoyingly inefficient forcing every page to query for the entire list first, then re-running the query for the desired subset. I guess there's no way around that, right? My real question is, is there any particular reason (other than laziness) that the first query (which fetches all results) is done with a '*'. It seems to me that especially if you have a lot of data in your table, that's unnecessarily inefficient since it's got to retrieve and store in memory all the fields. Since you only really need to know how many rows there are, wouldn't it be much more efficient to just pick one particular column, and make that column the smallest one available? -Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] efficient next/prev page generation
Hello, See http://www.pearfr.org/docs/dbpager.php?lang=en, a tutorial about PEAR::DB_Pager, which paging datas, from a DB result or a simple array. It can help you to find a good method. hth pierre -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: efficient next/prev page generation
SELECT COUNT(*) FROM table (only on initial page). Then pass that count from page to page. Then only one query will be necessary for subsequent page requests. The count will not always be accurate if records are added during the users visit. But it's a quicker solution. David Chamberlin [EMAIL PROTECTED] wrote: Just reviewed my post (should do that *before* hitting submit ... sigh ). One minor note, which should be obvious, but just for completeness: David Chamberlin wrote: 1.SELECT * FROM table 2. get the number of rows from result 3. figure out paging scheme 4. SELECT desired data FROM table LIMIT startPoint,numEntries I forgot to include the query criteria. i.e., 1. SELECT * FROM table WHERE/LIKE criteria 2. get the number of rows from result 3. figure out paging scheme 4. SELECT desired data FROM table WHERE/LIKE criteria LIMIT startPoint,numEntries -Dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] dump data, and save as a file
Use Content-Type: application/octet-stream Gary Every [EMAIL PROTECTED] wrote: Header(Content-type: text/plain); Header(Content-Disposition: attachment; filename=topsellers_dvd.csv); Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 Pay It Forward mailto:[EMAIL PROTECTED] http://accessingram.com Hi everyone, I want to dump some data from mysql into a file, and use php to force the browser to pop a download file window. This seems a simple procedure, but I am having trouble to make it work with IE. The following is what I did: ob_start(); $query = SELECT * FROM table; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo $row['data']; } header(Cache-control: private); header(Content-Type: application/txt); header(Content-Disposition: attachment; filename=test.txt); //Note: I also tried: header(Content-Disposition: inline; filename=test.txt); ob_end_flush(); * It seems OK with Netscape, but with IE, all I got is all data displayed on the screen even with ob_start(). I also tried echo the data after header(), I have the same result. I have spent a long time on this, and searched for information on www.php.net, but can not find an answer. Your help is highly appreciated. Thanks in advance. Ruth -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php