paulkd 59 Newbie Poster

Might your other records may contain a trailing space?

paulkd 59 Newbie Poster

Hi Jim,

There's no real mystery to ajax. It is simply a GET or POST to a standard cfml file, the response of which is then processed/acted on by JavaScript.

First thing to confirm is whether the url that the ajax is calling is working. You should be able to create a url yourself, my guess is it would look something like:-

https://fisnet.wvu.edu/secure/_listmodels.cfm?make=ford&edit=0

I've tried but I get timed out - your site may be behind some security.

paulkd 59 Newbie Poster

You have two drop downs. Are they both populated via ajax or just the models drop down?

paulkd 59 Newbie Poster

I've posted some code on cats/subcats. Hope it helps. See last post.

Click Here

paulkd 59 Newbie Poster

I've changed cookieid to fileid seems more appropriate.

   $output = '<div class="header">';
   $output .= '<img src="../images/siteimages/logo.png"alt="Logo image" />';
   $output.= '<div id="headerrotator">';
   include 'connect.php';
   $fileid = isset($_COOKIE['fileid']) ? $_COOKIE['fileid'] : 1;
   $q ="SELECT * FROM headerrotatorimage WHERE rotator = 1 AND status = 1 AND id <> $fileid ORDER BY RAND() LIMIT 1" or die (mysqli_error($link));
   $result = $link->query($q);
   while($row = mysqli_fetch_array($result)){
   setcookie('fileid',$row['id']);
   $output .= "<img src='{$row['filename']}' alt='{$row['name']}. image' />";
   }
   $output.= '</div>';
   $output.= '<div id="wishlistmenu">';
   $output.= '<ul>';
   $output .= '<li><a href="wishlist.php">Login/Register</a> </li>';
   $output .= '<li><a href="wishlist.php">Wish List</a> </li>';
   $output .= '<li><a href="wishlist.php">Reviews/Testing</a> </li>';
   $output .= '<li><a href="wishlist.php">View Cart</a> </li>';
   $output .= '<li><a href="wishlist.php">Terms/Delivery</a> </li>';
   $output .= '<li><a href="wishlist.php">Contact Us</a> </li>';
   $output.= '</ul>';
   $output.= '</div>';
   $output .= '</div>';

   echo $output;
paulkd 59 Newbie Poster

Untested.
Assuming your table contains an id column.
Set a cookie of the id of the last image displayed.
If this is first time (cookie doesn't exist) simply set a $cookieId of 1.

Amend your query to

$q ="SELECT * FROM headerrotatorimage WHERE rotator = 1 AND status = 1 and id <> $cookieId ORDER BY RAND() LIMIT 1" or die (mysqli_error($link));
paulkd 59 Newbie Poster

Rahul47,

What are you trying to achieve? What is your goal?

paulkd 59 Newbie Poster

Using JavaScript you can practically use any element to submit a form.

I think the <button> tag might also submit without JavaScript.

Also, pressing the enter key in an input text field will submit a form without the need for a button :-)

paulkd 59 Newbie Poster

Rahul47,

<input type="submit"... is actually the normal "submit" button.

paulkd 59 Newbie Poster

You said you already have an email function - you can simply feed $message from the code below into your email function.

<?php 

$username = "root"; // Mysql username
$password = "root"; // Mysql password
$db_name = "Stock"; // Database name
$host = "somehost";

mysql_connect($host, $username, $password) or die("Failed to connect to MySQL");
mysql_select_db($db_name); //SELECT THE CORRECT DATABASE

$rs = mysql_query("select ProductID, ProductDescription from Products where ProductQuantity < 1");

if(mysql_num_rows($rs)>0) {

    $message = '<p>The following products are out of stock</p><ul>';
    while($row = mysql_fetch_assoc($rs)) {
        $message .= '<li>'.$row['ProductID'].' '.$row['ProductDescription'].'</li>';
    }
    $message .= '</ul>';

    echo $message;
    //email your $message 

} else {
    //email a message that all products have stock
}


?>
paulkd 59 Newbie Poster

...and I presume you want a single email detailing the products, not one email per product?

paulkd 59 Newbie Poster

As iamthwee and myself mentioned - our idea was to send an email at the time that a particular product's stock level becomes zero.

Your code appears to want to check all products' stock levels on demand and send an email.

So forget code... let's think process. Do you simply want a function that can be run anytime that checks the stock level of all products and sends an email reporting which products are at zero?

paulkd 59 Newbie Poster

If IIM's solution doesn't fix your problem can you stick pages 1, 2 and 3 into a zip file and upload?

paulkd 59 Newbie Poster

I assume there's more code as we are in infinite loop territory otherwise :-)

paulkd 59 Newbie Poster

Any Code?

