[PHP-DB] Re: Accessing Foxpro free tables using ODBC
Hi Yue Teng, Right click on the directory in Explorer and change the NTFS permissions as appropriate. If you are not sure, set it to read/write Everyone. Best of luck-lah! John Yue Teng [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi John, It could be a file permissions issue. I ran the script using PHP from XP's command prompt window and the output is fine. The problem occurs only when test.php is served by Apache. How should I grant the permissions? Do I modify php.ini or Apache's httpd.conf file? John Lim [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Looks like a file permissions problem perhaps. Grant access to the the IIS user or make the file public to everyone. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Accessing Foxpro free tables using ODBC
Hi John, Finally got it to work. Guess what - my .dbf files were copied from an encrypted folder and so the .dbf files remained encrypted. Decrypted the files and now the script runs fine. Now it makes sense - whoever access the web shouldn't have access to encrypted files! Thanks a million for helping. John Lim [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Yue Teng, Right click on the directory in Explorer and change the NTFS permissions as appropriate. If you are not sure, set it to read/write Everyone. Best of luck-lah! John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] php
Hi every one i have problem in web project use PHP I want to open commport in web project. How to read data from commport in php base web project please help me sir Bye Ramesh Patel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Problem in commport
Hi every one i have problem in web project use PHP I want to open commport in web project. How to read data from commport in php base web project please help me sir Bye Ramesh Patel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] big sessions problem - page refusing to load, but will if I skip the logonpage
I have a logon screen that starts a session for several other pages and it has been working great, over the weekend something happened. I checked the site from home and after login the main page would not load, just a white screen and view source showed absolutely nothing. Now I'm in the office and looking at the source code and I don't see anything wrong, nothing changed. I can load the pages by skipping the logon and typing in the complete url manually and they all load just fine, soon as I try to use the logon screen the first main page after it will not load, if I enter the full url to another protected page it will load, then I can use the links for the main page and it too will now load. Just after the logon, the main page will not load. I have tried this with both my own login and a users login and it is happening to all. Any idea what could be causing this? I've gotta get this fixed ASAP, perminently, this is a business web site. The code for the login screen and the main page are pasted below. Regards, -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] There is no reason anyone would want a computer in their home. --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) = Code for authorization login: --- ?php //auth_user.php include ../common_db.inc; $register_script = register.php; function auth_user($userid, $userpassword) { global $default_dbname, $user_tablename; $link_id = db_connect($default_dbname); $query = SELECT username FROM $user_tablename WHERE userid = '$userid' AND userpassword = '$userpassword'; $result = mysql_query($query); if(!mysql_num_rows($result)) return 0; else { $query_data = mysql_fetch_row($result); return $query_data[0]; } } function login_form() { global $PHP_SELF; ? HTML HEAD TITLELogin/TITLE /HEAD BODY FORM METHOD=POST ACTION=? echo $PHP_SELF ? DIV ALIGN=CENTERCENTER H3Please log in to access the page you requested./H3 TABLE BORDER=1 WIDTH=200 CELLPADDING=2 TR TH WIDTH=18% ALIGN=RIGHT NOWRAPID/TH TD WIDTH=82% NOWRAP INPUT TYPE=TEXT NAME=userid SIZE=8 /TD /TR TR TH WIDTH=18% ALIGN=RIGHT NOWRAPPassword/TH TD WIDTH=82% NOWRAP INPUT TYPE=PASSWORD NAME=userpassword SIZE=8 /TD /TR TR TD WIDTH=100% COLSPAN=2 ALIGN=CENTER NOWRAP INPUT TYPE=SUBMIT VALUE=LOGIN NAME=Submit /TD /TR /TABLE /CENTER/DIV /FORM /BODY /HTML ? } session_start(); if(!isset($userid)) { login_form(); exit; } else { session_register(userid, userpassword); $username = auth_user($userid, $userpassword); if(!$username) { session_unregister(userid); session_unregister(userpassword); echo centerpAuthorization failed.br . Sorry, you must enter a valid userid and password combo./p . pThis site is restricted to Simrad Authorized Dealers only.br\n; echo Click a href=\$PHP_SELF\here/A to try again./p; echo pIf you are a Simrad Authorized Dealer and \n; echo you are not a member yet,brplease . call Simrad, Inc and request your login information./p\n; echo pIf you are not a Simrad Authorized Dealer please click on thebr \n; echo following link to return to our home page \n; echo a href=\../index.php\Simrad, Inc/a/p/center\n; exit; } // else // { //echo pa href=\dealers_page.php\Click here/a to continue; //header( 'Location: dealers_page.php' ); // } } ? == Code for the main page after the successful login: - ? include auth_user.php; ? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head ? include ../connect; $sql = select * from main where cat = 'dealers' and page = 'dealers'; $result = mysql_query($sql); while ($row=mysql_fetch_array($result)) { printf(title%s/title, $row[name]); } ? meta name=generator content=HTML Tidy, see www.w3.org / meta name=target content=td, tda, tda157, 157, tda 157, tdc, tdc338, tdc 338, tdl, td-l, 1100, 1550, 1620, tb, tb548, tb 548, buoy, radio buoy, direction finder, df, addf / ? include ../metatags_pages.inc; ? style type=text/css /*![CDATA[*/ td.small {font-size: 75%} .red {color: red; font-size: 75%; } .black {color: black; font-size: 75%; } .big {font-size: 150% } /*]]*/ /style /head body !-- Code for Extreme Tracker -- a
[PHP-DB] convert 2 dates to number of hours
Hello, how can i calculate the number of hours between 2 dates, and better yet , the work hours ( example from 8.30am to 6pm excluding weekends) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] convert 2 dates to number of hours
Hello, how can i calculate the number of hours between 2 dates, ( $unixDateTimeTo - $unixDateTimeFrom ) * 60 * 60 and better yet , the work hours ( example from 8.30am to 6pm excluding weekends) This would be more involved. Are you trying to find out how many work hours there were between 2 dates? Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] convert 2 dates to number of hours
thank you for your help, i figured this out : SELECT id, to_days(t1.closedate) - to_days(t1.date) FROM tracking AS t1 ... yes i am .. whe are using the IRM http://irm.schoenefeld.org/ for internal help desk and im creating event reports ... it only makes sense to include in the calculations the work hours so thats what im trying to do, to make the reports more viable Chris Boget wrote: Hello, how can i calculate the number of hours between 2 dates, ( $unixDateTimeTo - $unixDateTimeFrom ) * 60 * 60 and better yet , the work hours ( example from 8.30am to 6pm excluding weekends) This would be more involved. Are you trying to find out how many work hours there were between 2 dates? Chris
[PHP-DB] Help MySQL server has gone away
ok, I have a script that takes files from a HTTP post and loads them into a mySQL database. Whenever I try to load a file greater than a meg ot two, I get mySQL error #2006, MySQL server has gone away. I checked upload_max_filesize in php.ini and that's not the problem, also MAX_FILE_SIZE input tag is not the problem. Anyone have any ideas? Here the basic code that does the upload. There is some other code that collects other info and some error checking. I'm not hitting max execution time. So what gives? Thanks in advance for your help. BTW, PHP 4.2.1, my SQL 3.23.49-nt $f1=fopen($_FILES['newfile']['tmp_name'], r); $file=fread($f1, $_FILES['newfile']['size']); $file=AddSlashes($file); $insertQuery = INSERT INTO media_files SET shortdesc='{$_POST['short']}', longdesc='{$_POST['longdesc']}', username='{$_POST['user']}', mimetype='{$_FILES['newfile']['type']}', filedata='{$file}', filesize='{$_FILES['newfile']['size']}', filename='{$_FILES['newfile']['name']}', uploaded=CURDATE(), category1='{$_POST['gen']}', category2='{$_POST['category']}' ; Please help. Thanks. - Anthony -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] error_reporting()
I do the following ?PHP error_reporting(E_ALL); echo error_reporting(); ? and it says 2047 and still reports no errors. What overrides my setting? Thanks... Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP-DB] error_reporting()
Do you have display_errors = On in your php.ini ? Ryan Jameson (USA) wrote: I do the following ?PHP error_reporting(E_ALL); echo error_reporting(); ? and it says 2047 and still reports no errors. What overrides my setting? Thanks... Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] error_reporting()
That looks like it's the problem. I expected the directive to override the setting, but it must work the other way around. :-\ Thanks! Ryan -Original Message- From: Hutchins, Richard [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 1:30 PM To: Ryan Jameson (USA) Subject: RE: [PHP-DB] error_reporting() ... my first guess would be to check the setting of display_errors in your php.ini. It's set to off, by default. Hope this helps. -Original Message- From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 3:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] error_reporting() I do the following ?PHP error_reporting(E_ALL); echo error_reporting(); ? and it says 2047 and still reports no errors. What overrides my setting? Thanks... Ryan -- 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: Mysql vs postgresql
I would go for postgresql. Reasons? triggers,procedures,a speed almost equal to mysql. they say mysql is faster. In my experience, only the simplest sites take advantage of this great speed. Once, in a web-page I had 2 sql queries to a Postgresql engine and I had to re-write the code for Mysql: I couldn't without 5 separate queries. So, depending on the complexity of your site you shoud choose betwwen Postgreasql and MySQL. Gabi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php and fonts
You have to use IExplorer 4 or later and instead of a textarea where the user pastes the news you will provide him a span id=news editable=true/span or div ... or td... and in a input type=hidden name=news_text you will set the value before he submits the form: news_text.value=news.innerHTML; and this blob you put in your MySQL. This only work on IE. For Netscape, perhaps some other guy will help you. But, if it is an admin module, you will be able to impose a browser. Gabi always open to new ideas at [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Flush database
Could anyone help me to figure out how to write a piece of code that says if the time now time( ) is greater than 1 hour of the time( )then do something. I have a script that gets the time as of now and I also have the time of (lets say then) stored in a database. how would I write the code to say if the old time is greater than 1 hour do something? $subtracted_time = $time_now - $stored_database_time; if ($subtracted_time mktime(1,0,0,0,0,0)) Thank you -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Register Globals Question
Whoever told you that was wrong. It will not be deprecated, the default php.ini setting was merely changed. If you have a php.ini file and you upgrade you won't notice any change whatsoever. -Rasmus On Mon, 30 Sep 2002, Ryan Jameson (USA) wrote: I was recently told this: register_globals is a deprecated function due to security problems. It will NOT be available in the next version of PHP. As a result, the recommended way to access is with $_REQUEST[HTTP_USER_AGENT] instead. This is a joke right? I've got thousands of lines of code that rely on the availability of $HTTP_USER_AGENT. I've been doing it that way since 1998... It's not like the PHP guys to release new versions that are incompatible with the old ones. Please tell me this is not for real. Ryan -- 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] Register Globals Question
Thank you sir. Ryan -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 4:38 PM To: Ryan Jameson (USA) Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Register Globals Question Whoever told you that was wrong. It will not be deprecated, the default php.ini setting was merely changed. If you have a php.ini file and you upgrade you won't notice any change whatsoever. -Rasmus On Mon, 30 Sep 2002, Ryan Jameson (USA) wrote: I was recently told this: register_globals is a deprecated function due to security problems. It will NOT be available in the next version of PHP. As a result, the recommended way to access is with $_REQUEST[HTTP_USER_AGENT] instead. This is a joke right? I've got thousands of lines of code that rely on the availability of $HTTP_USER_AGENT. I've been doing it that way since 1998... It's not like the PHP guys to release new versions that are incompatible with the old ones. Please tell me this is not for real. Ryan -- 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] Register Globals Question
It is deprecated as it creates a massive security hole. However, all you have to do is change the setting in your php.ini file. Set register_globals=On. That's all. However, for all code you write from now on you should use $_POST, $_GET and the like. Read this article. http://www.zend.com/zend/art/art-sweat4.php ~ Matthew -Original Message- From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 6:34 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Register Globals Question I was recently told this: register_globals is a deprecated function due to security problems. It will NOT be available in the next version of PHP. As a result, the recommended way to access is with $_REQUEST[HTTP_USER_AGENT] instead. This is a joke right? I've got thousands of lines of code that rely on the availability of $HTTP_USER_AGENT. I've been doing it that way since 1998... It's not like the PHP guys to release new versions that are incompatible with the old ones. Please tell me this is not for real. Ryan -- 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] Register Globals Question
I was recently told this: register_globals is a deprecated function due to security problems. It will NOT be available in the next version of PHP. As a result, the recommended way to access is with $_REQUEST[HTTP_USER_AGENT] instead. This is a joke right? I've got thousands of lines of code that rely on the availability of $HTTP_USER_AGENT. I've been doing it that way since 1998... It's not like the PHP guys to release new versions that are incompatible with the old ones. Please tell me this is not for real. Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Compare time functions
Could anyone help me to figure out how to write a piece of code that says if the time now time( ) is greater than 1 hour of the time( time stored in the database) do something. I have a script that gets the time as of now and I also have the time of (lets say then) stored in a database. how would I write the code to say if the old time is greater than 1 hour do something? I need to compare the 2 time( ) functions. $time1 = current server time $time2 = server time stored in the database if ($time1 is = 1 hour of $time2) { execute code } How would one go about comparing these two time functions? Thank you -- Should you have any questions, comments or concerns, feel free to call me at 318-338-2033. Thank you for your time, Wade Kelley, Design Engineer Bayou Internet...(888) 30-BAYOU...http://www.bayou.com Mississippi Internet...(800) MISSISSIPPI...http://www.mississippi.net Vicksburg Online...(800) MISSISSIPPI...http://www.vicksburg.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Changing colors in table?
Okay. Disclaimer: I am very much the newbie, so please bear with me. I have a piece of code that displays an array from a MySQL table. One field in the table is blank (and is displayed as an empty column of cells) at the moment. I want to have the blank cells display an image, value, or change its background color based on whether the numerical values in the previous 4 fields meet certain criteria or not. Make sense? Maybe? An example of what I want to show: If table 2 has a value that is less than 5, then the last cell displayed changes color to reflect that. If table 2 has a value that is between 5 and 10, then the last cell displayed changes color to reflect that as well. Please help if you canmany thanks in advance. (I can show my code thus far as well if that helps..) Thanks, Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Next N Interface
Hello, I am trying to create a next n interface through php4, using results from a mysql query. I did this in the past easily with ColdFusion, but this time it's a bit more complicated. What I need to do basicaly is to have only 5 results per page. The first page displays the 5 results and Next Page at the bottom, the second page displays results 6 to 10 and displays Previous Page | Next Page , up until the last page that displays only the previous page, and the last results (from 1 to 5). I don't necessarely need to have each page as a number at the bottom, just the previous and next links. All I need basically is to either get or output only 5 rows at a time, with only needing the $_GET['startrow'] variable. Can anyone help me? (or just throw me a link to an existing page/script) Thanks, Éric. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Next N Interface
I did something like this with a photo gallery I made. The approach I took is the execute a query, get the number of rows, and divide that number by how ever many records I wanted on that page. Then that would give me the number of total pages I would have for my navigational links at the bottom. Then I would pass a page number from page to page and multiply this by the number of records which would give me the first record to display from the same query. Soem sample code: (I displayed 4 pictures/records per page) $num_rows = mysql_num_rows($result); //Check to see if any rows are present if ($num_rows = 0) { echo centerh2No Pictures Available in this Album/h2/center; exit(1); } $x = ($num_rows/4); $y = intval($x); if ($x $y) { $num_pages= $y+1; } else { $num_pages= $x; } $curr_row = ($curr_page*4); if ($DEBUG 0) { echo Curr_row is: $curr_rowbr; } mysql_data_seek($result, $curr_row); HTH -Brad Lucas Novæ Matrix wrote: Hello, I am trying to create a next n interface through php4, using results from a mysql query. I did this in the past easily with ColdFusion, but this time it's a bit more complicated. What I need to do basicaly is to have only 5 results per page. The first page displays the 5 results and Next Page at the bottom, the second page displays results 6 to 10 and displays Previous Page | Next Page , up until the last page that displays only the previous page, and the last results (from 1 to 5). I don't necessarely need to have each page as a number at the bottom, just the previous and next links. All I need basically is to either get or output only 5 rows at a time, with only needing the $_GET['startrow'] variable. Can anyone help me? (or just throw me a link to an existing page/script) Thanks, Éric. -- 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] Changing colors in table?
The blank table column comes from a blank MySQL database field...(I was initially going to blob images from there to show status change). If you know of a way to eliminate the database field and still show the status of the values in a web table, please point me in the right direction. I am one of those people who have to look up everything for JavaScript. (My main scripting beast was/is ASP...this PHP is a new project for a company on a Solaris platform!) -Original Message- From: Tony S. Wu [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:04 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Changing colors in table? I don't see where you put your blank table column. I am guessing it might be somewhere within this for loop: for ($i=0; $i $num_tables; $i++) { echo(centerh3 $arr_tablenames[$i] /h3/center); echo('table align=center border=1tr'); $result = mysql_db_query($dbname, select * from $arr_tablenames[$i], $id_link); for ($ii=0; $ii $arr_num_fields[$i]; $ii++) { echo(th); echo $hash_field_names[$i][$ii]; echo(/th); } echo(/trtr); $number_of_rows = @mysql_num_rows($result); for ($iii = 0; $iii $number_of_rows; $iii++) { $record = @mysql_fetch_row($result); for ($ii=0; $ii $arr_num_fields[$i]; $ii++) { echo(td); echo $record[$ii]; echo(/td); } echo(/tr); } echo(/table); } If that's the case, all you need to do is, let's pretend $table_value holds the table value you need to determine the background color: echo td; if ($table_value 5) { echo bgcolor = \#99\; // whatever color you want } else if ($table_value = 5 $table_value 10) { echo bgcolor = \#88\; // another color } else// if no value matched { echo ; // close td tag } Tony S. Wu [EMAIL PROTECTED] Nope, this world ain't perfect. But at least I know it's not because of me. Blue Tiger at [EMAIL PROTECTED] wrote: Can I force it to display the data sorted by the primary key? Here's the code: // store table names in an array $arr_tablenames[] = ''; // store number of fields per table(index 0,1,2..) in an array $arr_num_fields[] = ''; for ($i=0; $i $num_tables; $i++) { $arr_tablenames[$i] = mysql_tablename($tables, $i); $arr_num_fields[$i] = mysql_num_fields(mysql_db_query($dbname, select * from $arr_tablenames[$i], $id_link)); } // store field names in a multidimensional array: // [i] == table number, [ii] == field number for that table for ($i=0; $i $num_tables; $i++) { for ($ii=0; $ii $arr_num_fields[$i]; $ii++) { $result = mysql_db_query($dbname, select * from $arr_tablenames[$i], $id_link); $hash_field_names[$i][$ii] = mysql_field_name($result, $ii); } } for ($i=0; $i $num_tables; $i++) { echo(centerh3 $arr_tablenames[$i] /h3/center); echo('table align=center border=1tr'); $result = mysql_db_query($dbname, select * from $arr_tablenames[$i], $id_link); for ($ii=0; $ii $arr_num_fields[$i]; $ii++) { echo(th); echo $hash_field_names[$i][$ii]; echo(/th); } echo(/trtr); $number_of_rows = @mysql_num_rows($result); for ($iii = 0; $iii $number_of_rows; $iii++) { $record = @mysql_fetch_row($result); for ($ii=0; $ii $arr_num_fields[$i]; $ii++) { echo(td); echo $record[$ii]; echo(/td); } echo(/tr); } echo(/table); } Is that too much to sort through??? -Original Message- From: Tony S. Wu [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 7:31 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Changing colors in table? If the table's background color will be set when the page is first loaded, you can just use the bgcolor attribute of td tag. If you want to dynamically change the background color, you'll need to combine your page with javascript. Tony S. Wu [EMAIL PROTECTED] Nope, this world ain't perfect. But at least I know it's not because of me. Blue Tiger at [EMAIL PROTECTED] wrote: Okay. Disclaimer: I am very much the newbie, so please bear with me. I have a piece of code that displays an array from a MySQL table. One field in the table is blank (and is displayed as an empty column of cells) at the moment. I want to have the blank cells display an image, value, or change its background color based on whether the numerical values in the previous 4 fields meet certain criteria or not. Make sense? Maybe? An example of what I want to show: If table 2 has a value that is less than 5, then the last cell displayed changes color to reflect that. If table 2 has a value that is between 5 and 10, then the last cell
Re: [PHP-DB] Next N Interface
How about appending LIMIT _GET[startrow],5 to the end of your query. The first parameter to LIMIT is the start position and the second is the number of rows to return. Does this help, or am I misunderstanding your question? Mark Lucas Novæ Matrix wrote: Hello, I am trying to create a next n interface through php4, using results from a mysql query. I did this in the past easily with ColdFusion, but this time it's a bit more complicated. What I need to do basicaly is to have only 5 results per page. The first page displays the 5 results and Next Page at the bottom, the second page displays results 6 to 10 and displays Previous Page | Next Page , up until the last page that displays only the previous page, and the last results (from 1 to 5). I don't necessarely need to have each page as a number at the bottom, just the previous and next links. All I need basically is to either get or output only 5 rows at a time, with only needing the $_GET['startrow'] variable. Can anyone help me? (or just throw me a link to an existing page/script) Thanks, Éric. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Next N Interface
That would actually work for just getting a certain number of records from a query, but you would have to execute another query to figure out the navigational links he said he wants on the bottom...like google has, 1 2 3 4 5 . So, when I attacked it I figured one query is better then two even if it returns a whole bunch of records in the result that you are not using for that page. How is that for performance? which would be better? Or even, is there an alternative way to figureing out how many records are in a database? Always more then one way to skin a cat. -Brad Mark Lee wrote: How about appending LIMIT _GET[startrow],5 to the end of your query. The first parameter to LIMIT is the start position and the second is the number of rows to return. Does this help, or am I misunderstanding your question? Mark Lucas Novæ Matrix wrote: Hello, I am trying to create a next n interface through php4, using results from a mysql query. I did this in the past easily with ColdFusion, but this time it's a bit more complicated. What I need to do basicaly is to have only 5 results per page. The first page displays the 5 results and Next Page at the bottom, the second page displays results 6 to 10 and displays Previous Page | Next Page , up until the last page that displays only the previous page, and the last results (from 1 to 5). I don't necessarely need to have each page as a number at the bottom, just the previous and next links. All I need basically is to either get or output only 5 rows at a time, with only needing the $_GET['startrow'] variable. Can anyone help me? (or just throw me a link to an existing page/script) Thanks, Éric. -- 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] Next N Interface
That would actually work for just getting a certain number of records from a query, but you would have to execute another query to figure out the navigational links he said he wants on the bottom...like google has, 1 2 3 4 5 . So, when I attacked it I figured one query is better then two even if it returns a whole bunch of records in the result that you are not using for that page. How is that for performance? which would be better? Or even, is there an alternative way to figureing out how many records are in a database? Always more then one way to skin a cat. Use two queries. A count(*) query and a LIMIT query to only return X rows. If you have a smaller table, it might be okay to do it with on and seek the rows you want, but it's inefficient and not scalable for large tables. Previous/Next links are pretty simple with MySQL. Just pass a $page variable between pages. Increment it with Next, decrement it with Previous. Then, use it in your query like this: $result1 = mysql_query(SELECT COUNT(*) FROM your_table WHERE ... ); $records = mysql_result($result,0); $num_per_page = 5; $start = $page * $num_per_page; $num_pages = ceil($records / $num_per_page); $result = mysql_query(SELECT * FROM your_table WHERE ... LIMIT $start, $num_per_page); Add in a little logic so $page isn't below zero and doesn't go above your max pages, and you're golden... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Changing colors in table?
- Original Message - From: Blue Tiger [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 01, 2002 10:13 AM Subject: RE: [PHP-DB] Changing colors in table? : The blank table column comes from a blank MySQL database field...(I was : initially going to blob images from there to show status change). If you : know of a way to eliminate the database field and still show the status : of the values in a web table, please point me in the right direction. : I have a piece of code that displays an array from a MySQL table. One : field in the table is blank (and is displayed as an empty column of : cells) at the moment. I want to have the blank cells display an : image, : value, or change its background color based on whether the numerical : values in the previous 4 fields meet certain criteria or not. Make : sense? Maybe? : : An example of what I want to show: : If table 2 has a value that is less than 5, then the last cell : displayed : changes color to reflect that. : If table 2 has a value that is between 5 and 10, then the last cell : displayed changes color to reflect that as well. Ryan, I understand you want to display the results of a db query in an html table. Maybe I misunderstand but it seems that this shouldn't be done by fiddling with the database table; fiddle with the html table instead open mysql server do select $result start while loop on mysql-fetch-array($result) { set $summedfields = (sum field values); if ($summedfields == 2) { $bgclr=red; } else { $bgclr=blue; } if ($blankfield == NULL) { $blankfield = img src='image.gif' etc; } iterate on table row use $blankfield and $bgclr as values the html table data cells eoe Louise -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Compare time functions
Could anyone help me to figure out how to write a piece of code that says if the time now time( ) is greater than 1 hour of the time( time stored in the database) do something. I have a script that gets the time as of now and I also have the time of (lets say then) stored in a database. how would I write the code to say if the old time is greater than 1 hour do something? I need to compare the 2 time( ) functions. $time1 = current server time $time2 = server time stored in the database if ($time1 is = 1 hour of $time2) { execute code } How would one go about comparing these two time functions? Well, if you want to do the comparison in PHP, you can select out all of the rows and loop through them all. Use UNIX_TIMESTAMP(column_name) in your query to get out the unix timestamp of the date column, instead of the mysql format. Then.. $now = time(); if($now - $db_time 3600) { //more than an hour old } You could do it in your query like this: SELECT * FROM your_table WHERE db_time_column NOW() - INTERVAL 1 HOUR; That'll return all rows that have a db_time_column that's more than an hour old. Adapt that to an update or delete query and you're good to go. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] session_destroy() problem.
Ok. What is the best way to destroy a session. I have a logout page which is supposed to destroy the session but it doesn't seem to be working. After the user logs out they are take back to the log in page, which is all fine and good. But if the user tries to go to a restricted page they are let in. This is the code for my logout page. session_start(); setcookie(session_name(),,,/); session_unset(); session_destroy(); header(Location: index.php); any ideas? //Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php