1

My Ionic app Code is following:

    <label class="item item-input item-floating-label light">
        <span class="input-label">Date</span>
        <input type="date" placeholder="Date" ng-model="data.date" style="color: white;">
    </label>
    <div class="list card" style="background:#3CB371;" ng-repeat="student in students">
        <ion-checkbox class="checkbox-balanced" ng-model="data.reg_no" ng-checked="data.reg_no" style="color: white;">{{student.reg_no}}</ion-checkbox>
    </div>

//sends the data to server Add

app.js Code is following:

.controller('TakeAttendanceCtrl', function($scope, $http, ionicMaterialInk){

    $scope.add = function(data) {
        $http({
                method: 'post',
                url: host + 'api.php?take_attendance',
                params: data
            })
            .then(
                function(suc) {
                    if (confirm("Attendance updated.")) {
                        window.location.href = "home.html";
                    } else {
                        window.location.reload();
                    }
                },
                function(err) {});
    }
})

and my server side code is following: (api.php)

 include "library.php";
if(isset($take_attendance))
{

    insert("attendance","'','$date', '$reg_no'");
}

and the library.php file is this:

header("Access-Control-Allow-Origin:*");
extract($_REQUEST);
mysql_connect("localhost","root","");
mysql_select_db("sis"); 
function insert($table,$values)
{
    mysql_query("insert into $table values($values)");
    // echo "insert into $table values($values)";
}
4
  • you want to make sure in your php code to you handle the radio button values and then convert them to the appropriate insert statements for your table. You will need to add the table schema as well to the question. Commented Feb 18, 2017 at 17:54
  • Thanks for reply Sir! Commented Feb 18, 2017 at 18:01
  • If you give me an example its better for me. Commented Feb 18, 2017 at 18:01
  • you will probably want to break up each piece into a question and then do the research. For example, i would research how to process form data with php, esp with radio buttons. Then after you have tested that out, research how to store data in mysql with php. This way you understand each step without asking how to do entire thing. Commented Feb 18, 2017 at 22:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.