load part of page when cash page in server side - php

Page contains product details and rate them.
Rating is 5 stars that is works with ajax.
I want to cache these pages in server side but how can i cache product details without rating.
<div class='product-container' >
<div class='product-container-right' >
<h3>product-name</h3><br/>
<p>some detail about product</p>
</div>
<div class='vote-request'>rate this product:</div><br/>
<div id='productvote-20' class='product-vote' >
<input type='checkbox' name='vote' value='1' />
<input type='checkbox' name='vote' value='2' />
<input type='checkbox' name='vote' value='3' />
<input type='checkbox' name='vote' value='4' />
<input type='checkbox' name='vote' value='5' />
</div>
</div>
I want to cache div class='product-container-right' in server side.
how every time page (div class='product-container-right') is loaded from cache read div id='productvote-20' class='product-vote' by javascript( or jquery).

you need to add AJAX request that will run once on document-ready to get rating from PHP page and update the rating
$(document).ready( function(){
$('#productvote-20').load('Rating.php?productId=1');
})
And in that PHP file, you need to output this.. but don't cache that page
<input type='checkbox' name='vote' value='1' />
<input type='checkbox' name='vote' value='2' />
<input type='checkbox' name='vote' value='3' />
<input type='checkbox' name='vote' value='4' />
<input type='checkbox' name='vote' value='5' />

Related

Need help saving values from a checkbox without a form

Hello I will try an explain myself as clear as possible. I'm trying to add a filter products using multiple checkboxes that the user can click on that will alter the my php mysql query.
I have seen some examples of this online but they just show and hide divs. I would like to take the value of the checkboxes click and insert them in the query dynamically.
So my questions is how could I pass a value from multiple checkboxes with out using a form?
<div id="filterContentTitle">Filter Results</div>
<div id="filterContentResults">
<div id="filterContentCat">Categories</div>
<input type='checkbox' name='categories' value='1' /><label for='categories'>Dishwashers</label><br /><input type='checkbox' name='categories' value='2' /><label for='categories'>Hoods</label><br /><input type='checkbox' name='categories' value='3' /><label for='categories'>Microwaves</label><br /><input type='checkbox' name='categories' value='4' /><label for='categories'>Refrigerators</label><br /><input type='checkbox' name='categories' value='5' /><label for='categories'>Stoves & Ranges</label><br /><input type='checkbox' name='categories' value='6' /><label for='categories'>Washers & Dryers</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Brands</div>
<input type='checkbox' name='brand[]' value='GE' /><label for='brand'>GE</label><br /><input type='checkbox' name='brand[]' value='Viking' /><label for='brand'>Viking</label><br /><input type='checkbox' name='brand[]' value='Whirlpool' /><label for='brand'>Whirlpool</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Refrigerators Type</div>
<input type='checkbox' name='subCategory[]' value='French Door'><label for='subCategory'>French Door</label><br /><input type='checkbox' name='subCategory[]' value='Bult-In'><label for='subCategory'>Bult-In</label><br /><input type='checkbox' name='subCategory[]' value='Side by Side'><label for='subCategory'>Side by Side</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Refrigerators Capacity</div>
<input type='checkbox' name='capacity[]' value='20.7 cu ft'><label for='capacity'>20.7 cu ft</label><br /><input type='checkbox' name='capacity[]' value='28.6 cu ft'><label for='capacity'>28.6 cu ft</label><br /><input type='checkbox' name='capacity[]' value='20.4 cu ft'><label for='capacity'>20.4 cu ft</label><br /><input type='checkbox' name='capacity[]' value='24.6 Cu. Ft.'><label for='capacity'>24.6 Cu. Ft.</label><br /><input type='checkbox' name='capacity[]' value='25 cu. ft.'><label for='capacity'>25 cu. ft.</label><br /><input type='checkbox' name='capacity[]' value='22.0 Cu. Ft.'><label for='capacity'>22.0 Cu. Ft.</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Condition</div>
<input type='checkbox' name='condition[]' value='New'><label for='condition'>New</label><br /> </div>
<hr />
<div id="filterContentResults">
<div id="filterContentCat">Color</div>
<input type='checkbox' name='color[]' value='Stainless Steel'><label for='color'>Stainless Steel</label><br /><input type='checkbox' name='color[]' value='Black'><label for='color'>Black</label><br /><input type='checkbox' name='color[]' value='Biscuit'><label for='color'>Biscuit</label><br /> </div>
What you can do is bind into the jQuery change event on the input.
When the inputs are changed, you can then update the query that is being sent (presumably with Ajax) to the PHP script
$("input").change(function() {
updateProductList($(this).attr("id"), $(this).prop("checked"));
});
function updateProductList(field, state) {
// Do Work
$.ajax({
source: "my-url.php?" + field + "=" + state
});
}
Note: the example is simplified, but hopefully you get the idea.

