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

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

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

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

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

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

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

this is what i was trying to acheive. I found a solution and adapted it.

    include ("lock.php");
// Select the data from table_name
$result = mysqli_query($bd,"SELECT * FROM products");

// Display the table
echo "<table class=\"table table-bordered\">";

// Put results into table
$counter = 0;
while($row = mysqli_fetch_array($result))
{

// Display the image
echo "<td align='left'><a href=\"" .$row['path'] . "\">

<span class='producttable'><img width='140' src=\"" . $row['path'] . "\" border=1 alt=\"" . $row["path"] . "\" title=\"" . $row["price"] . "\"></span>

<br>
<span class='producttext'>$row[product_name]</span></br><br>$row[description]

</br>

</span></a>";
echo "<br><span class='producttext'><strong>&pound;$row[search_price]</strong></span></br>";

$counter++; # increment count every iteration
if ( $counter % 3 == 0 )
{
echo "<tr />";
}
}
echo "</td>";
echo "</table>";
rproffitt commented: I read you wanted to loop. Missed that you wanted 3 per row. +12
patk570 42 Newbie Poster

Hey Everyone, I am looking for possibly a CRM that can be used for multiple items:

1. Invoicing
2. Credit Card Processing
3. Front End Website
4. Customer Area/Members Pages
5. Admin Area
6. Integrate with Quickbooks?
7. Manage Employees (Time and Sales) 
8. Inventory Management

Any advice would be helpful. I am not looking to spend alot of money, If there are opensource CRM's that will do this, that would be fine. I have already tried OSPOS and its just not what i am looking for.

patk570 42 Newbie Poster

I just looked at it on my side, and its working like you want, here is a screenshot

egsonas commented: Hmmm.... Starnge. have you any changes to code or just putted codes in separate files? +1
patk570 42 Newbie Poster

I got it!!! here is what i did:

if(isset($_POST['AddHardwareAsset'])){
            $asset_tag = mysqli_real_escape_string($mysqli,$_POST['assetTag']);
            $serial_number = mysqli_real_escape_string($mysqli,$_POST['serialNumber']);
            $vendor = mysqli_real_escape_string($mysqli,$_POST['vendor']);
            $platform = mysqli_real_escape_string($mysqli,$_POST['platform']);
            $type = mysqli_real_escape_string($mysqli,$_POST['type']);
            $model = mysqli_real_escape_string($mysqli,$_POST['model']);
            $status = mysqli_real_escape_string($mysqli,$_POST['status']);
            $location = mysqli_real_escape_string($mysqli,$_POST['location']);
            $user = mysqli_real_escape_string($mysqli,$_POST['user']);
            $user_name = mysqli_real_escape_string($mysqli,$_POST['user_name']);
            $purchase_date = mysqli_real_escape_string($mysqli,$_POST['purchase_date']);
            $warranty_end_date = mysqli_real_escape_string($mysqli,$_POST['warranty_end_date']);
            $item_address = mysqli_real_escape_string($mysqli,$_POST['item_address']);
            $user_phone_number = mysqli_real_escape_string($mysqli,$_POST['user_phone_number']);
            $comments = mysqli_real_escape_string($mysqli,$_POST['comments']);
            $repair_history = mysqli_real_escape_string($mysqli,$_POST['repair_history']);
            $product_key = mysqli_real_escape_string($mysqli,$_POST['product_key']);

            $hardquery = "INSERT INTO assets (cust_id, asset_tag, serial_number, vendor, platform, type, model, status, location, user, user_account, purchase_date, warranty_date, item_address, phone_number, comments, repair_history, product_key,asset_type) 
VALUES ('$custID','$asset_tag','$serial_number','$vendor','$platform','$type','$model','$status','$location','$user','$user_name','$purchase_date','$warranty_end_date','$item_address','$user_phone_number','$comments','$repair_history','$product_key','hardware')";
        if ( $mysqli->query($hardquery) ) {

    $id = $mysqli->insert_id;

$addevent = "INSERT INTO events(title, event_date, cust_id, asset_id) VALUES ('$type', '$adddate', '$custID', '$id')";
$mysqli->query($addevent);

    $result =  '<div class="alert alert-success">'.$asset_tag.' has been added</div>';
} else {
    $result = '<div class="alert alert-danger">Item not added.</div>';
}
        }
patk570 42 Newbie Poster

Hi guys, I am trying to get the last_insert_id() from the table above, that way when it sends the query and is successful, it then updates the events table with timestamp, id , asset type and asset id from the insert code. I am currently using the max(id) but its not working, I want to make this easy and work perfectly. Any ideas what I can do differnt?

Thanks.

