simplypixie 123 Posting Pro in Training

For each value that you want to check:

$errors = 0;
$error_msg = '';
if (!isset($_POST['fname']) || empty ($_POST['fname']))) { $errors++: $error_msg = 'Errors Text'; }
// And so on for each posted field you want to check and then echo out the errors in the page
if ($errors ==0) {
 // Run your insert / update querry
}
simplypixie 123 Posting Pro in Training

Your queries are wrong - you should be using = NOT LIKE when selecting by matching id (or any other data). LIKE is for finding similar data.

With regard to selecting one message for each batch of messages:

$query = mysql_query("SELECT * FROM  `private_messages` WHERE to_id='$ID' AND To_Deleted=0 ORDER BY id DESC LIMIT 1");
simplypixie 123 Posting Pro in Training

It is fairly simple.

  • Check the form has been posted
  • Check the content isn't empty
  • Display/echo the comment

And here is the code to do it:

<?php

    if(isset($_POST['content'] && !empty($_POST['content'])) {

        echo $_POST['content'];
    }
?>

Put this code within the page where you want the comment to be echo'd. Alternatively assign the posted data to a variable so that you can use it within the page more than once and also means you can hide the form if you also want to do that.

To assign to a variable, replace echo $_POST['content'] with $comment = $_POST['content'] and place the php above all html instead of within the page and when you need to display the comment you just echo it

<?php echo $comment; ?>

I am not going to go into replacing the form but maybe something you could look into and try for yourself.

simplypixie 123 Posting Pro in Training

Your centre image needs a left and right margin and your right div needs to come before your center div in the html. Have you checked all your widths and padding aren't totalling to wider than the containing div?

simplypixie 123 Posting Pro in Training

I have just replied to this on php-forum.com

simplypixie 123 Posting Pro in Training

It might be loading the old site as the image in my first post is a cached one. The scripts are definitely included. I use the same page to load multiple products and they add to the cart, it is just when only one products is displayed.

simplypixie 123 Posting Pro in Training

I am using jQuery and Ajax to add items to a shopping cart and in all areas of the site apart from one it works fine and I cannot for the life of me work out why this one area isn't working.

The form code (which is the same as in all other Add To Cart forms) is:

<form method="" class="add_to_cart">  
    <input type="hidden" name="item_id" value="prods_<?php echo $prodid;?>" />
    <input type="hidden" name="unit_price" value="<?php echo $price;?>" />
    <input type="hidden" name="item_name" value="<?php echo $objproducts->prod_name.' - '.$objproducts->prod_code;?>" />
    <input type="hidden" name="image" value="/images/products_tb/<?php echo $objproducts->prod_img; ?>" />
    <input type="hidden" name="item_qty" value="1"/>
    <input type="hidden" name="item_url" value="/diesel_engine_products/<?php echo $catid; ?>/<?php echo $objproducts->prodid; ?>/"/>
    <input type="submit" class="rounded-buttons" name="add_to_bag" value="Add to Bag" />
</form>

The jQery/Ajax is:

$('.add_to_cart').submit(function (e) {
    e.preventDefault();

    var currentUrl = window.location.href.substr(window.location.href.lastIndexOf("/") + 1);;

    $.ajax({
        url: '/inc/shopping_bag_functions.php',
        data: $(this).serialize() + '&action=add',
        type: 'POST',
        success: function(html) {
            $('#shopping-bag p').html(html);
            $('.add-item')
                .fadeIn('fast')
                .dialog({
                    height: 100,
                    modal:true
                });
            if(currentUrl == '/shopping-bag.php') {
                $('.add-item').fadeOut(1000, function() {
                  $(".add-item").dialog('close');
                });
                $("#inner-content").load(location.href + " #inner-content>*", "");
            }
        }
    });
});

The page where this is not working on the site is when viewing individual products, for example This Page.

Can anyone see the problem as I can't and am fairly sure it is something simply

simplypixie 123 Posting Pro in Training

You need to check if the posted data has a value and if so if it equals the value in the menu then if it does, mark as selected:

<option value="<?php echo $row_rs_condo['condo_name']?>" <?php if (!empty($_POST['condo_nm']) && $_POST['condo_nm'] == $row_rs_condo['condo_name']) { echo 'selected'; } ?>><?php echo $row_rs_condo['condo_name']?></option>
simplypixie 123 Posting Pro in Training

It is not ajax you need to do what you are looking for it is plain JavaScript or jQuery. In it's most basic form just use an alert

simplypixie 123 Posting Pro in Training

Not sure, but try something like (basically you need to use remove as well) this:

$('#dialog').dialog({
    modal: true,
    hide: "explode",
    show: "blind",
    close: function(event, ui) { 
        $(this).dialog('destroy').remove();
    }
});
simplypixie 123 Posting Pro in Training

OK, thank you.

simplypixie 123 Posting Pro in Training

I used to be able to select which forums I received through my RSS feed and since the changes to the site my RSS feed stopped working so I hvae re-subscribed but it appears that I now have to receive all new posts from all forums meaning I am getting 100's, many of which I can't help with as they are in areas that I can't help. Can I get back to selecting which forums I subscribe to?

simplypixie 123 Posting Pro in Training

Where is the code getting the 'voted' from the database and storing it in the session?

simplypixie 123 Posting Pro in Training

It's OK, all sorted - I just run the two separately using the normal form validation and then my ajax and that works

simplypixie 123 Posting Pro in Training

I am using jQuery and Ajax for some areas of a site and I cannot for the life of me work out how to only submit the Ajax if the form is valid. For normal jQuery validation I am using jquery.validate.min.js like this:

$("#po-login-form").validate();

This works fine.
I then have ajax functionality in some areas as such:

$('#po-login-box .login-send').click(function (e) {
    e.preventDefault();
        $.ajax({
            url: 'po-login.php',
            data: $('#po-login-box form.do-login').serialize() + '&action=send',
            type: 'POST',
            success: function(html) {
                if (html == 'success') {
                    $('#po-login-box #po-login').hide("fast");
                    $('#mask , .login-popup').delay(1500).fadeOut(300 , function() {
                        $('#mask').remove();
                    });
                    window.location.href = 'checkout-delivery.php';
                } else {
                    $('#po-login-box .login-error').show("fast");
                }
            }
        });
});

Again it works fine.

Now my problem - I can't work out how to combine the 2 to ensure the form is valid before it submits (at the moment the ajax is firing regardless of what I do. I have tried using an if statement around the ajax and beforeSubmit within the ajax but neither works.

if($("#po-login-form").validate({
    $.ajax({
        // ajax here
    })
}); // This gives me an error in the console

$.ajax({
    beforeSubmit: $("#po-login-form").validate(),
    // All other ajax here
}); //This just submits the form without validating

There must be a way to do this and must be a fairly normal requirement but I can't seem to work it out or find anything online to help.

simplypixie 123 Posting Pro in Training

Sorry, my bad as not what I meant to say. I should have said

Trigger click event if referring url contains certain parameters

Anyway I am happy with what I have and doesn't seem too long winded and keeps all my javascript / jquery together nicely but thank you for your help.

simplypixie 123 Posting Pro in Training

If anyone is interested, this is how I have resolved this issue (using the example url above):

if($('window.location.search.substring(1):contains("part_number")')) {
	    $('.enquiry-form').trigger('click');
	}
simplypixie 123 Posting Pro in Training

Sorry I obviously haven't made myself clear - it isn't the referring page that I need to check but if the url contains the additional parameter for the part number.

simplypixie 123 Posting Pro in Training

If you are just trying to delete a record you just need:

mysql_query("DELETE FROM kunder WHERE ID='".$row['ID']."'";

A for your link, that is just the formatting:

"<a href=\"se_kunder.php?id=".$row['ID']."\">Slet</a>" .
simplypixie 123 Posting Pro in Training

Your reference to $id needs to be $row

simplypixie 123 Posting Pro in Training

I hope the title means something, I don't really know how to explain what I am trying to do in a few words.
I think better with an example.

I have a click event to display an enquiry form on a contact page:

$("#enquiry-form").hide();
	$('.enquiry-form').click(function() {
		$(this).hide();
		$('#enquiry-form').fadeIn( 'slow', function() {
		      $('#senderName').focus();
		    } )
	});

All fine.

Now if a user clicks on the following link

<a href="contact-united-diesel.php?part_number=<?php echo $row['parts_number']; ?>"><input type="button" class="rounded-buttons" name="enquire" value="Enquire" /></a>

I want them to be taken to the contact page and display the Enquiry Form.

I want to know if it is possible (and if so, how) to trigger the click event that displays the enquiry form on the contact page if the page is accessed via the above link?

simplypixie 123 Posting Pro in Training

But it obviously isn't working properly otherwise you wouldn't have hot the error you mentioned. Set the default value for your decimal fields as '0.00' instead of null and see if that helps.

And don't use capitals - there is no need to shout when someone is trying to help you.

simplypixie 123 Posting Pro in Training

For a start, this is wrong values'.'(
I don't know what you are trying to do their but it will break your script. You are also mixing styles of quote marks in your value parenthesis so change them all to be the same.

Try this:

"INSERT INTO tablename(ABC,BCD,CDE,DEF,EFG,FGH,GHI,HIJ,IJK) values('".$this->_abc."','".$this->_bcd."','".$this->_cde."','".$this->_def."','".$this->_efg."','".$this->_fgh."','".$this->_ghi."','".$this->_hij."','".$this->_ijk."')";
simplypixie 123 Posting Pro in Training

I have found the problem, it is with my jQuery. Basically whichever product I select to add to the basket, it seems to be going to the last form on the page (i.e. the last product) and submitting that data instead and as some of these don't have prices that is why no price was being added.

I am now trying to resolve the problem with the incorrect item details being submitted but as this issue is resolved I will mark as solved.

simplypixie 123 Posting Pro in Training

OK I don't know what I have done but I did change the class name of the form and now amounts are being added. However they are strange amounts so I will now have to look into this new problem - oh well.

simplypixie 123 Posting Pro in Training

Yes but the price is not even being set in the session (before it even gets to the returned output) which is why it really isn't making any sense to me.

simplypixie 123 Posting Pro in Training

If I var_dump, I get the price

simplypixie 123 Posting Pro in Training

No, no dollar sign (i am not American so wouldn't be anyway :) ) or any others for that matter just (for example) 1.99

simplypixie 123 Posting Pro in Training

Decimal fields won't like empty values being passed even if they are set to NULL so you will need to run some checks and apply a value if the posted data is empty, for example

$this->_amount = !empty($_POST["txtamount"]) ? $_POST["txtamount"] : NULL;
simplypixie 123 Posting Pro in Training

What type is the field in your database?

simplypixie 123 Posting Pro in Training

Can anyone see why my variable $unit_price isn't updating (in fact it isn't even being applied to the session variable) in this code (it must be something simple but I can't see it and is driving me mad). I have tested the posted data and it is being sent through and all other posted variables are being added to the session.

Please note that this is also using jQuery and Ajax.

My form:

<form method="#" class="cart">  
<input type="hidden" name="item_id" value="prods_<?php echo $product['prodid'];?>" />
<input type="hidden" name="unit_price" value="<?php echo $product['prod_price'];?>" />
<input type="hidden" name="item_name" value="<?php echo $product['prod_name'];?>" />
<input type="hidden" name="item_qty" value="1"/>
<input type="hidden" name="item_url" value="https://www.uniteddiesel.co.uk/diesel-products.php?prod_id=<?php echo $product['prodid']; ?>/"/>
 <input type="submit" class="rounded-buttons" name="add_to_bag" value="Add to Bag" />
<a href="diesel-products.php?prod_id=<?php echo $product['prodid']; ?>/"><input type="button" class="rounded-buttons" name="view" value="View" /></a>
										 </form>

My jQuery / Ajax:

$('.cart').submit(function (e) {
		e.preventDefault();
		// validate form
		$.ajax({
			cache: false,
			url: 'inc/shopping_bag.php',
			data: $('form.cart').serialize() + '&action=send',
			type: 'POST',
			success: function(html) {
				$('#shopping-bag p').html(html);
			}
		});
	});

My PHP (sorry it's a bit long):

<?php
require_once("../includes/config.php");

//Check if the basket array exists or not
if (!is_array($_SESSION['basket']))
{
	$_SESSION['basket']=array();
}

if (!empty($_POST['item_id'])) {
$item_id=$_POST['item_id'];
}

$item_qty=ceil($_POST['item_qty']); // CEIL is to stop partial quantities (0.01 etc)
$unit_price=$_POST['unit_price'];
$item_name = $_POST['item_name'];
$item_url = $_POST['item_url'];

$match=0;

$count=0;

if($item_qty>0)
{
	//Where ids match, add the qty to the existing qty
	if (is_array($_SESSION['basket']))
	{
		foreach ($_SESSION['basket'] as $array)
		{
			if ($array['item_id']==$item_id)
			{
				$match=1;
				$array['item_qty']+=$item_qty;
				$_SESSION['basket'][$count]=$array;
			}
			$count++;
		
		}
	}
	
	//If we did not find a match, add the item to the array …
simplypixie 123 Posting Pro in Training

Have you unticked the box in the Settings->discussion to not allow comments (Allow people to post comments on new articles )?

simplypixie 123 Posting Pro in Training

Surely the first thing you need to do is set your session to keep the user logged in and then you would just use an if statement to check is logged in before showing the other forms:

<?php
session_start();
	 extract($_POST);
	 $uname=$_POST['user'];
	 $pwd=$_POST['password'];
	$con=mysql_connect('localhost','root','')

	or

	die('could not connect:'.mysql_error());

	mysql_select_db("priya",$con);
	$result=mysql_query("select * from user 
	where user='$user' and password='$password'");

	if(($row=mysql_fetch_array($result))!=0)
	{
         $SESSION['user_id'] = $row['user_id'];
	 $msg="Login successfu!!!";
	}
	else
	{
	$msg="Access Denied";
	}
	echo $msg;
 
	mysql_close($con);
	
	?>
<?php if (isset($_SESSION) && !empty($_SESSION['user_id'])) { ?>
Show forms here
<?php } ?>
simplypixie 123 Posting Pro in Training

It looks like you are trying to put a space between the 2 variables so you need to use quote marks:

$body = $name.' '.$number
simplypixie 123 Posting Pro in Training

You won't get anything as their is no such variable as $row. You need to add the $a variable to the end of your link url (why are you using the name parameter in the link??):

echo "<a href='viewlink.php?name=".$row['name']."'>". $row['name'] ."</a>". " | " ;

And on your receiving page:

$a = $_GET['name'];

And then use $a throughout the script where you are currently using $row

simplypixie 123 Posting Pro in Training

It basically means that your login details are incorrect for the database.

simplypixie 123 Posting Pro in Training

You can't get it from your login page - you need to retrieve it from the database once they have logged in correctly. Everything in your code is relying on the user inputting their year of birth in the login form and posting it through.

simplypixie 123 Posting Pro in Training

What is the code on your rollno.php page?

simplypixie 123 Posting Pro in Training

Or float the image class to the left

simplypixie 123 Posting Pro in Training

Thank you but could you tell me how I get those attributes into the fancybox which is where they are supposed to be? i.e. in

$.fancybox(data);

Or would I do it like this

$.fancybox(data,
{
'width' : '30%',
'height' : '30%'
}
);
simplypixie 123 Posting Pro in Training

I am new to Ajax and have only been learning jQuery on and off for a few months so I apologise if this should be simple. I have followed a tutorial to get shopping cart functionality working using PHP, jQuery and Ajax and it is nearly there but I have a few issues that I just can't seem to work out.

1. I am using an iframe / popup effect for when items are added to the shopping cart using Fancybox and even though it appears it is very slow and it doesn't adjust to the settings I have specified.

2. Once an item is added, if any adjustments are made to the basket it redirects to the actual shopping cart page rather than reloading in the iframe.

3. I am not sure how to update the quantity and total items in the permanent shopping cart div in the sidebar of the site's pages without having to refresh the page (I have no code for this yet so looking for pointers).

When viewing the shopping cart (from a link) the iframe appears as it should and any changes made reresh in the iframe, this is the code for this part:

$(".shopping_bag").fancybox({
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

The problematic code is

$("form.add_to_bag").bind("submit", function() {
			var orderCode = $("input[name=order_code]", this).val();  
			var quantity = $("input[name=quantity]", this).val();
	    $.ajax({
	        type        	: "GET",
	        cache       	: false, …
simplypixie 123 Posting Pro in Training

You have an incorrect $ in your update query and no quote marks around your variable

$ser_no=$sernum

Coorect:

$sql2="UPDATE $tbl_name SET status='Completed' WHERE ser_no='".$sernum."'";
simplypixie 123 Posting Pro in Training
SELECT * FROM name WHERE task_my_id NOT IN (SELECT task_my_id FROM subname)
simplypixie 123 Posting Pro in Training

I am not saying that this is what is causing the problem (though it may be) but you have 2 id's named the same (you can only use one id per page, otherwise it needs to be a class):

<div id="navdiv">
			<!--about us submenu list ends-->
		<ul id="navdiv">
simplypixie 123 Posting Pro in Training

In the value of each form field you need to echo the posted data, for example

<input type="text" name="username" value="<?php if (isset($_POST['username'])) { echo $_POST['username']; } ?>">
simplypixie 123 Posting Pro in Training

Before you even look at getting the query results as @ardav has mentioned, your query will fail anyway as your form variables are wrong to work with what you are trying to do (you have put the method as get then tried to get the value using post - also not sure where your form is supposed to be submitting to with just .php in the action).

Change your form tag to

<form action="nameofpagetosubmitot.php" method="post">
simplypixie 123 Posting Pro in Training

This might help you work out what you need to do

if (!is_array($_SESSION['basket']))
{
	$_SESSION['basket']=array();
}

if (is_array($_POST['qty'])) {
	foreach ($_POST['qty'] as $key=>$quantity) {
		$quantity=ceil($quantity);
		if ($quantity==0) {
			unset($_SESSION['basket'][$key]);
		} else {
			$_SESSION['basket'][$key]['qty']=$quantity;
		}
	}
}
simplypixie 123 Posting Pro in Training

You simply need

Select customerNumber From Table1
Where customerNumber NOT IN (select customerNumber from table2)

You don't need to join or select from 2 tables in the main part of your query

haranaboy commented: Thanks for your help +2
simplypixie 123 Posting Pro in Training

Use CSS - for example set the table rows to white with black text and change the odd rows to a balck background with white text (modify to your needs, desired colours)

tbody tr { background: white; color: black;
tbody tr:nth-of-type(odd), .odd { background: black; color: white; }

This doesn't work in IE 8 or below.

simplypixie 123 Posting Pro in Training

Your problem is here

$rows=mysql_fetch_array($sql3);

This should be

$rows=mysql_fetch_array($result3);
karthik_ppts commented: yes +7