hello ,
i want to implement this code in yii…
Jquery and Html code is working fine in yii only storing in to db is not working
------------------------------ PHP Code ------------------
<?php
include ‘db.php’;
if(isset($_GET[‘save’]))
{
$i=0;
while($_GET["skills_$i"])
{
$s=$_GET["skills_$i"];
$u=$_GET["used_$i"];
$mexp=$_GET["mexp_$i"];
$yexp=$_GET["yexp_$i"];
$q=mysql_query("insert into skills (skills,used,mexp,yexp) values('$s',$u,$mexp,$yexp)");
$i++;
}
}
?>
------------------------------ HTML Code ------------------
<html>
<head>
</head>
<body>
<form name="skill" action="kal.php" method="get" id="sk">
<table border="0">
<th>Skills</th> <th> Used</th> <th> Experience</th> <th> Experience</th>
<tr class="table1" id="row0">
<td><select name="skills_0" id="skills_0"> <option value="">Select</option>
<?php
$q=mysql_query("select SkillsId,SkillsName from bsskills");
while($row=mysql_fetch_array($q))
{
echo "<option value=".$row['SkillsId'].">".$row['SkillsName']."</option>";
}
?>
</select>
</td>
<td><select name="used_0" id="used_0"> <option value="">Select</option>
<?php
$q=mysql_query("select Completionyear from bsnumber");
while($row=mysql_fetch_array($q))
{
echo "<option value=".$row['Completionyear'].">".$row['Completionyear']."</option>";
}
?>
</select>
</td>
<td><select name="mexp_0" id="mexp_0"> <option value="">Month</option>
<?php
$q=mysql_query("select Completionyear from bsnumber");
while($row=mysql_fetch_array($q))
{
echo "<option value=".$row['Completionyear'].">".$row['Completionyear']."</option>";
}
?>
</select>
</td>
<td><select name="yexp_0" id="yexp_0"> <option value="">Year</option>
<?php
$q=mysql_query("select Completionyear from bsnumber");
while($row=mysql_fetch_array($q))
{
echo "<option value=".$row['Completionyear'].">".$row['Completionyear']."</option>";
}
?>
</select>
</td>
</tr>
<tr><td colspan="2" align="center"><input type="button" value="Add" id="add"/><input type="button" value="Remove" id="rmv"/></td></tr>
<tr><td colspan="2" align="left"><input type="submit" value="save" name="save" id="save"/> </td></tr>
</table>
</form>
</body>
</html>
----------------------------------- Jquery Code----------------------
<script src="jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function()
{
var num = $('.table1').length-1; // how many "duplicatable" input fields we currently have
var newNum = new Number(num + 1);
$("#add").click(function()
{
var num_rows = $('.table1').length+1;
$("#table1_num_rows").val(num_rows);
var num = $('.table1').length-1; // how many "duplicatable" input fields we currently have
var newNum = new Number(num + 1); // the numeric ID of the new input field being added
// create the new element via clone(), and manipulate it's ID using newNum value
var newElem = $('#row0').clone().attr('id', 'row' + newNum);
newElem.children(':eq(0)').children(':eq(0)').attr('name', 'skills_' + newNum).attr('id', 'skills_' + newNum).attr('value','');
newElem.children(':eq(1)').children(':eq(0)').attr('name', 'used_' + newNum).attr('id', 'used_' + newNum).attr('value','').append("<option selected>Select</option>");
newElem.children(':eq(2)').children(':eq(0)').attr('name', 'mexp_' + newNum).attr('id', 'mexp_' + newNum).attr('value','').append("<option selected>Select</option>");
newElem.children(':eq(3)').children(':eq(0)').attr('name', 'yexp_' + newNum).attr('id', 'yexp_' + newNum).attr('value','').append("<option selected>Select</option>");
// insert the new element after the last "duplicatable" input field
$('#row' + num).after(newElem);
$('#rmv').attr('disabled','');
})
if($('.table1').length == 1)
{
$('#rmv').attr('disabled','disabled');
}
$("#rmv").click(function()
{
var num = $('.table1').length;
var num = num-1;
$('#row' + num).remove();
$("#table1_num_rows").val(num);
// if only one element remains, disable the "remove" button
if (num == 1)
$('#rmv').attr('disabled','disabled');
});
})
</script>
i tried to implement but it’s not working…
Can you please suggest me which code where i have to put?