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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Oh I see, I didn't know it could be dont like that. Thanks.

 

Does the pagination have to be insider the PHP for the echo then.  Echoing column by column is so much easier. 

 

<?php echo $row['product_id']; ?>

Yes, any php coding or echo's need to be inside <?php ?> tags.
Link to comment
Share on other sites

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.

Link to comment
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.