[PHP] Syntax Help, Please
I've forgotten how to assign something like this... $someStr = EOF bunch of raw non-echo'd html EOF; But can't seem to get the right syntax. Tried looking in the manual, but don't even know what I'm looking for! TIA, Steve
RE: [PHP] Syntax Help, Please
I've forgotten how to assign something like this... $someStr = EOF bunch of raw non-echo'd html EOF; But can't seem to get the right syntax. Tried looking in the manual, but don't even know what I'm looking for! You're looking for a heredoc. http://www.php.net/manual/en/language.types.string.php#language.types.string .syntax.heredoc Cheers, Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax Help, Please
In a message dated 6/15/2004 10:20:59 AM Pacific Daylight Time, [EMAIL PROTECTED] writes: I've forgotten how to assign something like this... $someStr = EOF bunch of raw non-echo'd html EOF; But can't seem to get the right syntax. Tried looking in the manual, but don't even know what I'm looking for! This way of entering text is called a heredoc. The syntax goes like this: $varname = ENDSTRING text ENDSTRING; ENDSTRING is any string you want, typed both at the beginning and at the end of the string. The first ENDSTRING must be at the end of the first line, with nothing following it, not even a space. And the ENDSTRING on the last line must be at the start of the line, with nothing before it, not even a space, and nothing following it other than the semicolon. Janet - Janet Valade, author, PHP MySQL for Dummies; PHP 5 for Dummies -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax Help, Please
On Tue, 15 Jun 2004 13:20:24 -0400, Steve Douville [EMAIL PROTECTED] wrote: I've forgotten how to assign something like this... $someStr = EOF bunch of raw non-echo'd html EOF; But can't seem to get the right syntax. Tried looking in the manual, but don't even know what I'm looking for! ?php $someStr = EOF anything you want EOF; ? Here they are in the manual: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] syntax help please?
I'm coming over from the ASP side and I'm trying to get a handle on this stuff, I could use a little help with the how and wheres, please. I do ok with the SQl bits, but the PHP bits are still being elusive... Heres my code: $sql = SELECT listnum,agentname,listAgent,streetName,streetNum,curprice,email_addr,officen ame,officephone,agentname,agentphone,bedrooms,full_baths,half_baths,customer Remarks FROM mlsdb WHERE mlsdb.statusCode = 'A' AND mlsdb.catgNum = '1'; $result = mysql_query($sql); //load it all into the associative array while(list($listnum,$agentname,$streetName,$streetNum) = mysql_fetch_row($result)): echo $listnum $agentname $streetNum $streetName br; endwhile; ? Which displays: 50730 Aubrey May Wyndwood Drive 0 873171 Tia Lingle Palm Trl 9903 902385 Anthony Kipen Normandy Blvd 6458 ... As you can see the $streetNum displays BEFORE the $streetName, I'm assuming thats becuase thats the order they are in in the query..(?) Heres my I'm a newbie question... exactly how and where do I define the variables so that i can use them in a different order than they are in the query? -- PHP General 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] syntax help please?
On Wednesday 29 August 2001 14:45, Glyndower wrote: Heres my I'm a newbie question... exactly how and where do I define the variables so that i can use them in a different order than they are in the query? Go over your results like this instead: while ($row = mysql_fetch_row($result)) { echo $row['listnum']; // displays 'listnum' field echo $row['officephone']; // etc... } (I've assumed your syntax for the mysql_fetch_row() function, I haven't used it in a while (use PostgreSQL myself)). ad -- PHP General 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] syntax help please?
On Thu, 30 Aug 2001 00:15, Glyndower wrote: I'm coming over from the ASP side and I'm trying to get a handle on this stuff, I could use a little help with the how and wheres, please. I do ok with the SQl bits, but the PHP bits are still being elusive... Heres my code: $sql = SELECT listnum,agentname,listAgent,streetName,streetNum,curprice,email_addr,of ficen ame,officephone,agentname,agentphone,bedrooms,full_baths,half_baths,cus tomer Remarks FROM mlsdb WHERE mlsdb.statusCode = 'A' AND mlsdb.catgNum = '1'; $result = mysql_query($sql); //load it all into the associative array while(list($listnum,$agentname,$streetName,$streetNum) = mysql_fetch_row($result)): echo $listnum $agentname $streetNum $streetName br; endwhile; ? Which displays: 50730 Aubrey May Wyndwood Drive 0 873171 Tia Lingle Palm Trl 9903 902385 Anthony Kipen Normandy Blvd 6458 ... As you can see the $streetNum displays BEFORE the $streetName, I'm assuming thats becuase thats the order they are in in the query..(?) Heres my I'm a newbie question... exactly how and where do I define the variables so that i can use them in a different order than they are in the query? Use extract ,which makes available variables of the same name as the fields in your table. $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { extract($row); echo $listnum $agentname $streetNum $streetName br; } -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Oxymoron: Weather Forecast. -- PHP General 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]