Re: Seperate strings in PHP WORKS

From: Date: Wed, 03 Jan 2001 21:05:35 +0000
Subject: Re: Seperate strings in PHP WORKS
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-32547@lists.php.net to get a copy of this message
Thanks Philip, With all your help it has come together and works sweet. The only problem I have come across now, is if the car has no specs in mysql it try's to display an image called .gif. So I have made it that if no images in the dbase it must read 0, in which it returns a blank gif image called 0.gif. Apart from that it is working really well. Thanks again Chris "Philip Olson" <philip@theprojects.org> wrote in message news:Pine.BSF.4.10.10101030440280.97715-100000@localhost... : Hey Chris- : : foreach will only work in php3. In the manual : : : PHP Manual : foreach : http://www.php.net/manual/control-structures.foreach.php : : An example is given that can "replace" the foreach structure shown below : with an alternative use of while statement. Do that. So (although you : must edit this with image info) : : : reset ($features); : while (list(, $feature) = each ($features)) { : echo "<br>$feature \n"; : } : : Although you won't be using foreach, it is noted that the provided example : was not copied correctly, $features was meant to be $features, not : $feature. $features is an array, $feature is a piece of that array. : Perhaps this is not optimal way to explain this to a newbie in initial : reply :-) But it happened. : : Also, fix your table! : : echo '</td></tr></table>'; : : That's much more acceptable and most likely a typo. That's all I can : think of, good luck! : : : Regards, : : Philip Olson : http://www.cornado.com/ : : : : On Wed, 3 Jan 2001, Sefton wrote: : : > I have had a chance to give the code below a try but it doesn't work. : > : > ++++++++++++++++++++++++++++++++ : > // I decided to go with a space ' ' instead of a comma , in mysql : > // Hence the use of the space in the $feature line. : > //$myrow[10] is the array used to aquire the information : > //from the mysql database : > : > echo "<table><tr><td>"; : > : > $feature = explode(' ',$myrow[10]); : > : > foreach ($feature as $feature){ : > print '<img src="images/'.$feature.'.gif">'; : > } : > : > echo "</table></tr></td>"; : > +++++++++++++++++++++++++++++++++ : > In the PHP manual it mentions something about a limit being added to php4. : > My service provider is still using php3. Will this make a difference, if so, : > how do i overcome it? : > : > ""Sefton"" <c.sefton@xtra.co.nz> wrote in message : > news:92tak0$v9p$1@toye.p.sourceforge.net... : > : Hello Everybody, : > : : > : Happy New Year !!! : > : : > : I have a question that to the skilled is probably very basic. : > : : > : Within a mysql database I have a field that holds the following type of : > : information... : > : : > : ac,pw,ps,rc,cd,aw,rs,4wd,abs etc : > : : > : It is the features of a car, and the field name is "specs" (Eg ac = air : > : conditioning, pw = power steer etc) : > : I don't want an indivual field for all the different features, but I want : > to : > : be able to break up the above string and place an image in my page for : > that : > : abreviation. I have the rest sorted out the vehicle make model etc I just : > : need to display these. I already have the images (eg: ac.gif) : > : Different vehicles will have different numbers of specs. Some might only : > : have ac,pw,ps. : > : : > : Example : > : I would like the above string to appear something like... : > : echo "<img src=\"images/$myrow[10].gif\">"; : > : : > : I am not sure how to continue it. Let alone split the string. I assume : > : converting the string to an array would work, but I am not sure how. Is : > : there an opposite to the implode command where I could specify the "," as : > a : > : break? : > : : > : Any help would be really great. : > : : > : Thanks, : > : : > : Chris : > : : > : : > : : > : -- : > : PHP General Mailing List (http://www.php.net/) : > : To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net : > : For additional commands, e-mail: php-general-help@lists.php.net : > : To contact the list administrators, e-mail: php-list-admin@lists.php.net : > : : > : > : > : > -- : > PHP General Mailing List (http://www.php.net/) : > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net : > For additional commands, e-mail: php-general-help@lists.php.net : > To contact the list administrators, e-mail: php-list-admin@lists.php.net : > : : : -- : PHP General Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net : For additional commands, e-mail: php-general-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net :

« previous php.general (#32547) next »