hello there! i want to create dynamic buttons!after many tries and a lot of googling i ve create dynamic buttons from mysql.my problem is to name the buttons from the table in mysql ! i post my code to help me if anybody can/knows/wants
<?php
$connect=mysql_connect("localhost","admin","pass")
or die ("Check your server connectio");
$db_found = mysql_select_db("mydb", $connect);
$SQL = "SELECT * FROM mytable ";
$result = mysql_query($SQL);
$num_r = mysql_num_rows($result);
while($nt=mysql_fetch_array($result)){
$test[$num_r]=$nt['testing']; //test values in mytable
}
?>
function addsubmit (fid){ // a fun that create dynamicly buttons
var num = "<?php echo $num_r; ?>";
if (num >0) {
for (i=0;i<num;i++){
var newsubmit = document.createElement("input");
<?php $temp=$num_r--;?>
newsubmit.type = "button";
newsubmit.id = "mysubmit";
newsubmit.name = "mysubmit";
newsubmit.value ="<?php echo $test[$temp]; ?>";
newsubmit.on-click = function () {
fun(i);
};
fid.appendChild(newsubmit);
}
}
}
but it doesnt work!i also try
newsubmit.value ="<?php echo $test[3]; ?>";
but didnt get any result please help and sorry for my large msg