ltoto Posted October 23, 2006 Share Posted October 23, 2006 i want to put strip tags around this text[code]<?// List the hotelsecho "> <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>\n";}?>[/code]this is the full code for the page...[code]<?phpmysql_select_db($database_conTotal, $conTotal);$query_rsHotels = "SELECT * FROM tabHotel WHERE hotelType = 'hotelType'";$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());$row_rsHotels = mysql_fetch_assoc($rsHotels);$totalRows_rsHotels = mysql_num_rows($rsHotels);$sql="SELECT * FROM tabHotel WHERE regionId = $id";$result = mysql_query($sql);if (!$result) { die('Invalid query: ' . mysql_error());}while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $name = $row['hotelName']; $description = $row['hotelDescription']; $rating = $row['hotelRating']; $image = "<img src=\"../thumb/phpThumb.php?src=../images/hotel_{$row['hotelImage']}&w=100&h=100&zc=1\" alt=\"Hotel\">"; ?><?if ($row['hotelRating'] == 3){$star = "../images/star3.jpg";}else if ($row['hotelRating'] == 4){$star = "../images/star4.jpg";}else if ($row['hotelRating'] == 5){$star = "../images/star5.jpg";}?><?// List the hotelsecho "> <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>\n";}?><? mysql_free_result($rsHotels);?>[/code]can anyone help pleeeeeease.....? Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/ Share on other sites More sharing options...
JasonLewis Posted October 23, 2006 Share Posted October 23, 2006 may i ask why you are ending your php then starting it again. and what do you want to do? Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113036 Share on other sites More sharing options...
ltoto Posted October 23, 2006 Author Share Posted October 23, 2006 sorry, I dunno y i pu them in, what i want to do is strip the $description part to, and then they can click on a more info button the read more about that page! Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113039 Share on other sites More sharing options...
redbullmarky Posted October 23, 2006 Share Posted October 23, 2006 have you actually tried just putting [url=http://uk2.php.net/strip_tags]strip_tags[/url] around the relevent part?[code]<?php// List the hotelsecho "> <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".strip_tags($description)."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>\n";}?>[/code]however, i have a nagging feeling that when you say 'strip tag' and 'more info button', you actually want to limit the amount of text that shows in the description, like just a summary?if so, have a look at [url=http://uk2.php.net/substr]substr[/url] as it's pretty common to use when showing a summary with a 'more' link/button.[b]ps:[/b] the open/closing php tags for no reason are caused by Dreamweaver after you've inserted several of their built-in server behaviours. if you see back to back tags, you can safely get rid of them to tidy things up a little. Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113043 Share on other sites More sharing options...
ltoto Posted October 23, 2006 Author Share Posted October 23, 2006 thanks alot, you are right about the summary thing aswell!! ;D Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113049 Share on other sites More sharing options...
ltoto Posted October 23, 2006 Author Share Posted October 23, 2006 how do i put like the .... in after this Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113054 Share on other sites More sharing options...
ltoto Posted October 23, 2006 Author Share Posted October 23, 2006 apologies for the triple post, i cant delete my postsi didnt explain my self clear in the post above, when i say the ... bit i mean so it goes like this....ggrtretertertett.... when it cuts the text offthis is my code at the moment:[code]echo "> <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".substr($description, 0, 300);"</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>\n";}[/code]thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113067 Share on other sites More sharing options...
redbullmarky Posted October 23, 2006 Share Posted October 23, 2006 i kinda feel that the way you've presented your code there is gonna make it hard on you to get your head around. if you're gonna open/close php tags, then close PHP and use HTML in this case:[code]<?php...blahblahblah?><div class="homebar2"><h1><?php echo $name; ?></h1></div><div class="hotel"><?php echo $image; ?></div><div class="hotelcontent"><?php echo substr($description, 0, 300); ?>...</div><h3><img src="<?php echo $star; ?>" hspace="2"></h3><?php}... blahblahblah?>[/code]that'll make it a million times easier to debug/change in the future and you'll see that all i've done is added three dots right after the description is echo'dcheersMark Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113083 Share on other sites More sharing options...
ltoto Posted October 23, 2006 Author Share Posted October 23, 2006 thanks a lot mate, that helped a lot Quote Link to comment https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113089 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.