Set multiple fields of form on particular radio button click

I'm developing a web app in which I've to integrate a Paypal account. There are many radio buttons on the page that represents various credits and it's price and like wise. My Problem is, I want some functionality through which I can set various other fields of form on one of the radio button click. And those values are different for every radio button.
<form action='<?php echo $paypal_url; ?>' method='post' name='form'>
<div class="crea_paka_title">Creadit Pakages</div>
<?php
foreach($admin_credits as $credits){
?>
<div class="creadit_fields">
<span class="for_radio">
<input type="radio" name="1" id="<?php echo $credits['AdminCredit']['id'];?>" value="" />
</span>
<span class="for_creadit">
<?php echo $credits['AdminCredit']['tx_total_credits']; ?> Credits
</span>
<span class="for_cre_value">
$<?php echo $credits['AdminCredit']['nu_total_price']; ?>
</span>
</div>
<div style="clear:both;"></div>
<?php
}
?>
<input type='hidden' name='business' value='<?php echo $paypal_id; ?>'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='item_name' value='<?php echo $credits['AdminCredit']['tx_total_credits'];?> Credits'>
<input type='hidden' name='item_number' value='<?php echo $credits['AdminCredit']['id'];?>'>
<input type='hidden' name='amount' value='<?php echo $credits['AdminCredit']['nu_total_price'];?>'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='currency_code' value='USD'>
Like as above in my code I've to change the values of inputs on radio button click. Any suggestions are appreciated.
jQuery will do it:
$("#rbID").click(finction(){
$("otherRB").attr("checked",true);
});

UPDATE through selected radio button

Hi guys and sorry for my english,
I try to make a simple UPDATE through selected radio buttons, but it's not working. I have a 3 <input type='radio'> buttons in while loop and every button should do something else which I want to filtered.
$result=mysql_query("SELECT id FROM table WHERE state=0");
while ($record=mysql_fetch_array($result)):
<form method='post' action=''>
<input type='radio' name='state' value='1' /> 1
<input type='radio' name='state' value='2' /> 2
<input type='radio' name='state' value='3' /> 3
<input type='submit' value='Send' />
</form>
endwhile;
If I choose one of the three button and click on "Send", then one row (based on ID) should be UPDATE a MySQL db:
mysql_query ("UPDATE table SET state=(selected radio button number 1-3) WHERE id=$record[id]");
But, the script it must be out of the while loop and if I make it this way, it's not working because the script can't recognize which ID was chosen.
If I make it like this:
$result=mysql_query("SELECT id FROM table WHERE state=0");
while ($record=mysql_fetch_array($result)):
<form method='post' action=''>
<input type='radio' name='state' value='$record[id]' /> 1
<input type='radio' name='state' value='$record[id]' /> 2
<input type='radio' name='state' value='$record[id]' /> 3
<input type='submit' value='Send' />
</form>
endwhile;
then ID is recognize by script, but I don't know, how can I filtered which number (1, 2 or 3) is sending to UPDATE query for "state" column. It's a big dilemma for me and I can't figure out. I need to recognized ID and filter the chosen number (1-3). Can you help me out ?
There is two options.
First:
$result=mysql_query("SELECT id FROM table WHERE state=0");
while ($record=mysql_fetch_array($result)):
<form method='post' action=''>
<input type='hidden' name='recordId' value='$record[id]' />
<input type='radio' name='state' value='1' />
<input type='radio' name='state' value='2' />
<input type='radio' name='state' value='3' />
<input type='submit' value='Send' />
</form>
endwhile;
and
$recordId = (int)$_POST['recordId'];
$state = (int)$_POST['state'];
mysql_query ("UPDATE table SET state=$state WHERE id=$recordId");
Second:
$result=mysql_query("SELECT id FROM table WHERE state=0");
<form method='post' action=''>
while ($record=mysql_fetch_array($result)):
<input type='radio' name='state[$record[id]]' value='1' />
<input type='radio' name='state[$record[id]]' value='2' />
<input type='radio' name='state[$record[id]]' value='3' />
endwhile;
<input type='submit' value='Send' />
</form>
and
foreach($_POST['state'] as $key => $val) {
$recordId = (int)$key;
$state = (int)$val;
mysql_query ("UPDATE table SET state=$state WHERE id=$recordId");
}
(note that the code above is probably not syntactically correct, and given as an illustration to the idea)
Also, mixing up code and data is a bad practice; consider using prepared statements instead.

