patk570 42 Newbie Poster

Instead of contactid in the php code on the bottom change it “ticketnumber” or use a ‘if(isset….. )‘ code

patk570 42 Newbie Poster

Echo $sql in your first statement and see what values are being submitted. See if any are null or not being converted to strings that is unrecognizable.

patk570 42 Newbie Poster

one thing is where is the new status coming from? is it coming from the URL?

if so, you can have something like:

<!DOCTYPE html>
<html>
<body>

<?php

<?php
    if(isset($_GET['status'])){
    $new_status = $_GET['status'];
    if($status=="your variable"){
        echo $sendData = '{ "messages" : [ { "content" : "Your order is $new_status.", } ] }';
    }
    }
?>



echo "<h2>" . $new_status . "</h2>";
echo  $sendData . "<br>";
?>

</body>
</html>
patk570 42 Newbie Poster
$sql = "UPDATE payfile set 
amtpaid = '', late ='', hudpay ='',  paidsum ='',      datepaid ='', 
 latechg = '', secdep = '', damage = '',     courtcost = '', nsf = '', chgmoyr = ' ', comments    =' '  
 WHERE amtpaid =!''";

This is all blank quotes, so nothing is going to be updated

patk570 42 Newbie Poster

Hi Everyone,

I am looking for a way to add a username to confirm a seat choice for certain weeks, I already have the PHP Code to confirm the seat when choosing but on the image i would like for it to display the username so other people know its taken and by who. The seats are ordered from 1 - 10 and the dealer seat is not available.

I have an image and i know its going to require CSS, Jquery and PHP to do this.

Attached is the image for the seats. Starting at the dealer(middle top) going clockwise is 1- 10

Basically I'm going to have a popup menu that shows available seats, if a seat is taken, ill hide it with my PHP code so its not selectable. Its going to be based on a date so every week it will change.

I am not sure if this is actually possibe using a static image or if I am going to have to create a new image using indesign or flash or something.

Any ideas would be great, im not looking for complete code just an idea of how to get started.

image0_(4).jpeg

patk570 42 Newbie Poster

I have a JSON array that has multidimensions to it:

