Jump to content

JamesB

Members
  • Posts

    425
  • Joined

  • Last visited

Posts posted by JamesB

  1. If apID is fetched in both queries then the arrays can be linked on this value.

     

     

    while ($appdetails = $result->fetch_object()){$details = array('name' => $appdetails->name,'apID'=>$appdetails->apID,'start'=>$appdetails->startDate,'end'=>$appdetails->endDate,'staffID'=>$appdetails->staffID,'origin'=>$appdetails->apps_origin);$appdata[$appdetails->apID] = $details;}while($service = $result1->fetch_object()){ // make sure to fetch 'apID' field in this query$appdata[$service->apID]['service'][] = $service->serviceID;}
  2.  

    $salt = 'example'; // this must never change $passwordUnencrypted = 'password';$passwordEncrypted = hash('sha512', $passwordUnencrypted . $salt); // adding row to table (registering)$sql = "INSERT INTO users (password) VALUES ('" . $passwordEncrypted ."')"; // checking password in table (logging in)$sql = "SELECT COUNT(*) FROM users WHERE password =  '" . ($passwordEncrypted) ."' LIMIT 1"; // obviously check for username too // updating password in table (changing password)$sql = "UPDATE users SET password = '" . $encryptedPassword . "' WHERE user_id = " . $user_id;
  3. Your var_dump is a 2 dimensional array, my example is a 3 dimensional array.

     

    But if you are using a 2 dimensional array, this should work:

     

     

     $event[$i] = array('id'=>$appdata["apID"],'title' => $appdata["name"],'staff_ID'=>$appdata['staffID'],'start' =>$appdata['start'],'end'=>$appdata['end'],'color'=>$backend,'allDay'=>false,'services' => $appdata['service']);
  4. Well inside the get_appointments() function I can understand $appdata being a 1 dimensional array and (2 dimensional array for services key), but outside that function isn't $appdata supposed to be 2 dimensional (and 3 dimensional for services key)?

    Because you have $appdata[$i]["apID"] instead of $appdata["apID"].

     

    Outside the get_appointments() function, shouldn't the $appdata array look like this:

     

    Array( [0] => Array( [name] => Kostas [apID] => 16 [start] => 2014-08-27 12:30:00 [end] => 2014-08-27 15:00:00 [staffID] => 5 [origin] => backend [service] => Array ( [0] => 1 [1] => 2 )))
  5. Would this be suitable?

     

     

    $event[$i] = array('id'=>$appdata[$i]["apID"],'title' => $appdata[$i]["name"],'staff_ID'=>$appdata[$i]['staffID'],'start' =>$appdata[$i]['start'],'end'=>$appdata[$i]['end'],'color'=>$backend,'allDay'=>false,'services' => $appdata[$i]['service']); // <------
  6. if both result objects contain the same amount of rows and each row relates to the other with the same row index, you could use this:

     

     

    $index = 0;while($service = $result1->fetch_object()){$names[$index]['service'] =$service->serviceID;$index++;}
  7. You can't call a PHP function from JavaScript code directly.

     

    html and javascript runs on the client-side. (in web browsers)

    php runs on the server-side.

     

    If you want client-side code to call server-side code, eg. the javascript code onchange="ChangePriority()" to call your PHP ChangePriority() function, then communication needs to happen between the client and the server.

    One way for them to communicate on the web is by submitting a form.

     

    So you can make the JavaScript code submit the form when the select changes, like in my previous post,

    then in your PHP page you can check if the form was submitted, and fetch the value with $_POST['Priority'],

    then you can call the PHP function ChangePriority().

  8. You seem to be breaking out of the loop, meaning score will be a max of 1 per call to checkResults(), assuming you reset score to 0.

     

    You are also only fetching the text input value once, which should be happening for each question in the loop.

     function checkResults() {score = 0;for (var k in answers) {var$this = $('#'+k),val = $this.val().toLowerCase();if (answers.hasOwnProperty(k)) {if (answers[k] === val) {$this.css('background-color', 'green');score++;} else {$this.css('background-color', 'red');}}}if (score == 2) {alert('Hi Ur Score is 2');}$('#score').text('score: ' + score);}
    • Like 1
×
×
  • Create New...