Re: [PHP] While and echoing HTML
I guess it is the missing semicolon. And you can write: echo trtd? echo $product_type ?/td/tr as simply echo trtd$product_type/td/tr Prathap -- Original Message --- From: Mark Sargent [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tue, 10 May 2005 13:23:51 +0900 Subject: [PHP] While and echoing HTML Hi All, this page, http://www.freewebmasterhelp.com/tutorials/phpmysql/5 has the below code, ? $i=0; while ($i $num) { $first=mysql_result($result,$i,first); $last=mysql_result($result,$i,last); $phone=mysql_result($result,$i,phone); $mobile=mysql_result($result,$i,mobile); $fax=mysql_result($result,$i,fax); $email=mysql_result($result,$i,email); $web=mysql_result($result,$i,web); ? tr tdfont face=Arial, Helvetica, sans-serif? echo $first. .$last; ?/font/td tdfont face=Arial, Helvetica, sans- serif? echo $phone; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $mobile; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $fax; ?/font/td tdfont face=Arial, Helvetica, sans-serifa href=mailto:? echo $email; ?E-mail/a/font/td tdfont face=Arial, Helvetica, sans-serifa href=? echo $web; ?Website/a/font/td /tr ? $i++; } echo /table; which I basically understand, except the html generation. I am trying to create something similiar, although, I think there are some errors in even perhaps my logic..? html body h1centerJumbo Status/center/h1br ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $myrow = mysql_fetch_array($result); $num = mysql_num_rows($result); ? table aligh=center border=2 tr tdProduct Type/td /tr ? $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr } $i++ ? /table /body /html I get the folowing error, *Parse error*: parse error, unexpected '}', expecting ',' or ';' in */var/www/html/products.php* on line *20 * which is the $i++ section. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- End of Original Message --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
Mark Sargent [EMAIL PROTECTED] writes: $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr } $i++ You should put $i++ into the while loop. And you should add an ; at the end of the echo line as well as at the end of $i++. With kind regards, Fabian Müller -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
Prathaban Mookiah wrote: I guess it is the missing semicolon. And you can write: echo trtd? echo $product_type ?/td/tr as simply echo trtd$product_type/td/tr Prathap -- Original Message --- From: Mark Sargent [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tue, 10 May 2005 13:23:51 +0900 Subject: [PHP] While and echoing HTML Hi All, this page, http://www.freewebmasterhelp.com/tutorials/phpmysql/5 has the below code, ? $i=0; while ($i $num) { $first=mysql_result($result,$i,first); $last=mysql_result($result,$i,last); $phone=mysql_result($result,$i,phone); $mobile=mysql_result($result,$i,mobile); $fax=mysql_result($result,$i,fax); $email=mysql_result($result,$i,email); $web=mysql_result($result,$i,web); ? tr tdfont face=Arial, Helvetica, sans-serif? echo $first. .$last; ?/font/td tdfont face=Arial, Helvetica, sans- serif? echo $phone; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $mobile; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $fax; ?/font/td tdfont face=Arial, Helvetica, sans-serifa href=mailto:? echo $email; ?E-mail/a/font/td tdfont face=Arial, Helvetica, sans-serifa href=? echo $web; ?Website/a/font/td /tr ? $i++; } echo /table; which I basically understand, except the html generation. I am trying to create something similiar, although, I think there are some errors in even perhaps my logic..? html body h1centerJumbo Status/center/h1br ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $myrow = mysql_fetch_array($result); $num = mysql_num_rows($result); ? table aligh=center border=2 tr tdProduct Type/td /tr ? $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr } $i++ ? /table /body /html I get the folowing error, *Parse error*: parse error, unexpected '}', expecting ',' or ';' in */var/www/html/products.php* on line *20 * which is the $i++ section. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- End of Original Message --- Hi All, Thanx. I saw the extra echo and removed it. Problem with that code, though. It displays only the 1st record, repeatedly, causing the browser to hang. Can anyone see what is wrong..? Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
oh, and the i++ should be inside the while loop and there is also a missing semi colon after the echo, ie; $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr; $i++ ; } Mark Sargent wrote, On 10/05/05 02:23 PM: Hi All, this page, http://www.freewebmasterhelp.com/tutorials/phpmysql/5 has the below code, ? $i=0; while ($i $num) { $first=mysql_result($result,$i,first); $last=mysql_result($result,$i,last); $phone=mysql_result($result,$i,phone); $mobile=mysql_result($result,$i,mobile); $fax=mysql_result($result,$i,fax); $email=mysql_result($result,$i,email); $web=mysql_result($result,$i,web); ? tr tdfont face=Arial, Helvetica, sans-serif? echo $first. .$last; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $phone; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $mobile; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $fax; ?/font/td tdfont face=Arial, Helvetica, sans-serifa href=mailto:? echo $email; ?E-mail/a/font/td tdfont face=Arial, Helvetica, sans-serifa href=? echo $web; ?Website/a/font/td /tr ? $i++; } echo /table; which I basically understand, except the html generation. I am trying to create something similiar, although, I think there are some errors in even perhaps my logic..? html body h1centerJumbo Status/center/h1br ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $myrow = mysql_fetch_array($result); $num = mysql_num_rows($result); ? table aligh=center border=2 tr tdProduct Type/td /tr ? $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr } $i++ ? /table /body /html I get the folowing error, *Parse error*: parse error, unexpected '}', expecting ',' or ';' in */var/www/html/products.php* on line *20 * which is the $i++ section. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
quoth the Mark Sargent: snip html body h1centerJumbo Status/center/h1br ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $myrow = mysql_fetch_array($result); $num = mysql_num_rows($result); ? table aligh=center border=2 tr tdProduct Type/td /tr ? $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr You are already in a php block here. Why the '?' ? Try: echo trtd$product_type/td/tr; } $i++ As the error message is trying to tell you, php statements are terminated with semi-colons: $i++; ? /table /body /html I get the folowing error, *Parse error*: parse error, unexpected '}', expecting ',' or ';' in */var/www/html/products.php* on line *20 * which is the $i++ section. Cheers. Mark Sargent. -d -- darren kirby :: Part of the problem since 1976 :: http://badcomputer.org ...the number of UNIX installations has grown to 10, with more expected... - Dennis Ritchie and Ken Thompson, June 1972 pgpVCEzIs6ipf.pgp Description: PGP signature
Re: [PHP] While and echoing HTML
Hi Mark, As far as I can see the only problem is that you have forgotten to add a semicolon after the i++ Cheers, Mary-Anne Mark Sargent wrote, On 10/05/05 02:23 PM: Hi All, this page, http://www.freewebmasterhelp.com/tutorials/phpmysql/5 has the below code, ? $i=0; while ($i $num) { $first=mysql_result($result,$i,first); $last=mysql_result($result,$i,last); $phone=mysql_result($result,$i,phone); $mobile=mysql_result($result,$i,mobile); $fax=mysql_result($result,$i,fax); $email=mysql_result($result,$i,email); $web=mysql_result($result,$i,web); ? tr tdfont face=Arial, Helvetica, sans-serif? echo $first. .$last; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $phone; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $mobile; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $fax; ?/font/td tdfont face=Arial, Helvetica, sans-serifa href=mailto:? echo $email; ?E-mail/a/font/td tdfont face=Arial, Helvetica, sans-serifa href=? echo $web; ?Website/a/font/td /tr ? $i++; } echo /table; which I basically understand, except the html generation. I am trying to create something similiar, although, I think there are some errors in even perhaps my logic..? html body h1centerJumbo Status/center/h1br ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $myrow = mysql_fetch_array($result); $num = mysql_num_rows($result); ? table aligh=center border=2 tr tdProduct Type/td /tr ? $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr } $i++ ? /table /body /html I get the folowing error, *Parse error*: parse error, unexpected '}', expecting ',' or ';' in */var/www/html/products.php* on line *20 * which is the $i++ section. Cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
Mary-Anne Nayler wrote: oh, and the i++ should be inside the while loop and there is also a missing semi colon after the echo, ie; $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr; $i++ ; } Mark Sargent wrote, On 10/05/05 02:23 PM: Hi All, this page, http://www.freewebmasterhelp.com/tutorials/phpmysql/5 has the below code, ? $i=0; while ($i $num) { $first=mysql_result($result,$i,first); $last=mysql_result($result,$i,last); $phone=mysql_result($result,$i,phone); $mobile=mysql_result($result,$i,mobile); $fax=mysql_result($result,$i,fax); $email=mysql_result($result,$i,email); $web=mysql_result($result,$i,web); ? tr tdfont face=Arial, Helvetica, sans-serif? echo $first. .$last; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $phone; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $mobile; ?/font/td tdfont face=Arial, Helvetica, sans-serif? echo $fax; ?/font/td tdfont face=Arial, Helvetica, sans-serifa href=mailto:? echo $email; ?E-mail/a/font/td tdfont face=Arial, Helvetica, sans-serifa href=? echo $web; ?Website/a/font/td /tr ? $i++; } echo /table; which I basically understand, except the html generation. I am trying to create something similiar, although, I think there are some errors in even perhaps my logic..? html body h1centerJumbo Status/center/h1br ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $myrow = mysql_fetch_array($result); $num = mysql_num_rows($result); ? table aligh=center border=2 tr tdProduct Type/td /tr ? $i=0; while ($i $num){ $product_type=mysql_result($result,$i,product_type_detail); echo trtd? echo $product_type ?/td/tr } $i++ ? /table /body /html I get the folowing error, *Parse error*: parse error, unexpected '}', expecting ',' or ';' in */var/www/html/products.php* on line *20 * which is the $i++ section. Cheers. Mark Sargent. Hi All, yes, changed it a little. Works fine now. Suprised at how much I've forgotten about HTML too. Cheers. Mark Sargent. html body h1centerJumbo Status/center/h1br table aligh=center border=2 tr tdProduct Type/td /tr ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); $num = mysql_num_rows($result); for ($i=0; $i$num; $i++){ $myrow = mysql_fetch_array($result); $product_type=mysql_result($result,$i,product_type_detail); echo trtd$product_type/td/tr; } ? /table /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
On Mon, May 9, 2005 10:57 pm, Mark Sargent said: Thanx. I saw the extra echo and removed it. Problem with that code, though. It displays only the 1st record, repeatedly, causing the browser to hang. Can anyone see what is wrong..? Cheers. Everybody else has told you to move the $i++; inside the while { } loop. I'm not gonna tell you that. I'm gonna tell you to get out a pencil and some paper, and walk through your code, writing down exactly what data goes where, in which variables, on each line. Make yourself a nice big wide columnar sheet of paper tracking each variable. LINE | $db | $result | $myrow | $num | $i | $product_type | 1 2 3 4 5 | db-link | 6 7 || db-result | . . . You need to do this. Trust me. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] While and echoing HTML
Mary-Anne Nayler wrote: Hi Mark, As far as I can see the only problem is that you have forgotten to add a semicolon after the i++ Mark: Since you are not displaying the counter, you really don't need to mess with $i. You can reduce your code to just : ?php $db = mysql_connect(localhost, root, grunger); mysql_select_db(status,$db); $result = mysql_query(SELECT ProductTypes.product_type_detail FROM ProductTypes,$db); ? table aligh=center border=2 tr tdProduct Type/td /tr ?php while($myrow = mysql_fetch_assoc($result)) echo trtd.$row['product_type']./td/tr; } ? /table /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] While and echoing HTML
I guess it is the missing semicolon. And you can write: echo trtd? echo $product_type ?/td/tr as simply echo trtd$product_type/td/tr I prefer echo 'trtd', $product_type, '/td/tr'; No string concatenation, or variable replacement required. Jared -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php