paypal form not sending data properly

I am trying to submit the following paypal form through a hosted-payment system. however, it does not seem to be passing through any of the variables apart from the price.
Can anyone see where I am going wrong:
<form action='https://securepayments.paypal.com/cgi-bin/acquiringweb' method='post' target='hss_iframe' id='PayPalForm' name='PayPalForm'>
<input type='hidden' name='cmd' value='_hosted-payment' />
<input type='hidden' name='charset' value='utf-8' />
<input type='hidden' name='currency_code' value='GBP' />
<input type='hidden' name='business' value='seller#email.com' />
<input type='hidden' name='paymentaction' value='sale' />
<input type='hidden' name='template' value='TemplateD' />
<input type='hidden' name='return' value='http://yoursite.com/groupon-success.php' />
<input type='hidden' name='notify_url' value='http://yoursite.com/paypal-groupon- ipn.php' />
<input type='hidden' name='item_name' value='Item name' />
<input type='hidden' name='item_number' value='4' />
<input type='hidden' name='subtotal' value='0.01' />
<input type='hidden' name='custom' value='41' />
<input type='hidden' name='address_override' value='true' />
<input type='hidden' name='first_name' value='Jack' />
<input type='hidden' name='last_name' value='Jones' />
<input type='hidden' name='address1' value='address1' />
<input type='hidden' name='city' value='Manchester' />
<input type='hidden' name='zip' value='M20 1AA' />
<input type='hidden' name='country' value='UK' />
<input type='hidden' name='billing_first_name' value='Jack' />
<input type='hidden' name='billing_last_name' value='Jones' />
<input type='hidden' name='billing_address1' value='address1' />
<input type='hidden' name='billing_city' value='Manchester' />
<input type='hidden' name='billing_zip' value='M20 1AA' />
<input type='hidden' name='billing_country' value='UK' />
</form>
it is then been passed to an iframe which seems to work fine using:
<iframe width="100%" scrolling="no" height="580px" frameborder="no" name="hss_iframe" style="float:right;"></iframe>
<script type="text/javascript">
$(function(){
$("#PayPalForm").submit();
});
</script>
Can anyone help with why this data does not seem to pass anything through
--------------- EDIT
Changed cmd to _xclick and passes through fine, so obviously an issue with _hosted-payment
Can anyone give any ideas
If by "however, it does not seem to be passing through any of the variables", you mean it doesn't display the item name / item number: that's correct. Website Payments Pro Hosted Solution doesn't currently support item details. You should remove these parameters as they're not in use for this product.
In addition, the billing/shipping address will be used, but you won't be able to modify them if you're using templateD.

IE6 Not submitting POST Data?

I have just tested my site on an old IE6 browser on a windows server.
The problem I have is when I submit a form, the POST data I get on the other page is empty. Array().
This site has worked on IE6 on a different windows server, it has worked on my laptop and works on all other major browsers (Firefox, Chrome, IE6,7,8, Safari) etc.
Its just this one machine. Is there a setting not to allow post data on IE6?
Thanks all
HTML
<form method="post" action="save_settings.php">
<div class='rw'>a
<input class='set_inp' type='text' name='a' id='a' value='' />
</div><div class='rw'>b
<input class='set_inp' type='text' name='b' id='b' value='' />
</div><div class='rw'>c
<input class='set_inp' type='text' name='c' id='c' value='' />
</div><div class='rw'>d
<input class='set_inp' type='text' name='d' id='d' value='' />
</div><div class='rw'>e
<input class='set_inp' type='text' name='e' id='e' value='' />
</div><div class='rw'>f
<input class='set_inp' type='text' name='f' id='f' value='' />
</div><div class='rw'>g
<input class='set_inp' type='text' name='g' id='g' value='' />
</div><div class='rw'>h
<input class='set_inp' type='text' name='h' id='h' value='' />
</div><div class='rw'>i
<input class='set_inp' type='text' name='i' id='i' value='' />
</div><div class='rw'>j
<input class='set_inp' type='text' name='j' id='j' value='' />
</div>
<input id="submit" name="submit" type="submit" value="Save" />
</form>
Try installing a plugin like http://www.brothersoft.com/iehttpheaders-13615.html on your IE. That will make sure that the POST data does is not being sent to the server.
Then try an antivirus scan on your computer. I have noticed this behaviour before when there was a virus.
Remove any IE browser toolbar / extension installed.
The answer can be found on here: http://support.microsoft.com/?id=251404
This setup of IE6 has a strange way of handling handshakes with the server.
In addition, enhanced security for Internet explorer was installed.

Categories