[PHP-DB] problem in parsing
if i have the following script, $exp = description=whatever\namount=23.50\nquantity=2\n; if (eregi((amount)(.*)(\n), $exp,$amt)) { print $amt[0]; } the output will be namount=23.50\nquantity=2\n what will i do so that the output value will be 23.50 only. thanks =) jen
Re: [PHP-DB] problem in parsing
On Fri, 9 Aug 2002, J-E-N wrote: Hi! This one: $exp = description=whatever\namount=23.50\nquantity=2\n; if (preg_match(/amount=([0-9]{1,9}\.[0-9]{1,9})(\n)/, $exp,$amt)) { print $amt[1]; } will output 23.50 and this one: $exp = description=whatever\namount=23.50\nquantity=2\n; if (preg_match(/(amount=[0-9]{1,9}\.[0-9]{1,9})(\n)/, $exp,$amt)) { print $amt[1]; } will output amount=23.50 Regards Urosh if i have the following script, $exp = description=whatever\namount=23.50\nquantity=2\n; if (eregi((amount)(.*)(\n), $exp,$amt)) { print $amt[0]; } the output will be namount=23.50\nquantity=2\n what will i do so that the output value will be 23.50 only. thanks =) jen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Supplied argument is not a valid MySQL result resource
I'm getting some massive errors on some pretty simple code. Included are the errors as well as the PHP function that is giving me issues. Any help would be greatly appreciated. And the weirdest thing, is that the code used to work ?? Line 267 is equal to this PHP line: $RSM = mysql_fetch_array($resultm); = ERRORS: = Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 267 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 269 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 287 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 289 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 295 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 297 less than one inside of nothing found. Warning: Undefined index: format in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 327 Warning: Undefined index: bannerID in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: bannerID in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: width in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: height in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: alt in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 = CODE: = function view_order($keywords, $id) { global $phpAds_db, $phpAds_hostname, $phpAds_mysqluser, $phpAds_mysqlpassword, $REMOTE_HOST, $USER, $phpAds_tbl_banners; if(!isset($USER[$id][cbannerID])) $USER[$id][cbannerID] = -1; # $text = explode(/, $keywords); $keywords = ; $x = 0; foreach($text as $line) { if( $x == 0 ) { $keywords = (keyword LIKE '% . $line . %'; } else { $keywords = $keywords . OR keyword LIKE '% . $line . %'; } $x++; } $keywords .= ); # mysql_connect($phpAds_hostname,$phpAds_mysqluser,$phpAds_mysqlpassword) or die(Unable to connect to database); mysql_select_db($phpAds_db) or die(Unable to select database $phpAds_db); if($USER[$id][cbannerID] == -1) { $sqlm = SELECT MIN(bannerID), MAX(bannerID) FROM banners WHERE active='true';; $resultm = mysql_query($sqlm); $RSM = mysql_fetch_array($resultm); if( mysql_num_rows($resultm) 1 ) { $num1 = rand(1, 100); } Else { $num1 = rand($RSM[0], $RSM[1]); } $sql = SELECT bannerID,banner,format,width,height,alt,url FROM $phpAds_tbl_banners WHERE active = 'true' AND $keywords AND bannerID = $num1 ORDER BY bannerID LIMIT 0,1;; } else { $sql = SELECT bannerID,banner,format,width,height,alt,url FROM $phpAds_tbl_banners WHERE active = 'true' AND $keywords AND bannerID . $USER[$id][cbannerID] . ORDER BY bannerID LIMIT 0,1;; } $result = mysql_query($sql); $RS = mysql_fetch_array($result); if( mysql_num_rows($result) 1 ) { $sql2 = SELECT bannerID,banner,format,width,height,alt,url FROM $phpAds_tbl_banners WHERE active = 'true' AND $keywords ORDER BY bannerID LIMIT 0,1;; $result2 = mysql_query($sql2); $RS2 = mysql_fetch_array($result2); if( mysql_num_rows($result2) 1 ) { echo less than one inside of nothing found.; } Else { $USER[$id][bannerID] = $RS2[bannerID]; $USER[$id][banner] = $RS2[banner]; $USER[$id][format] = $RS2[format]; $USER[$id][width] = $RS2[width]; $USER[$id][height] = $RS2[height]; $USER[$id][alt] = $RS2[alt]; $USER[$id][url] = $RS2[url]; $USER[$id][cbannerID] = $RS2[bannerID]; }
Re: [PHP-DB] Supplied argument is not a valid MySQL result resource
add an... or die(mysql_error()) to the $resultm = mysql_query($sqlm); statement and you'll have a lot more info for yourself, and the list if you still need assistance. MET met@uberstats To: [EMAIL PROTECTED] .comcc: Subject: [PHP-DB] Supplied argument is not a valid MySQL result 08/09/2002resource 11:46 AM I'm getting some massive errors on some pretty simple code. Included are the errors as well as the PHP function that is giving me issues. Any help would be greatly appreciated. And the weirdest thing, is that the code used to work ?? Line 267 is equal to this PHP line: $RSM = mysql_fetch_array($resultm); = ERRORS: = Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 267 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 269 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 287 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 289 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 295 Warning: Supplied argument is not a valid MySQL result resource in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 297 less than one inside of nothing found. Warning: Undefined index: format in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 327 Warning: Undefined index: bannerID in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: bannerID in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: width in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: height in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 Warning: Undefined index: alt in D:\Gunks\NewSite\phpAds\view.inc.php3 on line 333 = CODE: = function view_order($keywords, $id) { global $phpAds_db, $phpAds_hostname, $phpAds_mysqluser, $phpAds_mysqlpassword, $REMOTE_HOST, $USER, $phpAds_tbl_banners; if(!isset($USER[$id][cbannerID])) $USER[$id][cbannerID] = -1; # $text = explode(/, $keywords); $keywords = ; $x = 0; foreach($text as $line) { if( $x == 0 ) { $keywords = (keyword LIKE '% . $line . %'; } else { $keywords = $keywords . OR keyword LIKE '% . $line . %'; } $x++; } $keywords .= ); # mysql_connect($phpAds_hostname,$phpAds_mysqluser,$phpAds_mysqlpassword) or die(Unable to connect to database); @mysql_select_db($phpAds_db) or die(Unable to select database $phpAds_db); if($USER[$id][cbannerID] == -1) { $sqlm = SELECT MIN(bannerID), MAX(bannerID) FROM banners WHERE active='true';; $resultm = mysql_query($sqlm); $RSM = mysql_fetch_array($resultm); if( mysql_num_rows($resultm) 1 ) { $num1 = rand(1, 100); } Else { $num1 = rand($RSM[0], $RSM[1]); } $sql = SELECT bannerID,banner,format,width,height,alt,url FROM $phpAds_tbl_banners WHERE active = 'true' AND $keywords AND bannerID = $num1 ORDER BY bannerID LIMIT 0,1;; } else { $sql = SELECT bannerID,banner,format,width,height,alt,url FROM $phpAds_tbl_banners WHERE active = 'true' AND $keywords AND bannerID . $USER[$id][cbannerID] . ORDER BY bannerID LIMIT 0,1;; } $result = mysql_query($sql); $RS = mysql_fetch_array($result); if( mysql_num_rows($result) 1 ) { $sql2 = SELECT bannerID,banner,format,width,height,alt,url FROM $phpAds_tbl_banners WHERE active = 'true' AND $keywords ORDER BY bannerID LIMIT 0,1;; $result2 = mysql_query($sql2); $RS2 = mysql_fetch_array($result2); if( mysql_num_rows($result2) 1 ) { echo less than one inside of nothing found.; } Else { $USER[$id][bannerID] = $RS2[bannerID]; $USER[$id][banner] = $RS2[banner]; $USER[$id][format] =
[PHP-DB] Re: OCIStmtExecute: ORA-01008: not all variables bound on Anonymous PL/SQL
Hi, Does anyone know how to get this done? Thanks, Prince [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... I have the sample php program. While trying to execute, I get the above mentioned error. SQL create type typ_numbertab TABLE OF number(12); % cat mytest.php -Program Begins #!/usr/local/php4/bin/php -q ? $dept = array(10,20,30,40); $db = OCILogon(scott,tiger); $arr = OCINewCollection($db,'TYP_NUMBERTAB'); $sqlstmt = -- declare -- :dept TYP_VARCHARTAB ; begin forall i in 1..:dept.count insert into t values (:dept(i)); end;; $stmt = OCIParse($db,$sqlstmt); while (list(,$v) = each($dept)) { $arr-append($v); } $bnd = OCIBindByName($stmt,':dept',$arr,32,OCI_B_SQLT_NTY); OCIExecute($stmt); ? -Program Ends-- % mytest.php br / bWarning/b: OCIStmtExecute: ORA-01008: not all variables bound in bmytest.php/b on line b25/bbr / Can someone tell me what is it complaining about and how to fix this? Thanks, -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Variables Not Staying Set
...slightly in regards to my last email. I have a database query which requires a variable ( $USER[$id][cbannerID] ) to be equal to the ID of the current banner being viewed. If you've come to the page for the first time my script gives that variable a default value of -1 . if(!isset($USER[$id][cbannerID])) $USER[$id][cbannerID] = -1; However the variable does not hold that value. So in my SQL statement it prints nothing returning a SQL statement error. I then tried this just or a test purposes...on a separate php page. $USER[5]['test'] = 1; echo $USER[5]['test']; Nothing gets returned either. Please note that this works on my local Win2k machine, however when I upload it my FreeBSD machine it does not work. I'm guessing it has something to do with my PHP installation. Currently the machine is running Apache 1.3.26 and PHP 4.1.2 (going to upgrade soon but also note my Windows machine is running the same ver. Of PHP). Any ideas? - Matthew /** Matthew Metnetsky [EMAIL PROTECTED] **/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] odbc connect problem
I am attempting for the first time, to connect from freebsd/mysql/php box to a NT box running MAS200. I am able to connect from another NT workstation with Access and download data, so I am trying from FreeBSD now. When I run the code below I get error: Fatal error: Call to undefined function: odbc_connect() in /usr/local/apache/htdocs/odbctest.php on line 7 What am I doing wrong? There's not much info on this topic in the mysql manual. html head titleUntitled/title /head body bgcolor=white ? $connect = odbc_connect(localhost, , -); if (!$connect) { Error_handler( Error in odbc_connect , $connect ); } $result = odbc_exec($connect, SELECT ProductLineDescription FROM IMA_ProductLine, ItemNumber, ItemDescription FROM IM1_InventoryMasterFile where DefaultWhse = 004); if (!$result) { Error_handler( Error in odbc_exec( no cursor returned ) , $connect ); } echo table border=1trthBrand/ththPart Number/ththDescription/th/tr\n; // fetch the succesive result rows while( odbc_fetch_row( $result ) ) { $brand= odbc_result( $result, 1 ); // get the field ProductLineDescription $number= odbc_result( $result, 2 ); // get the field ItemNumber $description= odbc_result( $result, 3 ); // get the field ItemDescription echo trtd$brand/tdtd$number/tdtd$description/td/tr \n; } echo /table; echo /body/html; ? -- 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!) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] odbc connect problem
It looks like you didn't build php with odbc support. Try putting in a call to phpinfo (); and see if it says that odbc support is compiled in. (Another) Chip On Fri, 9 Aug 2002 [EMAIL PROTECTED] wrote: I am attempting for the first time, to connect from freebsd/mysql/php box to a NT box running MAS200. I am able to connect from another NT workstation with Access and download data, so I am trying from FreeBSD now. When I run the code below I get error: Fatal error: Call to undefined function: odbc_connect() in /usr/local/apache/htdocs/odbctest.php on line 7 What am I doing wrong? There's not much info on this topic in the mysql manual. html head titleUntitled/title /head body bgcolor=white ? $connect = odbc_connect(localhost, , -); if (!$connect) { Error_handler( Error in odbc_connect , $connect ); } $result = odbc_exec($connect, SELECT ProductLineDescription FROM IMA_ProductLine, ItemNumber, ItemDescription FROM IM1_InventoryMasterFile where DefaultWhse = 004); if (!$result) { Error_handler( Error in odbc_exec( no cursor returned ) , $connect ); } echo table border=1trthBrand/ththPart Number/ththDescription/th/tr\n; // fetch the succesive result rows while( odbc_fetch_row( $result ) ) { $brand= odbc_result( $result, 1 ); // get the field ProductLineDescription $number= odbc_result( $result, 2 ); // get the field ItemNumber $description= odbc_result( $result, 3 ); // get the field ItemDescription echo trtd$brand/tdtd$number/tdtd$description/td/tr \n; } echo /table; echo /body/html; ? -- 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!) -- 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] odbc connect problem
Yeah, you're right, I see I need to add --with-iodbc. Now another question - when I recompile to add this support, do I have to add all the other options that I originally had listed? Or can I add just this one and everything else will be left the same? What about php.ini? Will it be changed? -- Chip W Chip Atkinson [EMAIL PROTECTED] wrote on 08/09/2002 02:51:10 PM: It looks like you didn't build php with odbc support. Try putting in a call to phpinfo (); and see if it says that odbc support is compiled in. (Another) Chip On Fri, 9 Aug 2002 [EMAIL PROTECTED] wrote: I am attempting for the first time, to connect from freebsd/mysql/php box to a NT box running MAS200. I am able to connect from another NT workstation with Access and download data, so I am trying from FreeBSD now. When I run the code below I get error: Fatal error: Call to undefined function: odbc_connect() in /usr/local/apache/htdocs/odbctest.php on line 7 What am I doing wrong? There's not much info on this topic in the mysql manual. html head titleUntitled/title /head body bgcolor=white ? $connect = odbc_connect(localhost, , -); if (!$connect) { Error_handler( Error in odbc_connect , $connect ); } $result = odbc_exec($connect, SELECT ProductLineDescription FROM IMA_ProductLine, ItemNumber, ItemDescription FROM IM1_InventoryMasterFile where DefaultWhse = 004); if (!$result) { Error_handler( Error in odbc_exec( no cursor returned ) , $connect ); } echo table border=1trthBrand/ththPart Number/ththDescription/th/tr\n; // fetch the succesive result rows while( odbc_fetch_row( $result ) ) { $brand= odbc_result( $result, 1 ); // get the field ProductLineDescription $number= odbc_result( $result, 2 ); // get the field ItemNumber $description= odbc_result( $result, 3 ); // get the field ItemDescription echo trtd$brand/tdtd$number/tdtd$description/td/tr \n; } echo /table; echo /body/html; ? -- 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!) -- 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] odbc connect problem
Chip, You are going to have to rebuild the dso with the options you specified before - try cutting and pasting the configure that shows up in your phpinfo() to make it easier. Also, you can get the necessary iODBC header files at www.iodbc.org, as well as find a HOWTO there for compiling PHP/iODBC on *nix systems. Cheers, Andrew On Friday, August 9, 2002, at 06:08 PM, [EMAIL PROTECTED] wrote: Yeah, you're right, I see I need to add --with-iodbc. Now another question - when I recompile to add this support, do I have to add all the other options that I originally had listed? Or can I add just this one and everything else will be left the same? What about php.ini? Will it be changed? -- Chip W Chip Atkinson [EMAIL PROTECTED] wrote on 08/09/2002 02:51:10 PM: It looks like you didn't build php with odbc support. Try putting in a call to phpinfo (); and see if it says that odbc support is compiled in. (Another) Chip On Fri, 9 Aug 2002 [EMAIL PROTECTED] wrote: I am attempting for the first time, to connect from freebsd/mysql/php box to a NT box running MAS200. I am able to connect from another NT workstation with Access and download data, so I am trying from FreeBSD now. When I run the code below I get error: Fatal error: Call to undefined function: odbc_connect() in /usr/local/apache/htdocs/odbctest.php on line 7 What am I doing wrong? There's not much info on this topic in the mysql manual. html head titleUntitled/title /head body bgcolor=white ? $connect = odbc_connect(localhost, , -); if (!$connect) { Error_handler( Error in odbc_connect , $connect ); } $result = odbc_exec($connect, SELECT ProductLineDescription FROM IMA_ProductLine, ItemNumber, ItemDescription FROM IM1_InventoryMasterFile where DefaultWhse = 004); if (!$result) { Error_handler( Error in odbc_exec( no cursor returned ) , $connect ); } echo table border=1trthBrand/ththPart Number/ththDescription/th/tr\n; // fetch the succesive result rows while( odbc_fetch_row( $result ) ) { $brand= odbc_result( $result, 1 ); // get the field ProductLineDescription $number= odbc_result( $result, 2 ); // get the field ItemNumber $description= odbc_result( $result, 3 ); // get the field ItemDescription echo trtd$brand/tdtd$number/tdtd$description/td/tr \n; } echo /table; echo /body/html; ? -- 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!) -- 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
Re: [PHP-DB] odbc connect problem
Chip, I wonder if you set the ODBCINI environment variable with the putenv()? If you could show the code in your odbctest.php file that would be helpful. Actually, I'll be traveling to Linuxworld on Monday - anyone wants to chat about ODBC who will be there feel free to drop me an email. Cheers, Andrew Hill OpenLink Software On Friday, August 9, 2002, at 07:31 PM, [EMAIL PROTECTED] wrote: Thanks, that fixed that part of it, now here's the newest error message: Warning: SQL error: [iODBC][Driver Manager]Specified driver could not be loaded, SQL state IM003 in SQLConnect in /usr/local/apache/htdocs/odbctest.php on line 7 Fatal error: Call to undefined function: error_handler() in /usr/local/apache/htdocs/odbctest.php on line 10 I'm outa here, catch up with ya on monday, -- Chip salamander [EMAIL PROTECTED] wrote on 08/09/2002 04:10:00 PM: Chip, You are going to have to rebuild the dso with the options you specified before - try cutting and pasting the configure that shows up in your phpinfo() to make it easier. Also, you can get the necessary iODBC header files at www.iodbc.org, as well as find a HOWTO there for compiling PHP/iODBC on *nix systems. Cheers, Andrew On Friday, August 9, 2002, at 06:08 PM, [EMAIL PROTECTED] wrote: Yeah, you're right, I see I need to add --with-iodbc. Now another question - when I recompile to add this support, do I have to add all the other options that I originally had listed? Or can I add just this one and everything else will be left the same? What about php.ini? Will it be changed? -- Chip W Chip Atkinson [EMAIL PROTECTED] wrote on 08/09/2002 02:51:10 PM: It looks like you didn't build php with odbc support. Try putting in a call to phpinfo (); and see if it says that odbc support is compiled in. (Another) Chip On Fri, 9 Aug 2002 [EMAIL PROTECTED] wrote: I am attempting for the first time, to connect from freebsd/mysql/php box to a NT box running MAS200. I am able to connect from another NT workstation with Access and download data, so I am trying from FreeBSD now. When I run the code below I get error: Fatal error: Call to undefined function: odbc_connect() in /usr/local/apache/htdocs/odbctest.php on line 7 What am I doing wrong? There's not much info on this topic in the mysql manual. html head titleUntitled/title /head body bgcolor=white ? $connect = odbc_connect(localhost, , -); if (!$connect) { Error_handler( Error in odbc_connect , $connect ); } $result = odbc_exec($connect, SELECT ProductLineDescription FROM IMA_ProductLine, ItemNumber, ItemDescription FROM IM1_InventoryMasterFile where DefaultWhse = 004); if (!$result) { Error_handler( Error in odbc_exec( no cursor returned ) , $connect ); } echo table border=1trthBrand/ththPart Number/ththDescription/th/tr\n; // fetch the succesive result rows while( odbc_fetch_row( $result ) ) { $brand= odbc_result( $result, 1 ); // get the field ProductLineDescription $number= odbc_result( $result, 2 ); // get the field ItemNumber $description= odbc_result( $result, 3 ); // get the field ItemDescription echo trtd$brand/tdtd$number/tdtd$description/td/tr \n; } echo /table; echo /body/html; ? -- 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!) -- 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 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] Ranking in MySQL
I have a MySQL table called images, each with a rating from 1-10. The column is a decimal(10,2). For simplicity's sake, let's say i have the following: CREATE TABLE images ( image_id int not null auto_increment, image_path varchar(255) not null, rating decimal(10,2) not null, primary key(image_id) ); What I'm looking to do is be able to pull from the database the ranked position each image is in. I.e. this image is ranked 70 out of 121 Any suggestions on a MySQL query that could do this? Thanks, David Balatero [EMAIL PROTECTED]
Re: [PHP-DB] Ranking in MySQL
David, Your question is a little bit unclear. First, if it is rank, you do not need decimal, but integer (tinyint will do it). Then you need a little bit of statistics to rank the picture against the others, so, anytime each picture is ranked, you have to run the statistics and update the table (update images set rating=... where image_id=...). Then, in order to post the rank, just extract max(rating) (something like select max(rating) as ... from images) and then extract the rank of the image (select decimal from images where image_id=...) and you'll have what you need. Hope this helps and I did not write to many stupid things:) Mihai On Fri, 9 Aug 2002, David Balatero wrote: I have a MySQL table called images, each with a rating from 1-10. The column is a decimal(10,2). For simplicity's sake, let's say i have the following: CREATE TABLE images ( image_id int not null auto_increment, image_path varchar(255) not null, rating decimal(10,2) not null, primary key(image_id) ); What I'm looking to do is be able to pull from the database the ranked position each image is in. I.e. this image is ranked 70 out of 121 Any suggestions on a MySQL query that could do this? Thanks, David Balatero [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP and Exel
Hello all I'm want to now if its possible to read a exel file using PHP and then populate a Mu Sql database whit the information of the exel file, if its possible what are the steps to do it? Thanks for you colaboration Nuno Fernandes NLF Software -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Tutorials
Hi all, Does anyone know where I can get beginner tutorials on PHP and MySQL? Thanks, Taj -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php