Jump to content


Photo

strip tag help, PLEASE


  • Please log in to reply
8 replies to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 23 October 2006 - 09:18 AM

i want to put strip tags around this text

<?
// 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";
}?>

this is the full code for the page...

<?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);
?>

can anyone help pleeeeeease.....?

#2 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 23 October 2006 - 09:30 AM

may i ask why you are ending your php then starting it again. and what do you want to do?
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#3 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 23 October 2006 - 09:33 AM

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!

#4 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 October 2006 - 09:42 AM

have you actually tried just putting strip_tags around the relevent part?

<?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";
}?>

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 substr as it's pretty common to use when showing a summary with a 'more' link/button.

ps: 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.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#5 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 23 October 2006 - 10:10 AM

thanks alot, you are right about the summary thing aswell!!  ;D

#6 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 23 October 2006 - 10:18 AM

how do i put like the .... in after this

#7 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 23 October 2006 - 11:02 AM

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:

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";
}

thanks a lot

#8 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 October 2006 - 11:43 AM

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:

<?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
?>

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
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#9 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 23 October 2006 - 12:10 PM

thanks a lot mate, that helped a lot




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users