will somebody show me a sample how to add cart using dynamic button??

im having trouble retrieving value using dynamic button


using the code below

#
echo("<TR id='$i' bgcolor='B0C4DE'>");
#
$sr_num=$row['b_sr_num'];
#
echo ("<td><input name=data id=data type=text id=data readonly=readonly value=$sr_num></td>");
#
echo ('<td>'.$row['b_name'].'</td>');
#
echo ('<td>'.$row['b_author'].'</td>');
#
echo ('<td>'.$row['b_avail'].'</td>');
#
 
#
if($row['b_avail']>0)
#
{
#
if (!$_SESSION["valid_user"])
#
{
#
// User not logged in, redirect to login page
#
echo("<td>Available</td>");
#
}else
#
echo("<td><INPUT TYPE=button id=show name=show value=add onClick= buttonPress('$sr_num')></td>");
#
 
#
}else
#
echo("<td>No stock of book</td>");
#
echo("</TR>");
#
$i=$i+1; }
#
echo("</TABLE>");

should i use php or ajax?

Hey,

On which process page you try to implement dynamic button? Why? I think you try to same on any product listing page for clicking on button that product will add into current cart session, If yes than you can achieve same with using php/ajax and creating new table like cart_master. And clicking on that button you have write code to that product id goes into cart_master table along with userid.

I hope this will help you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.