Jump to content

Archived

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

ltoto

php & div tag help please

Recommended Posts

I want to style the $name in this, so i want to put a div ta around it, but I am unsure of how to put the div tag or where to put it
[code]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\">"; 
 
   
// List the hotels
  echo "$image  $name  $rating  $description<br>
  \n";
}[/code]

any suggestions?

Share this post


Link to post
Share on other sites
try this
[code]
<?php
echo "<div id='blah'>".$image." ".$rating." ".$description."</div><br />\n";
?>
[/code]

Share this post


Link to post
Share on other sites
If it is just the name, and not rating and description, use a span
[code]
echo "$image  <span class='name'>$name</span>  $rating  $description<br>";
[/code]

Share this post


Link to post
Share on other sites
im going to style each one  i did this

[code]echo "<div class="content">".$image." ".$rating." ".$description."</div><br />\n";[/code]

but i got a parse error which is this

Parse error: parse error, unexpected T_STRING, expecting ',' or ';'

Share this post


Link to post
Share on other sites
you can't put " in a string contained within "s

use
echo "<div class=\"content\">".$image." ".$rating." ".$description."</div><br />\n";

or
echo "<div class='content'>".$image." ".$rating." ".$description."</div><br />\n";

Share this post


Link to post
Share on other sites
so if i wanted to put a new div tag in id say do this

echo  "<div class='country'>".$image." ".$name." ".$rating." <div class='description'>".$description."</div>
\n";

Share this post


Link to post
Share on other sites
You have a /div tag missing to indicate where the 'country' div ends.

Also, DIV is a block construct and will force a new line (unless you float them). If you want them on the same line use span tags.

Share this post


Link to post
Share on other sites
i did this after your advice

echo  "<div class='\country\'>".$image."
<div class='\homebar2\'>".$name."
".$rating."
".$description."</div>
\n";
}

but it brings the footer up for some reason

Share this post


Link to post
Share on other sites
Which advice was that, then? To put in the missing /div tag or to use span?

Share this post


Link to post
Share on other sites
i made the mistake sorry just spotted it, i did something wrong is the rs, now its just being a nightmare to line up

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.