{
      "@id": "a",
      "@label": "A",
      "drecord": [
         {
            "@id": "aaliyah",
            "@rdate": "2001-08-25",
            "@lease": "bh05",
            "name": {
               "surname": "Aaliyah"
            },
            "job": "hip hop singer/actress",
            "dead": {
               "@value": "y"
            },
            "cause": "Burned to death in a plane crash",
            "ddate": {
               "date": "2001-08-25"
            },
            "bdate": {
               "date": "1979-01-16"
            },
            "other": {
               "#text": [
                  "Full name: Aaliyah Dana Haughton, was to have appeared in the second and third",
                  "movies."
               ],
               "movie": "Matrix",
               "home": {
                  "@id": "http://www.aaliyahEbertonline.com/"
               },
               "imdb": {
                  "@id": "Aaliyah"
               },
               "fg": {
                  "@id": "5727911"
               }
            }
         },

and i am trying to use the jQuery Auto Complete to get the name and surname to populate...right now all its doing is returning blank results when i type in a name like "aaliyah".

here is my jQuery Code:

$( function() {

    $( "#birds" ).autocomplete({
      source: function( request, response ) {
        $.ajax( {
          url: "dpsportion.json",
          type: "GET",
          dataType: "json",
          data: {
            term: request.term
          },
          success: function( data ) {
            response( data );
          }
        } );
      },
      minLength: 2,
      select: function( event, ui ) {
        console.log( "Selected: " + ui.item.drecord.name.fname + " aka " + ui.item.drecord.name.surname );
      }
    } );
  } );

what am i doing wrong? I thought i had to reference the line that i want like drecord.name or drecord.surname

patk570 42 Newbie Poster

This is what is returned

patk570 42 Newbie Poster

Hi, thanks for the reply,

i updated my code as follows:

var jsonArray = results;
            var li;
             for(var i in jsonArray){
                    var objectInstance = jsonArray[i];
                    for(var j in objectInstance.drivers) {
                        var driver = objectInstance.drivers[j];

               var stTime = new Date(results[i].dateTime);
               var status = objectInstance[i].status;
               var id = objectInstance[i].id;
               var driverf = driver.firstName;
               var driverl = driver.lastName;
               var driverCode = driver.employeeNo;
               var origin = objectInstance[i].origin;
               var editTime = new Date(objectInstance[i].editDateTime);
               console.log(driverf);
               console.log(status);
               let timeDifferenceMilliseconds = (new Date().getTime() - stTime.getTime());

               let timeDifferenceHours = timeDifferenceMilliseconds / 3600000;

               let timeDifferenceEditTime = (editTime.getTime() - stTime.getTime());

               let editDifferenceHrs = timeDifferenceEditTime / 3600000; 

               //console.log("Driver "+driverf+" Created Time: "+ stTime +"Edited :"+ editTime+ " Hours: "+ Math.round(editDifferenceHrs))

               if((timeDifferenceHours) > 30 && editDifferenceHrs >24){
                   li = $('<li/>');
                   li.append("Driver "+ driverf +" "+  driverl+" ("+ driverCode +")" +" on "+ stTime + " Has The Status Of " + status +" and is greater than "+Math.round(timeDifferenceHours) +" hours");
                   $('#listDrivers').append(li);
                   refreshOnDutyReport();
               }
             }
           }

but now it wont even console.log anything. I think I am doing this right, since i have never used a for (in) loop

patk570 42 Newbie Poster

Hey everyone, I have a JSON array that pulls data, its an immense amount of data that i use. It is a multilevel array eg:

dateTime: 2018-12-04T10:30:45:222z
comments:""
+Driver[0]

    [0]
        fname: John
            lname: Doe
        driverCode: DOEJ

    [1]
        fname: Mary
        lname: Smith
        driverCode: SMIMA
more info etc

I am trying to access dateTime, as well as driver.fname, driver.driverCode etc...

here is what i have tried so far...

var json = results;
      var li;

      for(var i; i=0; i < json.length; i++){
          for (var j; j=0; j < json[i].driver.length; j++){

        var stTime = new Date(json[i].dateTime);
        var status = json[i].status;
        var id = json[i].id;
        var driverf = json[i].driver[j].firstName;
        var driverl = json[i].driver[j].lastName;
        var driverCode = json[i].driver[j].employeeNo;
        var origin = json[i].origin;
        var editTime = new Date(json[i].editDateTime);

Its telling me that I am missing a ")" on for loop for "j" and it cannot find the object of length on "j" loop. What am i doing wrong? This seems like it is legit, but I am not sure.

patk570 42 Newbie Poster

I have a code that pulls a JSON response, and I need to compare times from now() and a previous when the timestamp was created. I am able to pull the info and have it display.

However,
when i try and get the comparison to work it just sits there and doesnt display anything.

Here is my code

    "use strict";
        var endDate = new Date();
        endDate.setHours(endDate.getHours());

        var startDate = new Date();
        startDate.setHours(- 12);

     api.call("Get", {
                "typeName": "DutyStatusLog",
                "search": {
               "fromDate" : startDate,
               "ToDate" : endDate,
               "statuses" :['ON']
                 }

              }, function(results){
                 console.log(results);
                 for(var i=0; i<results.length; i++){
                   var stTime = results[i].dateTime;
                   var status = results[i].status;
                   var driver = results[i].driver.id;
                   //stTime.getHours();
                   console.log("Driver "+ driver +" at time: ",stTime + " And Has The Status Of " + status);
                   var newDate = new Date();
                   //newDate.getHours();

                   if((stTime - newDate ) > 6){
                       console.log("Answers: ",answerThis);
                   }
                 }
              });

Yes, i Know answerThis is not defined right now, But I am trying to just get the comparison to work right now if its greater than 6 hrs

here is what is returned from the array:

+annotations: Array[1]
+coDrivers: Array[0]
dateTime: "2018-02-12T20:37:26.594Z" //this is what i want to subtract from newDate
+device: Object
distanceSinceLastValidCoordinate: 0
+driver: Object
editDateTime: "2018-02-12T20:39:09.829Z"
eventCode: 4
eventRecordStatus: 1
eventType: 1
id: "a8g2YKRG0lEu5X7fEjiGp7g"
+location: Object
malfunction: "None"
origin: "Manual"
sequence: "0000000000000677"
state: "Active"
status: "ON"
version: "0000000000044acd"
patk570 42 Newbie Poster

are you passing the id variable in the link to the page? When you do a $_REQUEST['id'] its looking for ?id=1 or ?id=testuser in the link from the previous page.

patk570 42 Newbie Poster

Whats the error? and you are also wide open to SQL Injection. After $qur put or die("Mysqli Error: " $qur");

patk570 42 Newbie Poster

Here is where i got to so far.

CaclulateTaxGallons = function() {

    $('tr.IFTAtable').each(function(i, el) {
        var $this = $(this),

            $miles = $this.find('[name="stateMiles\\[\\]"]'),
            $mpg = $this.find('[name="mpg\\[\\]"]'),
            c = parseFloat($miles.val()),
            q = parseInt($mpg.val()),
            total = c / q || 0;
        $this.find('[name="total\\[\\]"]').val(total.toFixed(2));
    });

};

CaclulateQuantityTotal = function() {
    CaclulateTaxGallons();
}

html:

<tr>
<td>CT</td>
<td>089</td>
<td>
  <input type="text" class="CtMiles" /> </td>
<td>
  <input type="text" onblur="CaclulateQuantityTotal();" name="stateMiles[]" id="CtMiles" class="CtMiles" />
</td>
<td>
  <input id="MPG"  type="text" name="mpg[]" class="mpg">
</td>
<td>
  <input type="text" name="total[]" class="calcTax[State]" />
</td>
<td>
  <input type="text" class="taxPdGallons[State]" tabindex="1" placeholder="TCH RPT" />
</td>
<td></td>
<td>.4170</td>
<td></td>
<td>&nbsp;</td>
<td></td>
</tr>
patk570 42 Newbie Poster

I am trying to figure out this loop for the math statement,

I am completely lost on how to do it based on each state.

Here is my fiddle on how i started...
https://jsfiddle.net/qq6whe31/

but i will say that i can completely lost...

patk570 42 Newbie Poster

when i populated the number...i had a localization string .toLocaleString() and it was messing up the number. Once i removed the .toLocaleString() it fixed it and its now working beautifully. Sorry to bother ya...

patk570 42 Newbie Poster

Guys and gals,

I am trying to do a simple LITTLE DIVIDE problem using jQuery its getting the values, but when its returning the results, it as if they are being divided by 10000, but I know its not...

E.G. 50506/1000 = 50.506

in my jquery problem, it is coming up as

E.G. 50506/1000 = 0.050506

Here is my jquery

$(function(){
    $('#copy').click(function(e){

        var calculate = parseFloat($("#totalMiles").val()) / parseFloat($("#totalGallons").val());
        $('#TotalMPG').val(calculate);
        var totalMPG = $('#TotalMPG').val();
        $('.mpg').val(totalMPG);
        sync(); <--this is another function i have above this...disreguard
    });
});

can anyone see what my issue is?

patk570 42 Newbie Poster

but that still isnt what i am wondering, Each input is going to have a state eg:

<td><input type="text" readonly="readonly" class="WV calcTax" /></td>
<td><input type="text" readonly="readonly" class="PA calcTax" /></td>
<td><input type="text" readonly="readonly" class="OH calcTax" /></td>

Can i do one formula and have it loop through to do the math like this:

Total Miles / MPG = Taxable Gallons | Tax Gallons- Tax Paid Gallons = Net Taxable Gallons| Net Taxable Gallons (*) Tax Rate = Tax Credit Due/Credit

To get that, I have have the report that gives me the gallons for each state used, that will always be a manual input.

I am just wondering to get that math done, can i use 1 formula and have it loop though like a case statement to figure out the above formula onkeyup or press a button that has function doThisMath(); and have it fill out all the appropiate fields.

patk570 42 Newbie Poster

Okay, so ill make it a text box where they put the value they get from the feds., but my main focus, is how would i calculate each row of data indivually based on the state class, i already have a jquery totalling the state miles, but these trucks move in between different states all the time.

patk570 42 Newbie Poster

Hello rproffitt,

We are a trucking company, the taxes are basically going to hard coded into a PHP Database, I know that they will change and I will be responsibe for changing them or if there is an api for the tax rate that i can do a cron job i will, but there is a <td>.3785</td> field that i will populate in the input box. I just didnt put the box yet.

patk570 42 Newbie Poster

Hey everyone, I have a table, that is going to used to calculate IFTA, its a fueltax calculator populated by each state and the rate of each state. My question is, do i need to create a formula for each state? or can i do 1 formula and have it read for each class? Where it says [StateName] that is going to change to what state it is for.

<table class="IFTAtable" id="FuelTaxIFTA" width="100%" border="1" cellpadding="2.5" cellspacing="5">
  <tr>
    <th>Juristiction</th>
    <th>Rate Code</th>
    <th>Total IFTA Miles by State</th>
    <th>Taxable Miles</th>
    <th>MPG </th>
    <th>Taxable Gallons</th>
    <th>Tax Paid Gallons</th>
    <th>Net Taxable Gallons</th>
    <th>Tax Rate</th>
    <th>Tax Credit or Tax Due</th>
    <th>Interest </th>
    <th>Total Due</th>
  </tr>
  <tr>
    <td>CT</td>
    <td>089</td>
    <td><input name="stateMiles" type="text" class="[stateName]Miles" readonly="readonly" /> </td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input id="MPG" type="text" name="mpg" class="mpg" readonly="readonly"></td>
    <td><input type="text" readonly="readonly" class="calcTax[State]"  /></td>
    <td><input type="text" class="taxPdGallons[State]" tabindex="1" autofocus="autofocus" placeholder="TCH RPT" /></td>
    <td>taxableGallons(-)TaxPaid</td>
    <td>.4170</td>
    <td>netTaxGallons * Tax Rate</td>
    <td>&nbsp;</td>
    <td><p>taxCredit+Intrest</p></td>
  </tr>
  <tr>
    <td>DE</td>
    <td>086</td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input id="MPG" type="text" name="mpg" class="mpg" readonly="readonly"></td>
    <td><input type="text" readonly="readonly" class="calcTax[State]"  /></td>
    <td><input type="text" class="taxPdGallons[State]" tabindex="2" placeholder="TCH RPT" /></td>
    <td>&nbsp;</td>
    <td>.2200</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>IN</td>
    <td>179</td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input id="MPG" type="text" name="mpg" class="mpg" readonly="readonly"></td>
    <td><input type="text" readonly="readonly" class="calcTax[State]"  /></td>
    <td><input type="text" class="taxPdGallons[State]" tabindex="3" placeholder="TCH RPT" /></td>
    <td>&nbsp;</td>
    <td>.4700</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>KY</td>
    <td>171</td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input type="text" name="stateMiles" class="[stateName]Miles" readonly="readonly" /></td>
    <td><input id="MPG" type="text" …
patk570 42 Newbie Poster

another screenshot

patk570 42 Newbie Poster

here is the output

patk570 42 Newbie Poster

Hi PTY, here is my Fiddle its just showing the js code i am using.

Fiddle

patk570 42 Newbie Poster

Question,

I have a $each(array, function()); and within that statement, i have afor loop , Is it safe to be doing this? and could this be the reason that i am getting the same values multiple times returned even though the object array length is 8, i am getting basically doubled up results, sometimes its more. if you need to see my code, i can post it.

patk570 42 Newbie Poster

6
●4

I have a code that displays an array from GeoTab SDK, I am able to get the array to display in the console.log, and it populates the results like normal, However, When I try to populate the data in the table, nothing shows but the headings.
Here is my code, and I will generate an object array and paste the code as well. I know the data that is generated is valid data,

function generateDutyStatusLogSearch1(){
api.call("Get", {
"typeName": "DutyStatusLog",
"search": {
"statuses": ["D", "OFF", "SB", "ON"],

},

}, function(dutyStatusLogs) {
var uniqueDrivers = {};
var multicall = [];
dutyStatusLogs.forEach(d => {
if (d.driver !== "NoUserId" && !uniqueDrivers[d.driver.id]) {
uniqueDrivers[d.driver.id] = d.driver;
multicall.push(["Get", {
typeName: "User",
search: {
id: d.driver.id
}
}]);
}
});

api.multiCall(multicall, function(drivers) {
drivers.forEach(d => {
uniqueDrivers[d[0].id] = d[0];
});
dutyStatusLogs.forEach(d => {
d.driver = uniqueDrivers[d.driver.id];
});
console.log("Done: ", dutyStatusLogs);
$.each(dutyStatusLogs, function( index, value ) {
 var row = $(value.driver.designation + value.status + value.state + value.driver.comment + value.origin  + value.dateTime);
 $('#demo-table').DataTable({
     paging: false,
     searching: false,
     data: row,

[object Array]: []
     columns: [

    [0...99]: Array
         { title: "Driver" },

[0...9]: Array
         { title: "Status" },

0: Object
         { title: "State" },
dateTime: "2017-11-15T12:15:13.190Z"

         { title: "Comments" },
device: Object
id: "b14"
         { title: "Origin" },

__proto__: Object
         { title: "Date" }
distanceSinceLastValidCoordinate: 0

     ]
driver: Object
acceptedEULA: 0

activeDashboardReports: Array
    });
activeFrom: "2017-11-09T14:22:52.607Z"
activeTo: "2050-01-01"
});
authorityAddress: "5505 State Route 405 SouthPO Box 355Milton, PA 17847"
authorityName: "Milton Transportation"
}, function(e) { …
patk570 42 Newbie Poster

Hey everyone, I have a script that does an API call, the results are displayed in a json array, but i am trying to break them down into HTML tables

here is my code

  var deviceId = ""; 

 api.call("Get", {
    typeName : "DutyStatusLog",
    search : {
            deviceSearch : {
                    driver : deviceId
            }
    }
}, function (result) {
    if (result !== null && result.length > 0) {
        document.getElementById("dataString").innerHTML = JSON.stringify(result[0])
    }
}, function (errorString) {
    alert(errorString);
});

and the output is :

{"id":"aOfoqjT0Yr0igg2i3PCXrGg","location":{"location":{"x":-76.86248779296875,"y":41.004390716552734}},"status":"Login","origin":"Automatic","device":{"id":"b2F"},"dateTime":"2017-11-24T15:38:01.620Z","driver":{"id":"b12"},"state":"Active","malfunction":"None","version":"00000000000060c1","sequence":"000000000000025a","eventRecordStatus":1,"eventCode":1,"eventType":5,"distanceSinceLastValidCoordinate":0}

WHat i want to know is how can i get this above string formatted into an HTML table and automaticall create rows when it loops?

patk570 42 Newbie Poster

It was something completely stupid, I was using the slim version of jQuery CDN, instead of the full version. It was a simple mistake that was overlooked until i went and examined the code. Once i put the full version, it resolved the issue i was having. UGH, i feel stupid at times. haha!

rproffitt commented: Thanks for sharing. Usually helps others when we reveal what it was. +14
patk570 42 Newbie Poster

Hi rproffitt, I am unable to run this on chrome either, its throwing the error that $.ajax is not a function??? I never heard of this.

patk570 42 Newbie Poster

Hey everyone, this code below is giving me a weird error, Script 438: Object doesn't support property or method 'ajax'. I am testing this in Microsoft Edge, but...I have a website that uses this exact same code, and its working like normal. I am getting the var id to load properly, I am not sure why it is not working, since, its working on the other site. I copied and pasted the code to match exact. anywho, its stating that it at the $.ajax({ line.

<script>
$(function(){
    $('.get-msg').click(function(){
    var id = $(this).attr('data-id');
    $.ajax({
          type : 'GET',
           url : 'viewmessage.php',
          data :  'dataID='+ id,
          success : function(r){

              $('#messageModal').modal('show');
             $('#messageBody').show().html(r);
            }
        });
    });
});
</script>

if(isset($_GET['dataID']) && is_numeric($_GET['dataID'])){
     $id = mysqli_real_escape_string($link, $_GET['dataID'] );
     $query = "SELECT * FROM `jobs` WHERE `id`='$id' LIMIT 1";
     $result = mysqli_query($link, $query);
     $message = "";
     if($result){
         $row = mysqli_fetch_assoc($result);
         $message .= '<div><h4>Title: </h4><h5>'.$row['title'].'<h5></div>';
         $message .= '<hr><br>';
         $message .= '<div><b>Job Description:<br>'.$row['description'].'</b></div>';
         $message .= '<hr><br>';
         $message .= '<div><b>Rate:<br>'.$row['rate'].'</b></div>';
         echo $message;
     }else{
         echo "No such data"; 
     }
}
patk570 42 Newbie Poster

I would suggest something like this: https://swisnl.github.io/jQuery-contextMenu/demo.html

its based in jQuery, which will make it easier to code. I sent you the demo link.

patk570 42 Newbie Poster

Also, you want to figure out what backbone you want to use to make it mobile friendly. We cannot just give answers we need a basis of foundation to start off, so we can give you advise or advise what direction to take.

patk570 42 Newbie Poster

Thanks

patk570 42 Newbie Poster

Haha, that was a typo, there is no Java, its all PHP and CSS. I edited the content.

patk570 42 Newbie Poster

It looks like you are missing a closing <tr> attribute in your first table field.

patk570 42 Newbie Poster

Hey everyone, I got bored one day and created this little jem. There are no issues with it, but it may help somone out later on down the road if they have a simple project that needs to be completed. Everything is on one pages and includes elements like Array Functions, Randomization and CSS.

<!DOCTYPE html>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bored? Try This Random Generator</title>

<meta content="This is a random sentence generator, so if you get bored you can sit here and press the button multiple times." />
<link href="https://fonts.googleapis.com/css?family=Indie+Flower" rel="stylesheet"> 

<style>
.button {
           background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 16px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    border-radius:10px;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
}
.img{
    position: relative;
    display: inline-block;
}
.img2{
    -moz-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1);
    filter: FlipH;
    -ms-filter: "FlipH";
}
</style>
</head>

<body style= "background-color:<?php echo GenerateRandomColor() ?>;">
<!-- /////////////////////////////////// -->
<?php
function GenerateRandomColor()
{
    $color = '#';
    $colorHexLighter = array("9","A","B","C","D","E","F" );
    for($x=0; $x < 6; $x++):
        $color .= $colorHexLighter[array_rand($colorHexLighter, 1)]  ;
    endfor;
    return substr($color, 0, 7);
}
function GenerateRandomColor1()
{
    $color = '#';
    $colorHexLighter = array("9","A","B","C","D","E","F" );
    for($x=0; $x < 6; $x++):
        $color .= $colorHexLighter[array_rand($colorHexLighter, 1)]  ;
    endfor;
    return substr($color, 0, 7);
}
if(isset ($_POST['newQuote'])){
$quote = array(
"I wish I had",
"Why Can't I have",
"Can I have", 
"Did you have",
"Will you get",
"When will I get"
);  
$rand_quote = array_rand($quote,1);
$items …
patk570 42 Newbie Poster

updated fiddle here: https://jsfiddle.net/oten520g/

patk570 42 Newbie Poster

Directly from getboostrap.com

Inline form
Add .form-inline to your form (which doesn't have to be a <form>) for left-aligned and inline-block controls. This only applies to forms within viewports that are at least 768px wide.

<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Name</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Email</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
</div>
<button type="submit" class="btn btn-default">Send invitation</button>
</form>

Use the .form-inline class to make the form go "side by side"

patk570 42 Newbie Poster

Hey Diafol, I echoed the $nid variable and it does show my user_id. Since i am the first one in the database, it echos 1. I do have the session_start() variable listed. I cannot make heads or tails of this one. haha. I might want to just go back to the procedural way of doing myslqi. haha.

t_thakar, as stated above, it does echo 1 since i am the first user.

patk570 42 Newbie Poster

Hey Diafol, I am using this to set $nid : $nid = $_SESSION['user_id'];. The user is me, so when it shows 1, that is me in the DB for user_id field.

patk570 42 Newbie Poster

Okay, so last one...

fixed that issue:

  $stmt = $this->db_connection->prepare("UPDATE `users` SET last_login = ? WHERE user_id = ? ");
                    $stmt->execute(array(date("Y-m-d H:i:s"), $nid));
                    print_r( $stmt );

Still will not update though...

here is what it returns...

mysqli_stmt Object
(
[affected_rows] => 0
 [insert_id] => 0
 [num_rows] => 0
 [param_count] => 2
 [field_count] => 0
 [errno] => 0
 [error] => 
 [error_list] => Array
    (
    )

[sqlstate] => 00000
[id] => 1

)

patk570 42 Newbie Poster

Okay, so I got the first bug to work, but now it will not update the date time...

                    $nid = $_SESSION['user_id'];
                    $date = date("Y-m-d H:i:s");
                    $stmt = $this->db_connection->prepare("UPDATE `users` SET `last_login` = ? WHERE `user_id` = ? ");
                    $stmt->execute(date("Y-m-d H:i:s"), '$nid');

                    echo "Date: ".var_dump($date);
                    echo "User ID: ".var_dump($nid);

Here is the result set that is returned...

  object(mysqli_stmt)#5 (10) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0)     ["param_count"]=> int(2) ["field_count"]=> int(0) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) } Statement: string(19) "2017-06-05 22:13:56" Date: string(1) "1" User ID: 
patk570 42 Newbie Poster

So i have a simple script nothing to big, but im already getting an unexpected "updateTime"

 $sql = "UPDATE users SET last_login = NOW() ";
 $updateTime = $this->db_connection->exec($sql);

THis is my first time using PDO and I am already getting errors after 2 lines...

patk570 42 Newbie Poster

Cannot get this to refresh. My code is below. I am propably doing something silly, but I cannot figure it out...

var auto_refresh = setInterval(
 function(e) { 
 var email = '<?php echo $_SESSION['user_email']?>';
 console.log(email);
  e.preventDefault();
   $.ajax({
      type : 'GET',
       url : 'count_record.php', // in here you should put your query 
      data :  'email='+ email, // here you pass your id via ajax .
                 // in php you should use $_POST['post_id'] to get this value 
      success : function(r){

          // now you can show output in your modal 
          $('#messages1').load(r).fadeIn("slow"); 
 }:15000);
 }
});
patk570 42 Newbie Poster

Just add the AddType application/x-httpd=php .html .htm then the pages will work. It will make the server think that HTML/HTM pages are PHP and read the scripting you added.

patk570 42 Newbie Poster

Thats not bad, but Like i said, I am not a stylist when it come to these things. I am the kind that kinds a nice template and just from there and makes a few tweaks. I am going to look at the UI kits. and see what i can come up with.

patk570 42 Newbie Poster

Hey everyone,

I have a site that has a customer account, right now it looks like crap and i need an idea on how to style it. Right now I am using Bootstrap, but I want to move away from it and try something else. My issue is, I have no CSS expierence. I can PHP code, but I cannot CSS for the life of me.

Attached is how my site looks now.

I would like to have a very nice looking "My Account" section. Any suggestions would be nice or maybe some layout options.

patk570 42 Newbie Poster

What Cereal said, when you have a field that is disabled, it will not send a variable to the server whereas the readonly field will send that field to the server.

patk570 42 Newbie Poster

add this to your .htaccess file

Apache2 @ Ubuntu/Debian: use this directive

 AddType application/x-httpd-php .html .htm

If your are running PHP as CGI (probably not the case), you should write instead:

  AddHandler application/x-httpd-php .html .htm 
patk570 42 Newbie Poster

I got it to work, i had to modify what you put and changed a few values. The code is working like it should now.

jquery:

     $(function(){

$('.get-msg').click(function(e){
  var id = $(this).attr('data-id');
  e.preventDefault();
   $.ajax({
      type : 'GET',
       url : 'viewmessage.php',
      data :  'dataID='+ id,
      success : function(r){
      $('#messageModal').modal('show');
      $('#messageBody').show().html(r);
    }
});

});

});

Link:

<a href="#" class="get-msg btn btn-xs btn-primary" data-id="'.$values['ID'].'">View</a>

PHP:

if(isset($_GET['dataID']) && is_numeric($_GET['dataID'])){
 $id = mysqli_real_escape_string($link, $_GET['dataID'] );
 $query = "SELECT `subj`, `message` FROM `tb_cform` WHERE `ID`='$id' LIMIT 1";
 $result = mysqli_query($link, $query);
 $message = "";
 if($result){
     $row = mysqli_fetch_assoc($result);
     $message .= '<div><h4>Subject: </h4><h5>'.$row['subj'].'<h5></div>';
     $message .= '<hr><br>';
     $message .= '<div><b>Message:<br>'.$row['message'].'</b></div>';
     echo $message;
 }else{
     echo "No such data"; 
 }
}

This code is perfect for populating a modal with information. I am posting the answer in hopes that it will help someone else out.

Basically, I had to get the var id set by using the class reconignation .get-msg then when you have that link clicked, it finds that attribute set in this case data-id and displays the results based off the link. The next is just strait AJAX call, by using GET and setting the PHP to get the dataID that is passed by AJAX, it will populate the results into the modal body on success. There are a few other properties that validates that the variable is numeric first before passing it on. With this, you just need one Modal to use and it will find any value that is assigned to the data-id

diafol commented: Glad it helped :) +15
patk570 42 Newbie Poster

So i figured out the issue, it is now displaying the results, however, $(a[data-target="#messageModal"]).data('id'); will not pass the value, i had to use: var id = $("#messageID").attr("data-id");. This is working, but becuase there are multiple instances of #messageID listed, it is only showing the first result becuase you cannot have duplicate ID tags with the same information.

My question is how can i assign or get a value added after #messageID like an array using[ ] to assign a value and have it look for that then get the data-id value to pass?