Jump to content


Photo

php & div tag help please


  • Please log in to reply
10 replies to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 09:56 AM

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

any suggestions?

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 September 2006 - 10:32 AM

try this
<?php
echo "<div id='blah'>".$image." ".$rating." ".$description."</div><br />\n";
?>

Tell me the problem, I will try tell you the solution

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 19 September 2006 - 10:40 AM

If it is just the name, and not rating and description, use a span
echo "$image   <span class='name'>$name</span>   $rating  $description<br>";

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 10:44 AM

im going to style each one  i did this

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

but i got a parse error which is this

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

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 19 September 2006 - 10:48 AM

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";
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 10:53 AM

add they work now, thanks a lot

#7 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 10:59 AM

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

#8 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 19 September 2006 - 11:07 AM

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.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#9 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 12:12 PM

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

#10 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 19 September 2006 - 01:24 PM

Which advice was that, then? To put in the missing /div tag or to use span?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#11 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 19 September 2006 - 01:25 PM

i made the mistake sorry just spotted it, i did something wrong is the rs, now its just being a nightmare to line up




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users