paulkd 59 Newbie Poster

I've done that too. :-)

paulkd 59 Newbie Poster

Isn't that what I said?

paulkd 59 Newbie Poster

I can send email in PHP

So the answer is Yes.

I presume there is a PHP function you call to remove an item from the database. After this function is run, you should simply run the function that returns the product quantity of the item and then send a PHP email if quantity is less than 1.

Pseudo code (PHP):

decrementProduct($productId);
$product = getProductDetails($productId);
//assumption that returned $product is an array
if($product['quantity']<1) {
    sendNoStockEmail($product);
}
paulkd 59 Newbie Poster

Do you already have a an email function?

paulkd 59 Newbie Poster

First off, I wouldn't store comma-delimited lists in a database field.
That said, here is some code for you to try.

<?php 

$hobbies = array(
    'Swimming',
    'Trekking',
    'Scuba Diving',
    'Birding'
);

//simulate your database field result
$dbResultHobbies = 'Swimming,Trekking,Birding';

$dbResultHobbiesArray = explode(',',$dbResultHobbies);

?>

<form>
    <?php foreach($hobbies as $hobby): ?>
        <?php if(in_array($hobby,$dbResultHobbiesArray)): ?>
            <p><input name="hobby[]" type="checkbox" value="<?php echo $hobby; ?>" checked="checked"> <?php echo $hobby; ?></p>
        <?php else: ?>
            <p><input name="hobby[]" type="checkbox" value="<?php echo $hobby; ?>"> <?php echo $hobby; ?></p>
        <?php endif; ?>
    <?php endforeach; ?>
</form>
Albert Pinto commented: Thanx Sir..... +2
paulkd 59 Newbie Poster

how can I remove something like everything except for "efg" from "abcdefghijklm" without know what anything is except for "ef"?

var alpha = 'abcdefghijklm';
var pattern = 'ef';
var re = new RegExp(pattern+".");
result = alpha.replace(re,"");
alert(result);
paulkd 59 Newbie Poster

@atikah8890 using my code you can then create your JavaScript var using

var dataLevel = <?php echo json_encode($q).';'; ?>

and to test the following JavaScript line should print understand

document.write( dataLevel[2][1] ); 
paulkd 59 Newbie Poster

This should give you the data structure you are after:-

$q = array();
while($row = mysql_fetch_assoc($query)){
    $q[] = array((int)$row['q_id'],$row['response_value'],(int)$row['cr_chpt'],(int)$row['ql_level']);
}   
paulkd 59 Newbie Poster

Lines 21 & 22 Change to:-

$('.success').fadeOut(200);
$('.error').fadeIn(200);
paulkd 59 Newbie Poster

What is the actual problem you are having?

paulkd 59 Newbie Poster

Are you using jQuery or just raw JavaScript?

paulkd 59 Newbie Poster

Code works fine, but in case I mistyped $_SESSION, here's the before and after delid=19 is removed.

$delid = 19;

$cartItems = array(
    array('id' => 18, 'name' => 'book'),
    array('id' => 19, 'name' => 'testing'),
    array('id' => 1, 'name' => 'fruity loops')
 );

 print_r($cartItems);

foreach($cartItems as $key => $products){
    if($products['id']==$delid) {
        unset($cartItems[$key]);
    }
}

echo '<hr>';
print_r($cartItems);
paulkd 59 Newbie Poster

Can you post a var_dump of your actual $_SESSION['cartItems'] ?

paulkd 59 Newbie Poster

Your array has two identical records (both [id] => 2), so I assume you copy/pasted for quickness.
You also have a ; missing in your for statement after $contents

foreach($_SESSION['cartItems'] as $key => $products){
    if($products['id']==$delid) {
        unset($_SESSION['cartItems'][$key]);
    }
}
paulkd 59 Newbie Poster

I've create a simple jsfiddle.

BTW I'm from a ColdFusion background, but I never used any cfform statements.

paulkd 59 Newbie Poster

What options are in the select?

paulkd 59 Newbie Poster

I learn something everyday :-) file()

You should use foreach not for to iterate through your user records.

paulkd 59 Newbie Poster

Need a little more snippet.. e.g. where did $user_length come from ?
is u0003:omied:123456-12-1234:male:married:privatesector:dfsfsdf:603-32323242:6016-2343432:omied@gmail.com:omeid123:dingo1234 associated with a variable?

paulkd 59 Newbie Poster

If error logging is disabled, is it possible your host has disabled your ability to rename?

paulkd 59 Newbie Poster

Let me know how you eventually become unstumped Bradley :-)

paulkd 59 Newbie Poster

Start with adding lots of echos....

e.g. between line 3 and 4 add echo '1';
after your $_POST check line add echo '2';

if they don't show up add a die after them... echo '1';die;

