Jump to content

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.....?
Link to comment
https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/
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.
Link to comment
https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113043
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
Link to comment
https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113067
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
Link to comment
https://forums.phpfreaks.com/topic/24818-strip-tag-help-please/#findComment-113083
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.