Re: [PHP-DB] Help in passing multiple HTML form options to SQL query -- Newbie
Richard, Many thanks for that. I was reading about the for statement in a book earlier today and wondered if I could implement it in some way. Looks so simple now I've been shown how :) Thanks again. Richard Chauvaux [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... first, the select tag in your form should be setup as an array: select name=country[] ... then the array $country[] will be available to your script on submittal. a simple way to build your sql where clause would be to iterate through the array using a subscript variable: $sql = select * from tbl where ctry='$country[0]'; for ($n=1; count($country) $n; $n++) { $sql.= or ctry='$country[$n]'; } richard TorrentUK wrote: I am designing a ski web site and am presently trying to put together a resort database. I started the search script tonight and am quite pleased that it works. Where I am struggling is that I would like my visitors to be able to select multiple countries from the drop down list and for my query to pull back info on all those selected. When I try it it only pulls back the last one (naturally). Please advise on what would be the most efficient way of constructing the query. Please talk in easy speak as I am real new at this and am not a developer by any stretch of the imagination. Many Thanks Torrent Here is a cut down version of my code, the html form is at the bottom. ?php if ($search) { $sql = SELECT rst_name, cty_name FROM resort_tbl WHERE cty_name='$country'; $result = mysql_query($sql); if ($row = mysql_fetch_array($result)) { echo centertable border=1\n; echo trtdName/tdtdCountry/td/tr\n; do { printf(trtd%s/tdtd%s/td\n, $row[rst_name], $row[cty_name]); } while ($myrow = mysql_fetch_array($result)); echo /table/center\n; } } ? form name=resort method=post action=?php echo $PHP_SELF? p Select country /fontbr select name=Country size=5 multiple option value=AndorraAndorra/option option value=AustriaAustria/option option value=BulgariaBulgaria/option option value=FinlandFinland/option option value=FranceFrance/option option value=ItalyItaly/option option value=North AmericaNorth America/option option value=NorwayNorway/option option value=RomaniaRomania/option option value=SloveniaSlovenia/option option value=SpainSpain/option option value=SwedenSweden/option option value=SwitzerlandSwitzerland/option /select br input type=submit name=search value=Search /p /form -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Mathematics Examples MySQL and PHP
Hello Everybody, Does anybody have some examples about howto make mathematic functions in PHP with values from any MySQL table such as: Value 1 + Value 2 = Value 3 Value 1 - Value 2 = Value 3 Value 1 * Value 2 = Value 3 Value 1 / Value 2 = Value 3 With kind regards, - Deze email is gecontroleerd op de aanwezigheid van virussen, mocht er ondanks dat toch een virus meegestuurd zijn dan verzoek ik u vriendelijk een email te sturen aan: [EMAIL PROTECTED] - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Resource id #2
I am trying to select a message from a table in a database. the message will will be in column 'msg' and will be in same row as id='0'. I need that msg put to the screen. With the code below I get the error: Resource id #2 Can someone please explain how I can fix this.. Thankyou in advance. ? $msgcre = SELECT msg FROM creators WHERE id='0'; $msg = mysql_query($msgcre); echo FONT color='#00' style='font-size: 10pt; font-weight: bold'$msg/font; ?
Re: [PHP-DB] Resource id #2
I am trying to select a message from a table in a database. the message will will be in column 'msg' and will be in same row as id='0'. I need that msg put to the screen. With the code below I get the error: Resource id #2 Can someone please explain how I can fix this.. Thankyou in advance. ? $msgcre = SELECT msg FROM creators WHERE id='0'; $msg = mysql_query($msgcre); echo FONT color='#00' style='font-size: 10pt; font-weight: bold'$msg/font; ? Andrew, Although the assignment statement looks as though the LHS (left-hand side) should contain the result of the query, it does not (as you have discovered). Instead of being an integer or string, it is something called a 'resource'. You have already 'met' a resource in connection with the db connect process. After issuing a query, you must then use one of the mysql_fetch_... functions to extract the data, one field, or one row at a time, from the 'resource'. Please check out the manual at http://uk2.php.net/manual/en/ref.mysql.php. Also you might consider working through one of the many excellent texts and/or online articles discussing the PHP/MySQL combination. Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] PHP 4 Book
Hello! =) I'm just starting to learn PHP but I don't know what book shall I use. Can you recommend to me a good PHP book that is FREE for download except the PHP Manual? Please include the complete URL of that book. Thanks. Any help will be much appreciated. =) __ www.edsamail.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] dbase help!!
I'm trying to read a record from a dbase data base so I've previously opened it successfully. The problem is that I call the function dbase_get_record, but it returns no records. The database is ok because I call the funcion dbase_numfields and dbase_numrecords and they give me correct information. Would you help me, please?. Here is the source code that fails. [EMAIL PROTECTED] Estoy intentando leer un registro de una base de datos dbase, por lo que antes la he abierto con éxito. el problema residen en que llamo a la función dbase_get_record, pero no me devuelve ningún registro. La base de datos está bien, porque llamo a la función dbase_numfields y dbase_numrecords y me dan información correcta. ¿Me podríais ayudar, por favor?. Ahí va el código fuente: [EMAIL PROTECTED] Source code- Código fuente: ? $based=articulo.dbf; if (($descriptor=dbase_open ($based, 0))==0){ printf (brError al abrir la base de datos); }else{ printf (brBase de datos abierta); $num_registros=dbase_numrecords($descriptor); $num_campos=dbase_numfields($descriptor); for ($i=1;$i=$num_registros;$i++){ $registro= dbase_get_record ($descriptor, $i); for ($j=0;$j$num_campos;$j++){ printf (brFila %d,Campo %d vale %S, $i, $j, $registro[$j]); } } dbase_close($descriptor); printf (brBase de datos cerrada); } ?
[PHP-DB] Help with PHP CSS selector
Currently I have PHP code that runs a server side check on your browser (placed above the html tags) and assigns a certain CSS stylesheet to it. The problem I have with the current code is it only goes by the browser and not both the browser and platform. I have the source code (listed below) that shows what the selector does. I was wondering if any of you could take a look at this and give some suggestions to have it run multiplatform (Windows and Mac) and have stylesheets for each like ie_win.css for IE on Windows and ie_mac.css for IE on Mac and so on. Thanks :) ?php $browser = getenv(HTTP_USER_AGENT); if (preg_match(/MSIE/i, $browser)) { $css = link rel=stylesheet href=ie_win.css type=text/css; } elseif (preg_match(/Mozilla/i, $browser)) { $css = link rel=stylesheet href=ns4_win.css type=text/css; } if (preg_match(/Mozilla\/5.0/i, $browser)) { $css = link rel=stylesheet href=ns6_win.css type=text/css; } elseif (preg_match(/opera/i, $browser)) { $css = link rel=stylesheet href=op_win.css type=text/css; } ? -- ___ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup Have you downloaded the latest calling software from Net2Phone? Click here to get it now! http://www.net2phone.com/cgi-bin/link.cgi?157 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] create table with php -whats wrong?
Hello all. I am trying to create simple test table with php, but I get: Parse error: parse error in /home/vanesaw/public_html/create.php on line 5 Line 5 is command to create table (see code below). Whats wrong with it? Thanks. ? $sql = mysql_connect(host, login, pass); mysql_select_db(dbname); CREATE TABLE test (id TINYINT not null AUTO_INCREMENT, process LONGTEXT not null , title LONGTEXT not null , description LONGTEXT not null , PRIMARY KEY (id)); ? done -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] create table with php -whats wrong?
Hello all. I am trying to create simple test table with php, but I get: Parse error: parse error in /home/vanesaw/public_html/create.php on line 5 Line 5 is command to create table (see code below). Whats wrong with it? Thanks. ? $sql = mysql_connect(host, login, pass); mysql_select_db(dbname); CREATE TABLE test (id TINYINT not null AUTO_INCREMENT, process LONGTEXT not null , title LONGTEXT not null , description LONGTEXT not null , PRIMARY KEY (id)); ? done Saulius, http://www.php.net/manual/en/function.mysql-query.php =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] create table with php -whats wrong?
Place your query in a string variable, like $sSql, and use the mysql_query command to execute the query. For example: $sSql=CREATE TABLE test (id TINYINT not null AUTO_INCREMENT, process LONGTEXT not null , title LONGTEXT not null , description LONGTEXT not null , PRIMARY KEY (id)); if (!mysql_query($sSql)) die (Could not create table); At 02:57 PM 10/28/2001, Saulius Jankauskas wrote: Hello all. I am trying to create simple test table with php, but I get: Parse error: parse error in /home/vanesaw/public_html/create.php on line 5 Line 5 is command to create table (see code below). Whats wrong with it? Thanks. ? $sql = mysql_connect(host, login, pass); mysql_select_db(dbname); CREATE TABLE test (id TINYINT not null AUTO_INCREMENT, process LONGTEXT not null , title LONGTEXT not null , description LONGTEXT not null , PRIMARY KEY (id)); ? done -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] Sliante, Richard S. Crawford http://www.mossroot.com mailto:[EMAIL PROTECTED] AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford It is only with the heart that we see rightly; what is essential is invisible to the eye. --Antoine de Saint Exupéry Push the button, Max! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] counting categories
How would you get the count of each category? Like this - http://www.scriptsearch.com Would you have to run a different select for each one? or would you do something like select category from $table and then count all of the matches for each category perl php asp thanks much, Josh __ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Application variables
php doesn't have application variables as such, however there are a couple options for implementing them... 1. have a single file with your application variables and manually include that in all files of the project 2. use the session_*() functions to keep the vars alive on pages 3. as you said, store to db and update once in a while (or a combination of these... i.e. 3 + 2, load from db, carry around in session and then save to db again) HTH beau // -Original Message- // From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] // Sent: Sunday, 28 October 2001 3:15 AM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] Application variables // // // Pls tell me how to implement application variables in PHP // like they are supported // in ASP else i might have to have the value stored in the // database and update // every now and then which is simply an overhead. // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, e-mail: [EMAIL PROTECTED] // For additional commands, e-mail: [EMAIL PROTECTED] // To contact the list administrators, e-mail: // [EMAIL PROTECTED] // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] counting categories
Hi, Depending on the database you are selecting from you could do it in one select like this: select category, count(*) from $table group by category order by category; - Frank How would you get the count of each category? Like this - http://www.scriptsearch.com Would you have to run a different select for each one? or would you do something like select category from $table and then count all of the matches for each category perl php asp thanks much, Josh __ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: php command to create table
mysql_query( CREATE TABLE abcd (FieldName1 INT (3) UNSIGNED DEFAULT '0' AUTO_INCREMENT, FieldName2 TINYINT (3) UNSIGNED DEFAULT '0', PRIMARY KEY(FieldName1), UNIQUE(FieldName1)) ); Saulius Jankauskas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... subj. Plz help. THanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] category structure
anyone have any ideas on this I have a table of directory categories id | parentid | category so... 1 | 0 | blah1 top 2 | 1 | blah2 sub 3 | 1 | blah3 sub2 4 | 3 | blah4 sub2-sub I want to hit the DB only once so i select all and drop into array Now i've created array with these like so: $category[$parentid][$id] But now what? trouble is that $msub[2][4] is a sub category of $msub[1][2] so i can't just run thru and print the array - need to manipulate a little. Any ideas? [or even a beeter way to do this?] thanks olinux __ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mySQL table update
I have a large table with quite many dates in format dd.mm. (don't ask why :) and I want to convert them into -mm-dd for obvious reasons. How can I do this the smartest way? I know I could do it with php and update it row by row but that doesn't seem too smart. Can I somehow do a copy from table to table at the same time? Like: Table 1: Name = John Doe Date1 = 01.01.2001 Date2 = 02.02.2001 Table 2: Name = NULL Date1 = -00-00 Date2 = -00-00 And now I want to set Table 2 to this: Name = John Doe Date1 = 2001-01-01 // Value from Table 1 Date2 = 2001-02-02 // Value from Table 1 At least tell me what to look for in the manual. :) Niklas
[PHP-DB] Oracle 9i
Hello, Has anyone managed to get PHP to link with Oracle9i? I suspect some Oracle 9 lib is OCI8-compatible, so it shouldn't be too hard to get this to work -- possibly a small change to the configure script. Unfortunately I don't know enough about Oracle to make this happen. A previous article on php-db suggested that someone had succeeded and reported on the success to php-install, but I haven't found any relevant solutions in the archives. Thanks! Juan [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Toronto php users group meeting.
www.realsoftstudio.com ... News Release ... PHP User Group Meeting Monday, Oct.29 at 7pm-10pm PHP SPINAL INJECTION TUTORIAL - When : Monday, Oct.29 at 7pm-10pm Where: Velocet Communications Inc. 210 Dundas street East (At University) suite 8000 (8th floor) Toronto ** If anybody has a 1024x768 capable SVGA projector they could possibly bring to this, please email me: [EMAIL PROTECTED] ** Cost : $1,000,000 per person (If you can't afford to pay that, we will let you in for free) Audience : HTML designers who want to get into writing dynamic web apps, weekend web warriors and experienced web developers who want to understand how PHP fits into the picture. Abstract : PHP is a popular scripting language designed specifically for creating web-based applications. The first half of this fast-paced tutorial, will quickly run through the basic characteristics and then move on to demonstrate how to use PHP to create images, pdf's and flash on the fly. In the second half things will get more complex with topics such as SQL, LDAP, XML, XSL/XSLT plus a peek into the internals of PHP's extension API if there is time. Attendees should have a basic understanding of HTML and the basic HTTP client/server model. For the latter topics a bit of advanced programming experience would be helpful but certainly not required. www.realsoftstudio.com begin 666 newslogo.gif M1TE.#EA+@`F`-4``)EFFR9S/_,_]RYW#,S9F9FF9F9S,S,_P`S,V:9F9G, MS,S___7__V:99IG,FS_S9F,YF99LS,F?__S-SN?__]68S,YEF9LR9F?_, MS-RYN?_U]?7U]S,S+FYN9F9F69F9C,S,P```/___P`` M M`'Y! $``0`+ `N`8```;_ M0))P2.(8CTA.Y9A).I'$:)3RJ5H[V.5 `NHZ,%^/V D:2Z-8SECMZ58[XKA M#,* N'/C?AA=^ @8!E7I[?4(2 A!Y/;'1_?VV$''L:CYHB(VTA'B(B M(2$8BV-K@W4-(*92#(];:%M')E( NBH!X$$:RLB )( !=95(;FFIE(XL9 M!8A1BV(Z4UURBQK=QY2$@(AP7(PXG6,@S:,H/PGJP%%ZU1'PN) MC L7!^125/':AVC;'064R X1(1#IF,.2I4J!$=-0H_)11HRN$0#GTR!*LD M4:*6*?$*/SUZ'#VWV(5$4R)C B1,\2SCL0@%_SIV-VD%\L1JT4@#NB\ MV;,(S%AJV' 0J:G+2D)-*DE8VO$AR#G[CZ@$N,`2YE%I15-*H73Y=EGG M@,#@DB1Q-1%N4!D5+8W6W[L(V?!`A 9E)(5J6 DQ:.BWC[\0/51A@R,MK% MH( S':$U=S*:#=0I,HD@Z8L2@VI8$@\QK!E6%46I$\Q2@P!JBUJ=L% M[2C,!Z]+9JG+4A=T3)D_@+7=4G*.V;Y$$8#Z0CL]JR@6(R=AVBNYZK4 MQID0;]O7\X9V[M,=NT*(@P71?[)VE$2-!='(FYEU)OECTE+]'0+ 8 M-Y$@G\VUH'\2?.)@([95:+M4A6)((A5]QDBA$8! !(V5P=QU[H'@P'W M4',/,$T1TMV#E02@2!=HV6 '1N))3)+019!7661`27Y4A):OEV0`))% M2%! %*R,LPB71[E9$DUVK*(B5Y5@E077=K3`$^E1!! 1 L,B56!812P`) MP'F31!%LR64!72HBRB@-Y0F;$3G9! *A?WY#)I2!*7K3( $H*@4[+5Q1Z@ :2@$)!],=924AMED:ZJJP3!4MBQ.D00`#L` ` end -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]