if it doesn't show up check config.php

paulkd 59 Newbie Poster

This code is based on your original code - to replace lines 22-67.

<?php  
$currentSODate = '';
$displaySubTotal = FALSE;
$subTotal = 0;
$grandTotal = 0;
?>
    <table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table">
        <tr>
            <td class="tbl_header">SO Date</td>
            <td class="tbl_header">MV CODE</td>
            <td class="tbl_header">MV NAME</td>
            <td class="tbl_header">RATE</td>
            <td class="tbl_header">SUPP.QTY</td>
            <td class="tbl_header">AMT</td>
        </tr>
        <?php while($row = $stmt->fetch()): ?>
            <?php if($currentSODate!=$row['SODate']): ?>
                <?php if($displaySubTotal): ?>
                    <tr>
                        <td colspan="4">
                        <td><b>subtotal</b></td>
                        <td><b><?php echo number_format($subTotal,2); ?></b></td>
                    </tr>
                    <?php $grandTotal += $subTotal; ?>
                    <?php $subTotal = 0; ?>
                <?php else: ?>
                    <?php $displaySubTotal = TRUE; ?>
                <?php endif; ?>
                <?php $currentSODate = $row['SODate']; ?>
            <?php endif; ?>
            <tr>
                <td class="tbl_content"><?php echo date("d-m-Y", strtotime($row['SODate']));?></td>
                <td class="tbl_content"><?php echo $row['MVCode'];?></td>
                <td class="tbl_content"><?php echo $row['MVName'];?></td>
                <td class="tbl_content_right"><?php echo number_format($row['Rate'],2) ;?></td>
                <td class="tbl_content_right"><?php echo number_format($row['Qty']) ;?></td>
                <td class="tbl_content_right"><?php echo number_format($row['BalAmt'],2) ;?></td>
            </tr>
            <?php $subTotal += $row['BalAmt']; ?>
        <?php endwhile; ?>
        <?php $grandTotal += $subTotal; ?>
        <tr>
            <td colspan="4">
            <td><b>subtotal</b></td>
            <td><b><?php echo number_format($subTotal,2); ?></b></td>
        </tr>
        <tr>
            <td colspan="4">
            <td><b>grand total</b></td>
            <td><b><?php echo number_format($grandTotal,2); ?></b></td>
        </tr>
    </table>
   <?php unset($dbh); unset($stmt); ?>
paulkd 59 Newbie Poster

Can you post all your PHP code, but NOT your mysqli credentials.

paulkd 59 Newbie Poster

I'm looking closer at your code original and it's making less sense. Help me out.

Line 5 - you have ended your php block with ?> so how is line 7 going to work ?

paulkd 59 Newbie Poster

Are you running these operations manually, or is there some wrapper script doing the work for you ?

paulkd 59 Newbie Poster

Your appear to be missing a mysql_select_db()

paulkd 59 Newbie Poster

I've never used backbone, and just trying to get my head around it's concepts.. but the documentation appears to suggest that the .create will fire a "request"

Creating a model will cause an immediate "add" event to be triggered on the collection, a "request" event as the new model is sent to the server, as well as a....

I may be way off :-)

paulkd 59 Newbie Poster

A quick look at your screenshot would suggest that you are not truncating the table - simply running the script over and over. e.g. id numbers for Westville Jnr are in increments of 39.

paulkd 59 Newbie Poster

Sorry, I ran your code five times and every time was successful. The only thing that did error was your fclose - you need to change it to fclose($handle);

RoryGren commented: Thank you! +4
paulkd 59 Newbie Poster

Are you able to provide an attachment of real data, of perhaps fake data that also results in the duplicate records?

paulkd 59 Newbie Poster

Hi showman13,

The div tags should not affect your table in any way.

You don't actually need div tags, simple H1->H6 and P tags should be sufficient for what you need (and your table).

The reason your H3 isn't naturally bold is that they have been set to "normal" in gen_css.css line 191.

paulkd 59 Newbie Poster

Without seeing the snippet of code that performs the POST "we" are unable to suggest where the issue lies.

paulkd 59 Newbie Poster

If I were going to use tables for a quick layout they would have been for the 3 columns at the top, but you have used floated divs, then further down you appear to be using a table where simple divs or paras are called for.

I would start by ripping out the CSS styles e.g. <h3 class="B"> make it <h3>. Your style sheet has a lot of horrendous style names which thankfully you don't appear to be using.

paulkd 59 Newbie Poster

David,

Yes. I now see that your arrays are starting at 1. I created my test data with a simple array(3,10) (for weight etc) which meant that they start at 0.

Glad to help.

paulkd 59 Newbie Poster

For the largest volume, are you interested in the actual largest volume or the box's index of the largest volume or both?