Jump to content

Archived

This topic is now archived and is closed to further replies.

ltoto

strip tag help, PLEASE

Recommended Posts

i want to put strip tags around this text

[code]<?
// List the hotels
echo "> <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]<?php
mysql_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 hotels
echo "> <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.....?

Share this post


Link to post
Share on other sites
may i ask why you are ending your php then starting it again. and what do you want to do?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
have you actually tried just putting [url=http://uk2.php.net/strip_tags]strip_tags[/url] around the relevent part?

[code]
<?php
// List the hotels
echo "> <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.

Share this post


Link to post
Share on other sites
thanks alot, you are right about the summary thing aswell!!  ;D

Share this post


Link to post
Share on other sites
apologies for the triple post, i cant delete my posts

i 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 off

this 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

Share this post


Link to post
Share on other sites
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'd

cheers
Mark

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.