Re: [PHP] please help, simple problem (i think)
Hi, Basically I am offering some packages and I want to say: These are the following packages with your account: package1 (-$row1-) package2 (-$row2-) package3 (-$row3-) package4 (-$row4-) package5 (-$row5-) how to do it? Thanks, -Ryan Maybe you should tell us what you really want to do? Usually you don't just assign a row value to a variable. Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 8:54 PM To: [EMAIL PROTECTED] Subject: [PHP] please help, simple problem (i think) Hi, Feeling a little braindead, please help. The below program as you can see is extremly simple, it connects to the database and runs a select (COUNT) query, this query will return 5 rows...so far so good, everything is working but I have no idea how to assign each of the rows to a variable so I can use it... something like: $one=$row[1]; $two=$row[2]; $thr=$row[3]; heres the code: ?php require configbwh.php; $connected=mysql_connect ($hostt, $userr, $passs) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db); $tt = SELECT ptype, count(*) FROM mylist WHERE ptype IN ('1', '2', '3', '4','5') GROUP BY ptype; if($res= mysql_query($tt)) { while($row = mysql_fetch_row($res)) { print($row[1]); } } ? Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] please help, simple problem (i think)
I guess you mean something like : ? $result=mysql_query(Select PackageName FROM Packages ORDER BY PackageName) or die(mysql_error()); While($row = mysql_fetch_object($result)) { Echo$row-PackageName BR; } ? Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 9:06 PM To: Boaz Yahav Cc: [EMAIL PROTECTED] Subject: Re: [PHP] please help, simple problem (i think) Hi, Basically I am offering some packages and I want to say: These are the following packages with your account: package1 (-$row1-) package2 (-$row2-) package3 (-$row3-) package4 (-$row4-) package5 (-$row5-) how to do it? Thanks, -Ryan Maybe you should tell us what you really want to do? Usually you don't just assign a row value to a variable. Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 8:54 PM To: [EMAIL PROTECTED] Subject: [PHP] please help, simple problem (i think) Hi, Feeling a little braindead, please help. The below program as you can see is extremly simple, it connects to the database and runs a select (COUNT) query, this query will return 5 rows...so far so good, everything is working but I have no idea how to assign each of the rows to a variable so I can use it... something like: $one=$row[1]; $two=$row[2]; $thr=$row[3]; heres the code: ?php require configbwh.php; $connected=mysql_connect ($hostt, $userr, $passs) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db); $tt = SELECT ptype, count(*) FROM mylist WHERE ptype IN ('1', '2', '3', '4','5') GROUP BY ptype; if($res= mysql_query($tt)) { while($row = mysql_fetch_row($res)) { print($row[1]); } } ? Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] please help, simple problem (i think)
Hi, I dont have packageName therejust id,type Plus i need to do this in 2 placesso if i could assign each counts result to a variable...it would be reay easy. Cheers, -Ryan - Original Message - From: Boaz Yahav [EMAIL PROTECTED] To: Ryan A [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, June 07, 2003 8:11 PM Subject: RE: [PHP] please help, simple problem (i think) I guess you mean something like : ? $result=mysql_query(Select PackageName FROM Packages ORDER BY PackageName) or die(mysql_error()); While($row = mysql_fetch_object($result)) { Echo$row-PackageName BR; } ? Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 9:06 PM To: Boaz Yahav Cc: [EMAIL PROTECTED] Subject: Re: [PHP] please help, simple problem (i think) Hi, Basically I am offering some packages and I want to say: These are the following packages with your account: package1 (-$row1-) package2 (-$row2-) package3 (-$row3-) package4 (-$row4-) package5 (-$row5-) how to do it? Thanks, -Ryan Maybe you should tell us what you really want to do? Usually you don't just assign a row value to a variable. Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 8:54 PM To: [EMAIL PROTECTED] Subject: [PHP] please help, simple problem (i think) Hi, Feeling a little braindead, please help. The below program as you can see is extremly simple, it connects to the database and runs a select (COUNT) query, this query will return 5 rows...so far so good, everything is working but I have no idea how to assign each of the rows to a variable so I can use it... something like: $one=$row[1]; $two=$row[2]; $thr=$row[3]; heres the code: ?php require configbwh.php; $connected=mysql_connect ($hostt, $userr, $passs) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db); $tt = SELECT ptype, count(*) FROM mylist WHERE ptype IN ('1', '2', '3', '4','5') GROUP BY ptype; if($res= mysql_query($tt)) { while($row = mysql_fetch_row($res)) { print($row[1]); } } ? Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] please help, simple problem (i think)
This was just an example :) You can do : ? $result=mysql_query(Select * FROM Packages) or die(mysql_error()); While($row = mysql_fetch_object($result)) { Echopackage . $row-id : $row-type BR; } ? You can reuse $result if you need to or you can just assign it all to a variable and dump it multiple times down the page... up to you Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 9:13 PM To: Boaz Yahav Cc: [EMAIL PROTECTED] Subject: Re: [PHP] please help, simple problem (i think) Hi, I dont have packageName therejust id,type Plus i need to do this in 2 placesso if i could assign each counts result to a variable...it would be reay easy. Cheers, -Ryan - Original Message - From: Boaz Yahav [EMAIL PROTECTED] To: Ryan A [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, June 07, 2003 8:11 PM Subject: RE: [PHP] please help, simple problem (i think) I guess you mean something like : ? $result=mysql_query(Select PackageName FROM Packages ORDER BY PackageName) or die(mysql_error()); While($row = mysql_fetch_object($result)) { Echo$row-PackageName BR; } ? Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 9:06 PM To: Boaz Yahav Cc: [EMAIL PROTECTED] Subject: Re: [PHP] please help, simple problem (i think) Hi, Basically I am offering some packages and I want to say: These are the following packages with your account: package1 (-$row1-) package2 (-$row2-) package3 (-$row3-) package4 (-$row4-) package5 (-$row5-) how to do it? Thanks, -Ryan Maybe you should tell us what you really want to do? Usually you don't just assign a row value to a variable. Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 8:54 PM To: [EMAIL PROTECTED] Subject: [PHP] please help, simple problem (i think) Hi, Feeling a little braindead, please help. The below program as you can see is extremly simple, it connects to the database and runs a select (COUNT) query, this query will return 5 rows...so far so good, everything is working but I have no idea how to assign each of the rows to a variable so I can use it... something like: $one=$row[1]; $two=$row[2]; $thr=$row[3]; heres the code: ?php require configbwh.php; $connected=mysql_connect ($hostt, $userr, $passs) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db); $tt = SELECT ptype, count(*) FROM mylist WHERE ptype IN ('1', '2', '3', '4','5') GROUP BY ptype; if($res= mysql_query($tt)) { while($row = mysql_fetch_row($res)) { print($row[1]); } } ? Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] please help, simple problem (i think)
Feeling a little braindead, please help. You post here more than I do. The below program as you can see is extremly simple, it connects to the database and runs a select (COUNT) query, this query will return 5 rows...so far so good, everything is working but I have no idea how to assign each of the rows to a variable so I can use it... something like: $one=$row[1]; $two=$row[2]; $thr=$row[3]; heres the code: ?php require configbwh.php; $connected=mysql_connect ($hostt, $userr, $passs) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db); $tt = SELECT ptype, count(*) FROM mylist WHERE ptype IN ('1', '2', '3', '4','5') GROUP BY ptype; if($res= mysql_query($tt)) { while($row = mysql_fetch_row($res)) { print($row[1]); $var[$row[0]] = $row[1]; Now $var is an array such as $var[type 1] = count 1 $var[type 2] = count 2 To cycle through and display it: foreach($var as $key = $value) { echo $key : $value; } ---John W. Holmes... Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php