if(isset($_POST['AddHardwareAsset'])){
            $asset_tag = mysqli_real_escape_string($mysqli,$_POST['assetTag']);
            $serial_number = mysqli_real_escape_string($mysqli,$_POST['serialNumber']);
            $vendor = mysqli_real_escape_string($mysqli,$_POST['vendor']);
            $platform = mysqli_real_escape_string($mysqli,$_POST['platform']);
            $type = mysqli_real_escape_string($mysqli,$_POST['type']);
            $model = mysqli_real_escape_string($mysqli,$_POST['model']);
            $status = mysqli_real_escape_string($mysqli,$_POST['status']);
            $location = mysqli_real_escape_string($mysqli,$_POST['location']);
            $user = mysqli_real_escape_string($mysqli,$_POST['user']);
            $user_name = mysqli_real_escape_string($mysqli,$_POST['user_name']);
            $purchase_date = mysqli_real_escape_string($mysqli,$_POST['purchase_date']);
            $warranty_end_date = mysqli_real_escape_string($mysqli,$_POST['warranty_end_date']);
            $item_address = mysqli_real_escape_string($mysqli,$_POST['item_address']);
            $user_phone_number = mysqli_real_escape_string($mysqli,$_POST['user_phone_number']);
            $comments = mysqli_real_escape_string($mysqli,$_POST['comments']);
            $repair_history = mysqli_real_escape_string($mysqli,$_POST['repair_history']);
            $product_key = mysqli_real_escape_string($mysqli,$_POST['product_key']);

            $hardquery = "INSERT INTO assets (cust_id, asset_tag, serial_number, vendor, platform, type, model, status, location, user, user_account, purchase_date, warranty_date, item_address, phone_number, comments, repair_history, product_key,asset_type) 
VALUES ('$custID','$asset_tag','$serial_number','$vendor','$platform','$type','$model','$status','$location','$user','$user_name','$purchase_date','$warranty_end_date','$item_address','$user_phone_number','$comments','$repair_history','$product_key','hardware')";

    $query = "SELECT max(id) FROM assets ORDER by id DESC LIMIT 1";
    if ($result = $mysqli->query($query)) {
        /* fetch associative array */
     $row = $result->fetch_assoc();
     $insertid = $row["id"];
}
        if ( $mysqli->query($hardquery) ) {

            $addevent = "INSERT INTO events(title, event_date, cust_id, asset_id) VALUES ('$type', '$adddate', '$custID', '$insertid')";
                $mysqli->query($addevent);

    $result =  '<div class="alert alert-success">'.$asset_tag.' has been added</div>';
} else {
    $result = '<div class="alert alert-danger">Item not added.</div>';
}
        }
patk570 42 Newbie Poster
patk570 42 Newbie Poster

Fixed it:

$count = mysqli_query($mysqli, "SELECT (SELECT COUNT(*) FROM assets WHERE cust_id=$custID AND asset_type='hardware') + (SELECT COUNT(*) FROM assets WHERE cust_id=$custID AND asset_type='software') AS total_count");
echo mysqli_error($mysqli);
$count = mysqli_fetch_object($count);
$count = $count->total_count;
patk570 42 Newbie Poster

Robin Hood, Men in Tights

patk570 42 Newbie Poster

I fixed the issue i was having, and it is working really good now.

Thanks for the help

//put query string above to get results

$cats_array = explode(",", $myEdit['categories']);

then below that in the checkbox array i have:

<td>
  <label>
     <input name="categories[]" 
        <?
        if (in_array(1, $cats_array)){
        echo 'checked="checked"';
        } else {
        echo '';
        }
        ?> 
    value="1" type="checkbox" />Quadriceps
  </label>
</td>

Now it is working like a charm and I do not have to remember what category each belong to.

patk570 42 Newbie Poster

the js, very simple and easy.

<script type="text/javascript">
function hideMe()
{
document.getElementById('otheroption2').style.display="none" ;
}
</script>
 <script type="text/javascript">
function showMe()
{
document.getElementById('otheroption2').style.display="block" ;
}
</script>

the html

basic:

            <td><select name="referredby">
<option onclick="return hideMe();" value="Facebook">Facebook</option>
<option onclick="return hideMe();" value="Twitter">Twitter</option>
<option onclick="return hideMe();" value="Angie's List">Angie's List</option>
<option onclick="return hideMe();" value="Google">Google</option>
<option onclick="return hideMe();" value="Bing">Bing</option>
<option onclick="return showMe();"  value="Friend">Friend</option>
<option onclick="return showMe();" value="Other">Other</option>

</select><input type="text" value="Please Specify:" onclick="this.value='';" name="otheroption2" id="otheroption2" style="display:none" />