php - assignment within an echo statement -
in php file, have echo statement, outputs html, within want assignment based on onclick event.
echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php' onclick='". $_session['dakno'] = $r[$j]; ."' >".$r[$j]."</a></td>";
i have tried lot of combinations, still getting syntax error because of onclick section.
echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php' onclick='"<?php $_session['dakno'] = $r[$j]; ?> "' >".$r[$j]."</a></td>";
edits:
i output field in table hyperlink. on clicking link, value of clicked item passed php file using session variable.
$sno = 1; while($r = mysqli_fetch_array($rs)){ echo "<tr>"; echo "<td style='padding:10px; text-align:left;'>".$sno."</td>"; $sno++; for( $j=1; $j<6; $j++){ if($j == 1){ echo "<td style='padding:10px; text-align:left;'> <a target='_blank' href='stat.php' onclick='". $_session['dakno'] = $r[$j]; ."' >".$r[$j]."</a></td>"; continue; } else echo "<td style='padding:10px; text-align:left;'>".$r[$j]."</td>"; } echo "</tr>"; }
please, me remove syntax error making.
as specified in question, needed pass value php file when clicked link. did not want use ajax here because not expect update content dynamically. after 2 hours of brainstorming, solved problem extremely basic solution.
$sno = 1; while($r = mysqli_fetch_array($rs)){ echo ""; echo "<tr>"; echo "<td style='padding:10px; text-align:left;'>".$sno."</td>"; $sno++; for( $j=1; $j<6; $j++){ if($j == 1){ echo "<td style='padding:10px; text-align:left;'><form action='stat.php' method='post'> <input type='hidden' name='dakno' value='".$r[$j]."' > </input> <button class='dakbutton' type='submit'>".$r[$j]."</button></form></td>"; continue; } else echo "<td style='padding:10px; text-align:left;'>".$r[$j]."</td>"; } echo "</tr>"; echo "</form>"; }
Comments
Post a Comment