Jump to content

Using HTML Inside PHP


justlukeyou

Recommended Posts

Hi,

 

Im a echo out insider {} however when I try and add CSS it just creates an error as it dislikes the HTML.

 

I have tried this but it doesn't like it.  Is there a certain formar to using html inside PHP?

 

echo '<div class="productimageborder"><a href="product.php?price=' . $query_row['name'] . '</div>';

 

 

$pages_query = mysql_query("SELECT COUNT(`name`) FROM `productdbase`");
$pages = mysql_result($pages_query, 0);
$pages = ceil(mysql_result($pages_query, 0) / $per_page);

$page = (isset($_GET['page'])) ?  (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_page;

$query_string = "SELECT `name`, `rrp`, `image_link`, `image_link`, `discount` FROM `productdbase` LIMIT $start, $per_page";
$query = mysql_query($query_string);

while ($query_row = mysql_fetch_assoc($query)) {


echo '<p>', $query_row['name'] ,'</p>';

echo '<p>', $query_row['rrp'] ,'</p>';

echo '<p>', $query_row['image_link'] ,'</p>';

echo '<p>', $query_row['name'] ,'</p>';





}

if ($pages >= 1 && $page <= $pages) {
for ($x=1; $x<=$pages; $x++) {
echo ($x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ' : '<a href="?page='.$x.'">'.$x.'</a> ';
}
}

Link to comment
https://forums.phpfreaks.com/topic/263445-using-html-inside-php/
Share on other sites

Thanks,

 

Im been playing with a bit more and now when I ech the follow it just echoes the first  items once but not the echo inside the DIV.  It should echo echo line for 15 different results.

 

echo '<p>', $query_row['name'] ,'</p>';

echo '<p>', $query_row['rrp'] ,'</p>';

echo '<p>', $query_row['image_link'] ,'</p>';

echo '<p>', $query_row['discount'] ,'</p>';


echo '<div class="productimageborder"><a href="product.php?price=' . $query_row['name'] . '</div>';

echo '<div class="productimageborder"><a href="product.php?price=' . $query_row['name'] . '</div>';

Ahh.. maybe missing a little something here?

 

echo '<div class="productimageborder"><a href="product.php?price=' . $query_row['price'] . '">' . $query_row['name'] . '</a></div>';

Yes that would help!

 

Now I just need to the productrangeborder DIV, I have tried this as below but it kicks back an unexpected T_ECHO

 

So I take Im putting it in way.

 

'<div class="productrangeborder">'

echo '<div class="productdetailsborder"><a href="product.php?product_id=' . $query_row['product_id'] . '">' . $query_row['name'] . '</a></div>';

echo '<div class="productimageborder"><a href="product.php?product_id=' . $query_row['product_id'] . '"><img src="' . $query_row['image_link'] . '"/></a></div>';

echo '<div class="priceborder">' . $query_row['rrp'] . '</div>';

echo '<div class="discountborder">' . $query_row['discount'] . '</div>';


'</div>'

Just got to watch those semi-colons at the end of lines and echo where you mean to.

echo '<div class="productrangeborder">';

echo '<div class="productdetailsborder"><a href="product.php?product_id=' . $query_row['product_id'] . '">' . $query_row['name'] . '</a></div>';

echo '<div class="productimageborder"><a href="product.php?product_id=' . $query_row['product_id'] . '"><img src="' . $query_row['image_link'] . '"/></a></div>';

echo '<div class="priceborder">' . $query_row['rrp'] . '</div>';

echo '<div class="discountborder">' . $query_row['discount'] . '</div>';


echo '</div>';

Thanks,

 

I'm just looking for the simplest way to do this.

 

I did read through the guide but I can't see where I can seperate the curly tags from HTML.

 

Do you how I can do this please.  I have the product display and the pagination code so I just to fit it together.

Archived

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

×
×
  • 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.