HTML HREF inside PHP

Codes here !

Moderators: macek, egami, gesf

PD1984
New php-forum User
New php-forum User
Posts: 2
Joined: Mon May 07, 2012 4:11 am

HTML HREF inside PHP

Postby PD1984 » Mon May 07, 2012 4:16 am

Hi,
I am creating a multiple drop down list using AJAX and within the result I wish to place a link to a page where more details can be viewed on a product.
I have a feeling I do not have the quotes in correctly but have tried different ways around and still haven't had any joy.

Code: Select all

if($col==$ar_cols[$last_key]) $re_html .= '<br/>'. $row[$col] echo "<a href=productinfo.php?id=".$row['ProductID'].">View more Details</a>";


The problem is from the echo onwards..

Any help would be appreciated or if more code needs posting up.

Thank you in advance

Pete

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: HTML HREF inside PHP

Postby Nullsig » Mon May 07, 2012 5:32 am

It looks like you are missing semi-colons and brackets.

Code: Select all

if($col==$ar_cols[$last_key]){
$re_html .= '<br/>'. $row[$col];
echo "<a href=productinfo.php?id=".$row['ProductID'].">View more Details</a>";
}


Adding the curly brackets to group off this section of code the code now reads:

If $col is equal to the $last_key index of $ar_cols do the following.
Concatenate to the end of $re_html a line break and the value of $row[$col].
Then echo out a hyperlink to productinfo.php with the query string of id=$row['productID'].

PD1984
New php-forum User
New php-forum User
Posts: 2
Joined: Mon May 07, 2012 4:11 am

Re: HTML HREF inside PHP

Postby PD1984 » Mon May 07, 2012 10:10 am

Thank you Nullsig, that's done what I wanted now.


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron