troubleshooting Question

Can a html button have php attributes?

Avatar of Crazy Horse
Crazy HorseFlag for South Africa asked on
6 Comments1 Solution67 ViewsLast Modified:
I am playing around with integrating a shopping cart into my own website and the way you create a product or buy button is like this:

    data-item-description="Some fresh bacon">
    Buy bacon

This could get tedious if for every item you had to now do this. Can you make these dynamic with PHP? I would more than likely have all products in the database but for simplicity lets say I have:

$id = 2;
$item_name = "cheese";
$item_price = 3.00;
$item_weight = 20;
$item_description = "Chedder Cheese";

How could I put that into the button code? I have tried various ways but none of them work so I am obviously doing something wrong.
Marco Gasi

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2010

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros