I have a script which displays ads in a table based on a database query, each ad has a submit button, when the submit button is click it takes you to another page which echo’s the corresponding details based on the username of the ad you clicked on, however when there is more than one ad, it only displays the details of the first ad. Is there any way to assign a unique ID or something so that when the submit button of a specific ad is clicked the corresponding details are echo’ed rather than just the first one?
This is the echo code:
echo "<div id='expanderContent' style='display:none'>
<div class='reasonbar'>
<div class='prod-title1' style='width: 70%;'>" .
$row['lname'] .
"</div>
<div class='reason1' style='width: 29%;'>
Category:<br /> ".
$row['category'] .
"</div>
</div>";
echo "<div class='reasonbar'>
<div class='prod-title2' style='width: 70%;'>
<form action='adclick.php' method='post'>
<input type='hidden' name='username' value='" . $row['username'] . "'/>
<input type='submit' name='submit' value='Submit'>
</div>
<div class='reason2' style='width: 29%;'>
</div>
</div
</div>";
First of all, you’re not closing your form tag in that echo. Second, do you have any kind of loop to go through multiple results (multiple ads) if more than one is retrieved?