[PHP-DB] another PHP Sql question...
I am querying a database just fine. Getting back what I expect, just fine. But now I've been thrown a wrench in the form of double row display. my client wants... a b c d e f ... Well, I've reached the end on my PHP/SQL knowledge (which really isn't all that far!) Right now I'm doing (very much shortened)... // Query the database $result = $db-query($strSql); // Always check that $result is not an error if (DB::isError($result)) die ($result-getMessage()); while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A . 'br /'; } OK, this is fine for a straight list! But I need to create... tr tdrow_1/feild_A/td tdrow_1/feild_B/td /tr tr tdrow_2/feild_A/td tdrow_2/feild_B/td /tr ... And using the method of WHILE() doesn't cut it. Can some one enlighten me what syntax can I use to hit 2 rows at a time? Thanks Walter -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] another PHP Sql question...
I'm not sure i understand the problem. Do a,c,e come from one query result and b,d,f from another? If it's all from the same query why not do : $result=mysql_query(. TABLE While($row = mysql_fetch_object($result)) { EchoTRTD$row-feild_A/TDTD$row-feild_B/TD/TR; } /TABLE Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. Share your code : http://addexample.weberdev.com Search for PHP Code from your browser http://toolbar.weberdev.com -Original Message- From: jsWalter [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2003 8:14 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] another PHP Sql question... I am querying a database just fine. Getting back what I expect, just fine. But now I've been thrown a wrench in the form of double row display. my client wants... a b c d e f ... Well, I've reached the end on my PHP/SQL knowledge (which really isn't all that far!) Right now I'm doing (very much shortened)... // Query the database $result = $db-query($strSql); // Always check that $result is not an error if (DB::isError($result)) die ($result-getMessage()); while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A . 'br /'; } OK, this is fine for a straight list! But I need to create... tr tdrow_1/feild_A/td tdrow_1/feild_B/td /tr tr tdrow_2/feild_A/td tdrow_2/feild_B/td /tr ... And using the method of WHILE() doesn't cut it. Can some one enlighten me what syntax can I use to hit 2 rows at a time? Thanks Walter -- 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] another PHP Sql question...
Boaz Yahav [EMAIL PROTECTED] wrote in message I'm not sure i understand the problem. a,c,e come from one query result and b,d,f from another? No, they all come from the same table, but the same field name but from different rows of the database. If it's all from the same query why not do : reult=mysql_query(. TABLE While($row = mysql_fetch_object($result)) { EchoTRTD$row-feild_A/TDTD$row-feild_B/TD/TR; } /TABLE This method does not grap data from 2 rows at atime. I examined my example and noticed I goofed, it should have read... ... tr tdrow_1/field_A/td tdrow_2/field_A/td /tr tr tdrow_3/field_A/td tdrow_4/field_A/td /tr Same field, but diffeent rows. Sorry for the confusion. Walter -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] another PHP Sql question...
One question: Do you mean that a b are from the same column but are row 1 2 from your query result.? If so, you can possibly write a loop like so Dump all your records in an array; Start loop for as long you find records in array { Take the first record from your array and dump it into a variable (var1); Move the value from the variable var1 to another variable (var2); If both variables are set { Print the two variables with the html tags you want; Unset both variables; } } Add a handler to make sure you get the last records if it happens to be an od number off records; You'll have to do your own coding around this logic. Good luck Jack -Original Message- From: jsWalter [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2003 9:46 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] another PHP Sql question... Boaz Yahav [EMAIL PROTECTED] wrote in message I'm not sure i understand the problem. a,c,e come from one query result and b,d,f from another? No, they all come from the same table, but the same field name but from different rows of the database. If it's all from the same query why not do : reult=mysql_query(. TABLE While($row = mysql_fetch_object($result)) { EchoTRTD$row-feild_A/TDTD$row-feild_B/TD/TR; } /TABLE This method does not grap data from 2 rows at atime. I examined my example and noticed I goofed, it should have read... ... tr tdrow_1/field_A/td tdrow_2/field_A/td /tr tr tdrow_3/field_A/td tdrow_4/field_A/td /tr Same field, but diffeent rows. Sorry for the confusion. Walter -- 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] another PHP Sql question...
You can do: while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A . 'nbsp'; $row = $result-fetchRow(DB_FETCHMODE_ASSOC); extract ($row); echo $feild_A . 'br /'; } Tiberiu - Original Message - From: jsWalter [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, August 29, 2003 8:14 AM Subject: [PHP-DB] another PHP Sql question... I am querying a database just fine. Getting back what I expect, just fine. But now I've been thrown a wrench in the form of double row display. my client wants... a b c d e f ... Well, I've reached the end on my PHP/SQL knowledge (which really isn't all that far!) Right now I'm doing (very much shortened)... // Query the database $result = $db-query($strSql); // Always check that $result is not an error if (DB::isError($result)) die ($result-getMessage()); while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A . 'br /'; } OK, this is fine for a straight list! But I need to create... tr tdrow_1/feild_A/td tdrow_1/feild_B/td /tr tr tdrow_2/feild_A/td tdrow_2/feild_B/td /tr ... And using the method of WHILE() doesn't cut it. Can some one enlighten me what syntax can I use to hit 2 rows at a time? Thanks Walter -- 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] another PHP Sql question...
At 09:33 AM 8/29/2003, you wrote: You can do: while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A . 'nbsp'; $row = $result-fetchRow(DB_FETCHMODE_ASSOC); extract ($row); echo $feild_A . 'br /'; } close, but doesn't handle odd row counts... while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A; if( $row = $result-fetchRow(DB_FETCHMODE_ASSOC) ) { extract ($row); echo 'nbsp' . $feild_A . 'br /'; } else { echo 'br /'; /* optionally, add a 'last' here to skip extra db-call */ } } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] another PHP Sql question...
At 09:33 AM 8/29/2003, you wrote: You can do: while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A . 'nbsp'; $row = $result-fetchRow(DB_FETCHMODE_ASSOC); extract ($row); echo $feild_A . 'br /'; } close, but doesn't handle odd row counts... while ($row = $result-fetchRow(DB_FETCHMODE_ASSOC)) { extract ($row); echo $feild_A; if( $row = $result-fetchRow(DB_FETCHMODE_ASSOC) ) { extract ($row); echo 'nbsp' . $feild_A . 'br /'; } else { echo 'br /'; /* optionally, add a 'last' here to skip extra db-call */ } } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php