Jump to content

amavadia

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by amavadia

  1. Thank you. I did try that before as well but just realised the silly error i made... used the form name as the selector rather than form id
  2. I have a form on my page with various elements and have created a seperate validate php page. At the bottom of my form I have a button (type="button"). When it is clicked, the data is posted to the validate page, and errors returned. If errors are returned it displays them, if not I want it to post and redirect to another page like a normal form. The problem I have is when I use a type="button" button, the first part works fine but obviously it does not post and redirect because it is not a submit button, but if I change the button type to submit, the .click() handler on the button does not seem to be firing and so the page is posted even without checking for errors. Should i be using a different handler on the submit button as opposed to a button button?
  3. Thanks David, Gave your modifications a go and it didnt work the first time but then I tried putting the second bind inside the last callback and it works perfectly now. Also nested the animations a bit to give it a good sequence. Very nice effect. Heres what I ended up with: $(".del a").bind("click",delClick); function delClick() { var batch = $(this).attr( 'href' ); $("#confirmdel").html('Are you sure you want to delete batch ' + batch + '? <a href="#" id="confirmdelete">Yes</a> <a href="#" id="cancel">Cancel</a>'); $("#confirmdel").show('slow', function(){ $("#confirmdelete").click(function(){ $.post('../scripts/deletebatch.php', {batchid: batch}); $("#confirmdel").hide('fast', function(){ $('#batches').fadeOut('fast', function(){ $('#batches').load('index.php #batches',false,function(){ $('#batches').fadeIn('slow'); $(".del a").bind("click",delClick); }); }); }); return false; }); }); return false; } All the best.
  4. I guess one way would be to start building up a record in the DB when the setexpresscheckout is called and save the amount in there but I was hoping to avoid having to create temp records and only save the information once the transaction was complete?
  5. Hi David, Thanks for the pointers. As you have suggested I changed from an id selector to a class selector so the HTML is now: <td class="del"><a href... and the Jquery is : $(".del a").bind("... The second point you made makes sense but even though new elements are being created, they still have the same names . Anyhow, more than happy to give it a go but im not really sure how to go about binding the new elements after the load? would it just be to copy the same section of jquery code into the callback of the load? The issue there being I would have to embed infinate copies of the code because different users would delete different numbers of items at a time?
  6. Hi all, I am looking to integrate Paypal Express checkout on my site and have been working with the API today. I have got the code working in a static state with predefined payment amounts but I am having trouble making this dynamic. When you first submit a request to set up an express checkout you send the payment amount along with it. The paypal server then makes the checkout and the user is redirected to the paypal site to login and authenticate. From here they click to be redirected back to my site where I have a pay button which when clicked submits the final request to confirm the payment. I am sure there must be a simple solution to this because so many people use paypal already but when you submit the final confirmation request, you have to send the payment amount again, but because the page redirects onto the paypal page inbetween, I can't use a session variable to store the amount. How have other people overcome this? Thanks
  7. Hi So I have a mysql database which contains information on a number of items (we'll call them batches). each user can add multiple batches to the database. On the user's account page, a query looks up all the batches they have submitted and lists them. Today I have been working on a way that the user can delete their batches one at a time from the list without having to refresh the page and I am 90% there, just one little niggle which I cant work out. The way I have done it is where the php loops through the result of the query and lists the batches, it also places an image which looks like this in html: <td id="del"><a href="42"><img src="../images/delete.gif"/></a></td> where 42 is the id for the batch in the db. To pick up when the user clicks the delete image next to a batch I have used the following jquery: <script type="text/javascript"> $(document).ready(function(){ $("#del a").bind("click", function() { var batch = $(this).attr( 'href' ); $("#confirmdel").html('Are you sure you want to delete batch ' + batch + '? <a href="#" id="confirmdelete">Yes</a> <a href="#" id="cancel">Cancel</a>'); $("#confirmdel").show('slow', function(){ $("#confirmdelete").click(function(){ $.post('../scripts/deletebatch.php', {batchid: batch}); $("#confirmdel").hide('slow'); $('#batches').fadeOut('fast'); $('#batches').load('index.php #batches',false,function(){ $('#batches').fadeIn('slow'); }); return false; }); }); return false; }); }); </script> deletebatch.php is just a small php script which takes in the batch id and inactivates it in the db. confirmdel is an empty div on the page which will be used to confirm the delete or cancel it. Now this all works great and once the user confirms the delete, the confirmdel div will fade out, then the list of batches will fade out, the row will be inactivated in the db and the list will fade back in having reloaded and being one item less. But the problem is if the user then clicks on a delete icon next to a batch on the refreshed list, none of the jquery fires and it treats the <a href="42"... as a hyperlink and tries to go to that page. Firstly thought it may have something to do with the fact its within the $(document).ready(function(){} section so I tried to copy the same block of code outside of that but still no luck. Would really appreciate some help with this last bit. Cheers
  8. I am designing a web site which will dynamically generate labels which will be printed out by the end user. I have coded the part which generates each label into an image, but sometimes a user will want to print multiple copies of the same label on a page. I am working on the basis of an A4 page initially and depending on the design of the label, they will be different sizes (but they wont be mixing different designs on a single page so for each a4 sheet, every label will be the same size). I have no idea how to go about the dynamic arranging of images onto the page without them being half chopped off. Ideally they will just be arranged onto a HTML page which I can just add a print button to. Any suggestions are most welcome
  9. Thanks for your post nafetski its application/msword though are there any benefits of parsing from the filename rather than using the file type? also, how would I go about clipping the extension from the filename as some extensions are 4 characters and some are 3?
  10. ok figured this one out by uploading the files and then using zip.lib.php to zip the individual files on the server side, name it how i want and then unlink the individual files. Can someone help with the filetype validation though... foreach ($_FILES as $_key => $_value) { if ($_FILES[$_key]['size'] < 2000000 && ($_FILES[$_key]['type'] == "application/pdf")) { print_r($_FILES[$_key]); move_uploaded_file($_FILES["$_key"]["tmp_name"], "c:/wamp/www/attachments/" . $_FILES["$_key"]["name"]); echo "Stored in: " . "upload/" . $_FILES["$_key"]["name"]; } else { echo $_FILES[$_key]['name'] . ' is invalid'; } } So $_FILES[$_key]['type'] == "application/pdf" will let pdf files be uploaded, but what is the equivelent for word documents (.doc not .docx)? tried $_FILES[$_key]['type'] == "application/doc" but unfortunately life isnt that simple Thanks
  11. If it was for me that would be fine, but i'm building a system for non technical users and would like to make it as easy for them as possible. It is also useful for me if the function can rename the zip file to keep a consitent naming convention without having to have another database table to relate the zip file to a particular record.
  12. Does anyone know of any functions which allow you to upload multiple files to a webserver and saves them there as a ZIP archive automatically? Thanks
  13. Out of interest, why does the space not make a difference when developing locally but has an impact online?
  14. You probably have some white-space on that line after the ?> tag. AMAZING... Thank You!! Really would not have thought about that... all that aggravation for a space!
  15. Hi all So ive been designing implementing my php website for the past few months locally using WAMP stack, and coding with php designer. All was fine, and the site worked perfectly with a mysql database. I then uploaded it to my webserver with support for php and mysql, built the tables as required, and the site does work, but I am gettin this error on some pages.: Warning: Cannot modify header information - headers already sent by (output started at /home/sites/findaplacement.com/public_html/list.inc.php:57) in /home/sites/findaplacement.com/public_html/update_customer_admin.php on line 90 This occurs on pages where i used validation to check the input of forms, then submit the details to the database to be stored. I have an IF loop that says if everything is OK, then update the record in the database, and then using header('Refresh: 5; URL=account.php'); on line 90 of the page update_customer_admin.php send the user to their account home page. I have made sure that the header is the first output the page gives, and the file it is showing as the problem (list.inc.php) is a simple include file which contains the definition of a few arrays, nothing else. And line 57 dosent event have any code on it, its just the php closing tag '?>' I find it strange because it works perfectly locally. Anyone have any idea what might be different on my webserver which might cause this?? Thanks
  16. Thanks for that but I think ive found an easier way of making up the search query string: $query = "SELECT * FROM advert WHERE location LIKE '%" . join("%' OR location LIKE '%", $loc) . "%'";
  17. Hopefully this will be an easy one for someone... I have... array called $loc a MySQL table called advert a Field within the table called location Im trying to... Search for records which contain any of the values in the array in the location field. So far ive got a query which will find a record if there is just one value in the field. But if the field contains more than 1 value, it dosen't find the record even if that field contains one of the values in the search array. Values in the Location field are storred separated by commas, so my guess is I need to add something to the search query to account for the spaces and and commas? $query = "SELECT * FROM advert WHERE location IN('".join("','", $loc)."')"; any help appreciated!
  18. Guys, ive progressed a little here, but would really like a bit of help to finish it off As explained, I have a table of courses with 5 attributes for each (called attribute_1, attribute_2, attribute_3 etc...) On the search page, the user will select a value of 1-5 from drop down menus which will then be sent to the results page via $_POST. When I pick the $_POST values up, at the top of the results page I want to show all the courses that match the search criteria EXACTLY, which is quite simple... I just concatenated the $_POST values directly into the SQL query. Then below this I am looking to post SIMILAR matches, so I have written a query which looks for each attribute +/- 1. But to get this to work, I had to also include the original criteria because if someone selects criteria with say 1 for the first attribute and 2 for the second, and in the DB there is a course which has 1 for the first and 3 for the second, it wont come up unless it is searching for 1 in the first attribute also. This means when there is an exact match, it shows up in both the top exact match section (where it should) and also the similar match section (dont want it here) Is there any way to exclude the exact match combination from the similar match query? Sorry for the long and confusing explanation. Below are my queries: EXACT Match: select * FROM advert, attributes WHERE attributes.attribute_1 = ' . $_POST['searchatt1'] . ' AND attributes.attribute_2 = ' . $_POST['searchatt2'] . ' AND attributes.attribute_3 = ' . $_POST['searchatt3'] . ' AND attributes.attribute_4 = ' . $_POST['searchatt4'] . ' AND attributes.attribute_5 = ' . $_POST['searchatt5'] . ' AND advert.advert_id = attributes.advert_id ORDER BY role_title'; SIMILAR match: select * FROM advert, attributes WHERE (attributes.attribute_1 = ' . (($_POST['searchatt1'])+1) . ' OR attributes.attribute_1 = ' . $_POST['searchatt1'] . ' OR attributes.attribute_1 = ' . (($_POST['searchatt1'])-1) . ') AND (attributes.attribute_2 = ' . (($_POST['searchatt2'])+1) . ' OR attributes.attribute_2 = ' . $_POST['searchatt2'] . ' OR attributes.attribute_2 = ' . (($_POST['searchatt2'])-1) . ') AND (attributes.attribute_3 = ' . (($_POST['searchatt3'])+1) . ' OR attributes.attribute_3 = ' . $_POST['searchatt3'] . ' OR attributes.attribute_3 = ' . (($_POST['searchatt3'])-1) . ') AND (attributes.attribute_4 = ' . (($_POST['searchatt4'])+1) . ' OR attributes.attribute_4 = ' . $_POST['searchatt4'] . ' OR attributes.attribute_4 = ' . (($_POST['searchatt4'])-1) . ') AND (attributes.attribute_5 = ' . (($_POST['searchatt5'])+1) . ' OR attributes.attribute_5 = ' . $_POST['searchatt5'] . ' OR attributes.attribute_5 = ' . (($_POST['searchatt5'])-1) . ') AND advert.advert_id = attributes.advert_id ORDER BY role_title';
  19. If 5 is the best rating, and 1 the worst then you could apply an algorithm. Weight the importance of each attribute. $totalRating = $firstAttributeRating * $firstWeight + $secondAttributeRating * $secondWeight....etc. If you give a concrete example then it might be easier to help you. Thanks for your reply. Basically it is a website to compare and search for computing degree courses so a record would be a particular course, which would have 5 attributes an attribute would be for example how much programming, or maths, or analysis would be involved, and this would be rated from 1 to 5 where 1 would be none of the attribute would be included in the course, and 5 would be a lot. At the moment ive implemented a simple search via a database query, so the user select he wants a course with a lot of programming, no analysis etc, and it will return exact matches But I also want to add a way of recommending similar courses to the person, so for the user above I would like to recommend a course with very little programming but still no analysis.
  20. Hey Guys I am currently working on a project where people use a php based website to post adverts. Each advert has 5 attributes assocated with it that describe it, and each attribute has a scale of 1-5 so for eg. advert 1 will be rated 1 for attribute 1, 3 for attribute 2 and so on I have implemented a simple search for exact matches of the attributes, but am now looking for a simple way of finding similar results based on the attributes where there is just 1 value off in a couple of the attributes for example. Anybody have any ideas of how to do this in a simple way? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.