Sorry for the confusing title. I am as confused.
SO what I am trying to do is print results from the MySQL database I've got. I have a checkbox value as "yes" in my DB and I would like to replace this to some other word while printing out the results.
I've tried different ways but all of them break the page, because I'm new to this and have no idea what I am doing.
Here is my code so far (only put what I think is relevant):
$keyword= "";
if (isset($_POST["keyword"])) {
$keyword = ($_POST["keyword"]);
}
$results = mysqli_query($con, "SELECT * FROM pcdata WHERE name LIKE '$keyword' LIMIT 0, 25");
if (!$results) {
echo "Not found...";
} else {
echo "Found...<br>";
}
while ($row = mysqli_fetch_array($results)) {
echo "<br>";
echo "Name: " . $row['name'] . "<br>";
echo "Model: " . $row['model'] . "<br>";
echo "Operating system: " . $row['model'] . "<br>";
echo "Type of computer: " . $row['pctype'] . "<br>";
echo "Other information: " . $row['info'] . "<br>";
echo "Need help ASAP: " . $row['help'] . "<br>";
}
Why don't you try a simple if inside your while:
$myvariable='';
if($row['help']='yes'){
$myvariable='put_something_here';
}
And in your echo just do:
echo "Need help ASAP: " . $myvariable . "<br>";
Or a ternary solution:
$row['help'] == 'yes' ? 'put_something_here' : 'what_do_you_want_to_print_if_it_is_not_yes'
Try this code:
$keyword= "";
if (isset($_POST["keyword"]))
$keyword=($_POST["keyword"]);
$results=mysqli_query($con,"
SELECT *
FROM pcdata
WHERE name LIKE '$keyword' LIMIT 0,25");
if (!$results) {
echo "Not found...";
}
else {
echo "Found...<br>";
}
while ($row = mysqli_fetch_array($results))
{
echo "<br>";
echo "Name: " . $row['name'] . "<br>";
echo "Model: " . $row['model'] . "<br>";
echo "Operating system: " . $row['model'] . "<br>";
echo "Type of computer: " . $row['pctype'] . "<br>";
echo "Other information: " . $row['info'] . "<br>";
echo "Need help ASAP: ";
if ($row['help'] === 'yes'){
echo 'YES';
} else {
echo 'NO';
}
echo '<br>';
}
We check the value of $row['help'] and if it "yes" printing 'YES', if other - printing 'NO'
you can also use select statement combined with Case statement which will result as desired try following code
$keyword= "";
if (isset($_POST["keyword"]))
{
$keyword = ($_POST["keyword"]);
}
//used different variable to build query
$selectquery="SELECT id,name,model,pctype,info CASE WHEN help='yes' THEN 'Your Yes String' WHEN help='no' THEN 'Your No String' else 'nothing' END as help FROM pcdata where name like '$keyword'" ;
//passed $selectquery to mysqli_qery
$results = mysqli_query($con, $selectquery);
if (!$results) {
echo "Not found...";
} else {
echo "Found...<br>";
}
while ($row = mysqli_fetch_array($results)) {
echo "<br>";
echo "Name: " . $row['name'] . "<br>";
echo "Model: " . $row['model'] . "<br>";
echo "Operating system: " . $row['model'] . "<br>";
echo "Type of computer: " . $row['pctype'] . "<br>";
echo "Other information: " . $row['info'] . "<br>";
echo "Need help ASAP: " . $row['help'] . "<br>";
}
Hello im having some problems with my forms. It says "Saw a form start tag, but there was already an active form element. Nested forms are not allowed." but when im looking in my code the forms are not even nested in my code can i have some help.
$sql8 = 'SELECT läggtill.serier, läggtill.id, läggtill.id2, läggtill.säsonger, läggtill.betyg, kategorier.kategori from läggtill inner join'
. ' kategorier on läggtill.kategorier=kategorier.id order by läggtill.serier';
$resultat8 = $mysqli->query($sql8);
$antal8 = $resultat8->num_rows;
while ($rad8 = $resultat8->fetch_assoc()) {
echo "<li>" .$rad8['serier'] .', ' .$rad8['säsonger'] .' Säsonger, ' .$rad8['kategori'] .'<br>'.
'Betyg: ' .$rad8['betyg'] .'/10 </li>' .'<br>';
$id = $rad8['id'];
?>
<?php
echo '<form action="alla.php" method="POST">
<button name=' .$id .'>Ta bort</button>
</form>'
?>
<?php
if (isset($_POST[$id])) {
$sql9 = "Delete from läggtill where id=" . $id . " LIMIT 1";
if ($resultat9 === $mysqli->query($sql9)) {
header('location: alla.php');
} else {
echo "det misslyckades.";
}
echo "asdasd";
}
$id2 = $rad8['id2'];
echo "<div class=" . 'Update' . '>'
?>
<?php
echo "<form action='alla.php' method='POST'>
<label for='serier'>Serie: </label>
<input type='text' name='serier' id='serier'><br>";
$sql14 = 'SELECT * FROM kategorier';
$resultat14 = $mysqli->query($sql14);
$antal14 = $resultat14->num_rows;
if ($antal14 == 0) {
echo 'Inget funnet';
} else {
$sql15 = 'SELECT kategori, id FROM kategorier';
$resultat15 = $mysqli->query($sql15);
$antal15 = $resultat15->num_rows;
if ($antal15 == 0) {
echo 'Inget kategori funnen';
} else {
echo 'Kategori: <select name =kategorier>';
while ($rad15 = $resultat15->fetch_assoc()) {
echo '<option value='. $rad15['id'] . '>' . $rad15['kategori'] . '</option><br>';
}
echo '</select>';
}
}
echo '<br><button name= . $id2' . '>Uppdatera</button>';
if (isset($_POST[$id2])) {
$kategorier = $_POST['kategorier'];
$betyg = $_POST['betyg'];
$serier = $_POST['serier'];
$säsonger = $_POST['säsonger'];
if(strlen($kategorier) && strlen($säsonger) && strlen($serier) && strlen($betyg)) {
$sql12 = '"UPDATE läggtill SET kategorier="" . $kategorier . "", säsonger="" . $säsonger . "", serier="" . $serier . "","
. " betyg="" . $betyg . "" WHERE id2="" . $id2 . "";';
if($resultat9 == $mysqli->query($sql12)) {
header('location: alla.php');
} else {
echo 'Det misslyckades';
}
}
}
}
echo "</form>";
echo "</div>";`**enter code here**`
check have updated few things, hope it will work out
<?php
$sql8 = 'SELECT läggtill.serier, läggtill.id, läggtill.id2, läggtill.säsonger, läggtill.betyg, kategorier.kategori from läggtill inner join'
. ' kategorier on läggtill.kategorier=kategorier.id order by läggtill.serier';
$resultat8 = $mysqli->query($sql8);
$antal8 = $resultat8->num_rows;
while ($rad8 = $resultat8->fetch_assoc()) {
echo "<li>" . $rad8['serier'] . ', ' . $rad8['säsonger'] . ' Säsonger, ' . $rad8['kategori'] . '<br>' .
'Betyg: ' . $rad8['betyg'] . '/10 </li>' . '<br>';
$id = $rad8['id'];
?>
<?php
echo '<form action="alla.php" method="POST">
<button name=' . $id . '>Ta bort</button>
</form>'
?>
<?php
if (isset($_POST[$id])) {
$sql9 = "Delete from läggtill where id=" . $id . " LIMIT 1";
if ($resultat9 === $mysqli->query($sql9)) {
header('location: alla.php');
} else {
echo "det misslyckades.";
}
echo "asdasd";
}
$id2 = $rad8['id2'];
echo "<div class=" . 'Update' . '>'
?>
<?php
echo "<form action='alla.php' method='POST'>
<label for='serier'>Serie: </label>
<input type='text' name='serier' id='serier'><br>";
$sql14 = 'SELECT * FROM kategorier';
$resultat14 = $mysqli->query($sql14);
$antal14 = $resultat14->num_rows;
if ($antal14 == 0) {
echo 'Inget funnet';
} else {
$sql15 = 'SELECT kategori, id FROM kategorier';
$resultat15 = $mysqli->query($sql15);
$antal15 = $resultat15->num_rows;
if ($antal15 == 0) {
echo 'Inget kategori funnen';
} else {
echo 'Kategori: <select name =kategorier>';
while ($rad15 = $resultat15->fetch_assoc()) {
echo '<option value=' . $rad15['id'] . '>' . $rad15['kategori'] . '</option><br>';
}
echo '</select>';
}
}
echo '<br><button name= . $id2' . '>Uppdatera</button></form>';
if (isset($_POST[$id2])) {
$kategorier = $_POST['kategorier'];
$betyg = $_POST['betyg'];
$serier = $_POST['serier'];
$säsonger = $_POST['säsonger'];
if (strlen($kategorier) && strlen($säsonger) && strlen($serier) && strlen($betyg)) {
$sql12 = '"UPDATE läggtill SET kategorier="" . $kategorier . "", säsonger="" . $säsonger . "", serier="" . $serier . "","
. " betyg="" . $betyg . "" WHERE id2="" . $id2 . "";';
if ($resultat9 == $mysqli->query($sql12)) {
header('location: alla.php');
} else {
echo 'Det misslyckades';
}
}
}
}
echo "</div>";
Being a complete noob, I'm trying to create a way for my php page to show all data registered in a database when the values of the columns "identity" and "idricovero" are the same ones used at the start of the session.
Currently it shows only the latest data entered, while I'd like the page to "update" with every new data.
Here's the code
<html>
<body>
<?php
require "connessione.php";
$operatore="";
session_start();
if (!empty($_SESSION['username'])) {$operatore = $_SESSION['username'];}
$idpazok = $idricok = $cartellaok = 0;
$identity = $idpaz = "";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
if (!empty($_GET['identity'])) {
$identity = test_input($_GET['identity']);
$idpazok = 1;
}
if (!empty($_GET['idricovero'])) {
$idricovero = test_input($_GET['idricovero']);
$idricok = 1;
}
}
if ($idricok AND $idpazok) {
//prendo i dati della cartella paziente
$query = "SELECT * FROM Accertamentomirato WHERE `identity` = '".$identity."' AND idricovero = '".$idricovero."'";
//echo "<h2>".$query."</h2>";
$results = mysqli_query($conn, $query);
if (mysqli_num_rows($results) > 0) {
$row = mysqli_fetch_assoc($results);
$dataorarilevazione = $row['dataorarilevazione'];
$csm1 = $row['csm1'];
$csm2 = $row['csm2'];
$csm3 = $row['csm3'];
$cartellaok=1;
} else {
echo "<h2 class=error> Cartella paziente non esistente</h2>"; //.mysqli_error($conn);
}
mysqli_free_result($results);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($cartellaok) {
echo "<h1>" . "ACCERTAMENTO MIRATO" . "</h1>";
echo "<fieldset>";
echo "<legend>".$datarilevazione. "</legend>";
echo "<fieldset>";
echo "<legend>".$orarilevazione."</legend>";
echo "<table>";
if (!empty($csm1)) {echo "<tr> " . "<td> " . "TEMPO DI REMPIMENTO CAPILLARE: " . "</td> " . "<td>".$csm1."</td> " . "</tr>";}
if (!empty($csm2)) {echo "<tr> " . "<td> " . "SENSIBILITÀ TATTILE: " . " </td> " . "<td>".$csm2."</td> " . "</tr>";}
if (!empty($csm3)) {echo "<tr> " . "<td> " . "MOBILITÀ DELLE ESTREMITÀ: " . "</td> " . "<td>".$csm3."</td> " . "</tr>";}
echo "<tr> " . "<td> " . "Operatore: " . "</td> " . "<td>".$operatore." </td> " . "</tr>";
echo "</table>";
echo "</fieldset>";
echo "</fieldset>";
}
?>
</body>
</html>
I have an HTML form where I can add first name, last name and phone number. When I try to insert a value into the phone number field I get this error:
message from webpage
For the first name and last name fields it works everytime.I'm using google chrome. Could be a browser error or it is a code error?
This is the part of code which includes the form:
require('libraries/Interview.class.php');
require('libraries/PhoneBook.class.php');
require('libraries/Beneficiari.class.php');
require('libraries/Marci.class.php');
require('libraries/Modele.class.php');
require_once('connect.php');
require('libraries/Agentii.class.php');
require ("include/callcenter-header.php");
$_SESSION['username'] = 'admin';
$phone_no ="";
if (strlen($phone_no) == 9) {
$contact = PhoneBook::listBYPhoneNo($phone_no, $conn);
$selected_contact = null;
$beneficiari = Beneficiari::listAllNoOwner($db);
$content_agentii = "<option value=''>Alege agentie</option>";
$content_beneficiari = "<option value=''>Alege beneficiar</option>";
$btn_add_new = "";
$selected_bname = "";
$selected_aname = "";
if ($contact) {
if (count($contact) == 0) {
$selected_contact = $contact[0];
} else {
for ($x = 0; $x < count($contact); $x++) {
if ($contact[$x]['default'] == 0) {
$selected_contact = $contact[$x];
}
}
}
$agentii = Agentii::listAll_byBeneficiar($selected_contact['id_beneficiar'], $db);
for ($b = 0; $b < count($beneficiari); $b++) {
if ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id']) {
$selected_bname = $beneficiari[$b]['nume'];
};
$selected = ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id'] ? "selected = 'selected'" : '');
$content_beneficiari .= "<option " . $selected . " value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
for ($a = 0; $a < count($agentii); $a++) {
if ($selected_contact['agency_id'] == $agentii[$a]['id']) {
$selected_aname = $agentii[$a]['nume'];
};
$selected = ($selected_contact['agency_id'] == $agentii[$a]['id'] ? "selected = 'selected'" : '');
$content_agentii .= "<option " . $selected . " value='" . $agentii[$a]['id'] . "'>" . $agentii[$a]['nume'] . "</option>";
}
$btn_upd = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
for ($b = 0; $b < count($beneficiari); $b++) {
$content_beneficiari .= "<option value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
$selected_contact = null;
$agentii = null;
$btn_add_new = "<button class='add_new_pb'>Inregistreaza contact</button>";
}
}
?>
<script>
function OnNewCall(myCallTraceId, callParams)
{
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.cc_interview.php",
data: {ck_new_call: myCallTraceId, callParams: callParams},
success: function (response) {
$('#contact_info_form').html(response);
$('#flt9_assets').val($("#res_client_company option:selected").html());
$('#flt10_assets').val($("#res_client_agency option:selected").html().split(",")[0]);
filterData(1);
}
});
}
</script>
<br/>
<div style="text-align: left" class="contact_info">
<fieldset>
<legend>Informatii client</legend>
<table id="contact_info_form">
<tr>
<td><label>Call Trace ID :</label><br/><input type="text" id="res_ctid" value="-" /></td>
</tr>
<tr>
<td><label>Nume :</label><br/><input type="text" id="res_client_firstname" value="<?php echo #$selected_contact['first_name']; ?>" /></td>
<td><label>Prenume :</label><br/><input type="text" id="res_client_lastname" value="<?php echo #$selected_contact['last_name']; ?>"/></td>
<td><label>Telefon :</label><br/><input type="text" readonly="readonly" id="res_client_phone" value="<?php echo $phone_no; ?>"/></td>
<td><label>Email :</label><br/><input type="text" id="res_client_email" value="<?php echo #$selected_contact['email']; ?>"/></td>
</tr>
<tr>
<td><label>Beneficiar :</label><br/><select id="res_client_company"><?php echo $content_beneficiari; ?></select></td>
<td><label>Agentia :</label><br/><select id="res_client_agency" ><?php echo $content_agentii; ?></select></td>
<td><label>Adresa :</label><br/><input type="text" id="res_client_address" value="<?php echo #$selected_contact['adresa_agentie']; ?>"/></td>
<td><span id="contact_info_act_btn"><?php echo $btn_add_new; ?><?php echo $btn_upd; ?></span></br><span id="btn_act_resp"></span></td>
</tr>
</table>
</fieldset>
<script>
$('#contact_info_form').on('change', '#res_client_company', function () {
$('#flt9_assets').val($("#res_client_company option:selected").html());
$('#flt10_assets').val('');
filterData(1);
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.agentii.php",
data: {req_benef: $(this).val()},
beforeSend: function () {
$('#res_client_agency').html('');
},
success: function (response) {
$('#res_client_agency').html(JSON.parse(response));
}
});
});
$('#contact_info_form').on('change', '#res_client_agency', function () {
if ($("#res_client_agency option:selected") !== null) {
$('#flt10_assets').val($("#res_client_agency option:selected").html().split(",")[0]);
filterData(1);
}
});
$('#contact_info_form').on('click', '.add_new_pb', function () {
var request = {
first_name: $('#res_client_firstname').val(),
last_name: $('#res_client_lastname').val(),
phone: $('#res_client_phone').val(),
email: $('#res_client_email').val(),
company: $('#res_client_company').val(),
agency: $('#res_client_agency').val(),
address: $('#res_client_address').val()
};
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.cc_interview.php",
data: {req_new_pb_entry: JSON.stringify(request)},
beforeSend: function () {
$('#contact_info_act_btn').html('');
},
success: function (response) {
var resp = JSON.parse(response);
if (resp['result']) {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul a fost inregistrat cu succes !");
} else {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul nu a putut fi inregistrat !");
}
}
});
});
$('#contact_info_form').on('click', '.upd_pb', function () {
var request = {
first_name: $('#res_client_firstname').val(),
last_name: $('#res_client_lastname').val(),
phone: $('#res_client_phone').val(),
email: $('#res_client_email').val(),
company: $('#res_client_company').val(),
agency: $('#res_client_agency').val(),
address: $('#res_client_address').val()
};
$.ajax({
type: "POST",
url: "dynamic/dynamic.functions.cc_interview.php",
data: {req_upd_pb_entry: JSON.stringify(request)},
beforeSend: function () {
$('#contact_info_act_btn').html('');
},
success: function (response) {
var resp = JSON.parse(response);
if (resp['result']) {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul a fost actualizat cu succes !");
} else {
$('#contact_info_act_btn').html(resp['html']);
$('#btn_act_resp').html("Contactul nu a putut fi actualizat !");
}
}
});
});
$('#res_client_phone').on('click', '', function () {
try
{
window.external.Dial($('#res_client_phone').val(), 0, -1);
} catch (err)
{
alert("Error on Dial Function !" + err);
}
});
</script>
</div>
And this is the dynamic.functions.cc_interview.php code:
require '../connect.php';
/*
* WHEN user selects an equipment
*/
if (isset($_POST['cci_set_et'])) {
$echipID = str_replace('act_lnk_', '', $_POST['cci_set_et']);
require '../libraries/Interview.class.php';
require '../libraries/Echipamente.class.php';
require '../libraries/Ingineri_service.class.php';
$echipament = Echip::listEchipId($echipID, $db);
$ingineri = Ingineri_service::listAllDistinct($db);
$question = Interview::listFirstQuestionByEchip($echipID, $conn);
#$answers = Interview::listAnswers($question[0]['id'], $conn);
$response = array();
$html = "";
$html .= "<tr class='qRow' id='qRow-" . $_POST['q_count'] . "'><td>" . #$question[0]['text'] . "</td>";
$html .= "<td><input type='hidden' id='qR-" . #$question[0]['id'] . "' value=''><input type='hidden' id='qRid-" . $question[0]['id'] . "' value=''>";
for ($x = 0; $x < count($answers); $x++) {
switch (#$question[0]['multiple_choice']) {
case 0 :
$name = "q" . $question[0]['id'] . "";
break;
case 1 : $name = "q" . $question[0]['id'] . "-" . $answers[$x]['id'];
break;
default : $name = "q" . $question[0]['id'] . "";
}
$html .= "<div>" . $answers[$x]['text'] . " <input class='in_qResp' name='" . $name . "' type='" . $answers[$x]['input_type'] . "' id='R-" . $answers[$x]['id'] . "-" . $answers[$x]['next_question_id'] . "' value='" . $answers[$x]['text'] . "' /> ";
if ($answers[$x]['has_hint'] == 1) {
$html .= " | <a class='ahint'>HINT</a><div class='tooltip'>content</div>";
}
$html .= "</div>";
}
$html .= "<button class='qSubmit' id='qS-" . #$question[0]['id'] . "'>Submit</buton></td></tr>";
$ingineri_html = "";
for ($i = 0; $i < count($ingineri); $i++) {
$selected = ($ingineri[$i]['inginer_service'] == $echipament[0]['inginer_service'] ? "selected='selected'" : "");
$ingineri_html .= "<option " . $selected . " value='" . $ingineri[$i]['inginer_service'] . "'>" . ucwords(str_replace('.', ' ', $ingineri[$i]['inginer_service'])) . "</option>";
}
$response['question']['id'] = $question[0]['id'];
$response['equip_class'] = $echipament[0]['categorie'];
$response['equip_mark'] = $echipament[0]['numeMarca'];
$response['equip_model'] = $echipament[0]['numeModel'];
$response['equip_serial'] = $echipament[0]['serie'];
$response['equip_cod'] = $echipament[0]['cod'];
$response['agency_id'] = $echipament[0]['agentie'];
$response['question']['text'] = $question[0]['text'];
$response['question']['response'] = "";
$response['engineer_html'] = $ingineri_html;
$response['html'] = $html;
echo json_encode($response);
}
/*
* When user submits an answer
*/
if (isset($_POST['cci_set_nq'])) {
$answer_token = explode('-', $_POST['cci_set_nq']);
$answer_id = $answer_token[1];
require '../libraries/Interview.class.php';
$selected_answer = Interview::findAnswer($answer_id, $conn);
$question = Interview::listNextQuestionByAnswer($answer_id, $conn);
$answers = Interview::listAnswers($question[0]['id'], $conn);
$response = array();
$html = "";
$html .= "<tr class='qRow'><td>" . $question[0]['text'] . "</td>";
$html .= "<td><input type='hidden' id='qR-" . $question[0]['id'] . "' value=''><input type='hidden' id='qRid-" . $question[0]['id'] . "' value=''>";
for ($x = 0; $x < count($answers); $x++) {
switch ($question[0]['multiple_choice']) {
case 0 :
$name = "q" . $question[0]['id'] . "";
break;
case 1 : $name = "q" . $question[0]['id'] . "-" . $answers[$x]['id'];
break;
default : $name = "q" . $question[0]['id'] . "";
}
$html .= "<div>" . $answers[$x]['text'] . " <input class='in_qResp' name='" . $name . "' type='" . $answers[$x]['input_type'] . "' id='R-" . $answers[$x]['id'] . "-" . $answers[$x]['next_question_id'] . "' value='" . $answers[$x]['text'] . "' /> ";
if ($answers[$x]['has_hint'] == 1) {
$html .= " | <a class='a_hint'>HINT</a><div class='tooltip'></div>";
}
$html .= "</div>";
}
$html .= "<button class='qSubmit' id='qS-" . $question[0]['id'] . "'>Submit</buton></td></tr>";
$response['question']['id'] = $question[0]['id'];
$response['question']['text'] = $question[0]['text'];
$response['question']['response'] = "";
$response['action'] = $selected_answer['action'];
$response['html'] = $html;
echo json_encode($response);
}
/*
* Function to insert new action into table actuni when agent decides so .
*/
if (isset($_POST['cci_set_aNi'])) {
require '../libraries/Actiuni.class.php';
$request = json_decode($_POST['cci_set_aNi']);
$request->equip_id = str_replace('act_lnk_', '', $request->equip_id);
$request->resolution->interview_string = "Reprezentant client : " . $request->client_first_name . " " . $request->client_last_name . " \n " .
"Telefon client : " . $request->call_id . " \n" .
"Rezultat interviu : \n" . $request->resolution->interview_string . " \n";
// $id_sesizare = Actiuni::insert('call_incident', date('Y-m-d H:i'), $request->deadline, $request->engineer, $request->equip_id, $request->resolution->interview_string, 'nevalidata', date('H:i'), $_SESSION['username'], $request->agency_id, '0', 'RON', $db);
$id_sesizare = 212312;
echo $id_sesizare;
}
/*
* Function to insert new Phone Book entry into table phone_book
*/
if (isset($_POST['req_new_pb_entry'])) {
require '../libraries/PhoneBook.class.php';
$request = json_decode($_POST['req_new_pb_entry']);
$inserted = PhoneBook::insert($request->first_name, $request->last_name, $request->phone, $request->email, $request->agency, $conn);
if ($inserted) {
$response['result'] = TRUE;
$response['html'] = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
$response['result'] = FALSE;
$response['html'] = "<button class='add_new_pb'>Inregistreaza contact</button>";
}
echo json_encode($response);
}
if (isset($_POST['req_upd_pb_entry'])) {
require '../libraries/PhoneBook.class.php';
$request = json_decode($_POST['req_upd_pb_entry']);
$updated = PhoneBook::update($request->first_name, $request->last_name, $request->phone, $request->email, $request->agency, $conn);
$response = array();
if ($updated) {
$response['result'] = TRUE;
$response['html'] = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
$response['result'] = FALSE;
$response['html'] = "<button class='upd_pb'>Actualizeaza info</button>";
}
echo json_encode($response);
}
if (isset($_POST['ck_new_call'])) {
$callTraceId = $_POST['ck_new_call'];
$callParams = $_POST['callParams'];
parse_str($callParams, $callParams_arr);
require('../libraries/PhoneBook.class.php');
require('../libraries/Beneficiari.class.php');
require('../libraries/Agentii.class.php');
$phone_no = intval($callParams_arr['MCC_ANI']);
if (strlen($phone_no) == 9) {
$contact = PhoneBook::listBYPhoneNo($phone_no, $conn);
$selected_contact = null;
$beneficiari = Beneficiari::listAllNoOwner($db);
$content_agentii = "<option value=''>Alege agentie</option>";
$content_beneficiari = "<option value=''>Alege beneficiar</option>";
$btn_add_new = "";
$selected_bname = "";
$selected_aname = "";
if ($contact) {
if (count($contact) == 0) {
$selected_contact = $contact[0];
} else {
for ($x = 0; $x < count($contact); $x++) {
if ($contact[$x]['default'] == 0) {
$selected_contact = $contact[$x];
}
}
}
$agentii = Agentii::listAll_byBeneficiar($selected_contact['id_beneficiar'], $db);
for ($b = 0; $b < count($beneficiari); $b++) {
if ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id']) {
$selected_bname = $beneficiari[$b]['nume'];
};
$selected = ($selected_contact['id_beneficiar'] == $beneficiari[$b]['id'] ? "selected = 'selected'" : '');
$content_beneficiari .= "<option " . $selected . " value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
for ($a = 0; $a < count($agentii); $a++) {
if ($selected_contact['agency_id'] == $agentii[$a]['id']) {
$selected_aname = $agentii[$a]['nume'];
};
$selected = ($selected_contact['agency_id'] == $agentii[$a]['id'] ? "selected = 'selected'" : '');
$content_agentii .= "<option " . $selected . " value='" . $agentii[$a]['id'] . "'>" . $agentii[$a]['nume'] . "</option>";
}
$btn_upd = "<button class='upd_pb'>Actualizeaza info</button>";
} else {
for ($b = 0; $b < count($beneficiari); $b++) {
$content_beneficiari .= "<option value='" . $beneficiari[$b]['id'] . "'>" . $beneficiari[$b]['nume'] . "</option>";
}
$selected_contact = null;
$agentii = null;
$btn_add_new = "<button class='add_new_pb'>Inregistreaza contact</button>";
}
$response = "";
$response .="<tr>";
$response .="<td colspan=\"2\"><label>CALL TRACEID :</label><br/><input type=\"text\" id=\"res_ctid\" value=\"" .$callTraceId. "\" /></td>";
$response .="</tr>";
$response .="<tr>";
$response .="<td><label>Nume :</label><br/><input type=\"text\" id=\"res_client_firstname\" value=\"" . #$selected_contact['first_name'] . "\" /></td>";
$response .="<td><label>Prenume :</label><br/><input type=\"text\" id=\"res_client_lastname\" value=\"" . #$selected_contact['last_name'] . "\"/></td> ";
$response .="<td><label>Telefon :</label><br/><input type=\"text\" id=\"res_client_phone\" value=\"" . $phone_no . "\"/></td>";
$response .="<td><label>Email :</label><br/><input type=\"text\" id=\"res_client_email\" value=\"" . #$selected_contact['email'] . "\"/></td>";
$response .="</tr>";
$response .="<tr>";
$response .="<td><label>Beneficiar :</label><br/><select id=\"res_client_company\">" . $content_beneficiari . "</select></td>";
$response .="<td><label>Agentia :</label><br/><select id=\"res_client_agency\" >" . $content_agentii . "</select></td>";
$response .="<td><label>Adresa :</label><br/><input type=\"text\" id=\"res_client_address\" value=\"" . #$selected_contact['adresa_agentie'] . "\"/></td>";
$response .="<td><span id=\"contact_info_act_btn\">" . $btn_add_new . "" . $btn_upd . "</span></br><span id=\"btn_act_resp\"></span></td>";
$response .="</tr>";
error_log($response);
echo $response;
}
}
?>
The word "true" is in the database where its getting the data from, but the if statement is going to the else.
while(odbc_fetch_row($user)){
echo "<div style='position:absolute;overflow:scroll;height:370px;'>";
$name = odbc_result($user, 'username');
$email = odbc_result($user, 'email');
$admin = odbc_result($user, 'admin');
$lastLogin = odbc_result($user, 'lastLogin');
$userDisabled = odbc_result($user, 'disabled');
$fullname = odbc_result($user, 'firstName') . " " . odbc_result($user, 'lastName');
echo "<br><h2> " . $name . "</h2>";
echo $fullname . "<br>";
echo " " . $email;
echo "<br>Last Login Time: <br>" . $lastLogin;
echo "<br>";
if($userDisabled == "true"){
echo "<input type='checkbox' class='disableUser' checked id='disableUser'>Disable User<br>";
}else{
echo "<input type='checkbox' class='disableUser' id='disableUser' >Disable User<br>";
}
echo "<br>";
}
so try with this :
if((is_bool($userDisabled) && $userDisabled === TRUE) || (is_string($userDisabled) && strtoupper($userDisabled) == "TRUE" ) {
# do your job
}else {
# you can eat or sleep :)
}