Quick Tip – Jquery edit-in-place with MySQL

Ok, I wanted to share a trick I came up with yesterday working on a project. What I needed was to create a table from a MySQL result, and be able to edit all the fields in the table. I decided to use JQUERY and AJAX to accomplish this.

I decided on JQUERY and AJAX for a few reasons. I didn’t want the user to have to leave or reload the page each time a value was changed. And, speed was important too and I find AJAX is a great way to boost your load times as most of the work is done in the background.

So what does it do? Well it creates a text element that changes to an HTML input on click. After the value is changed it is sent via AJAX to another page that inserts the new data into MySQL.

What you need, You will need the following JavaScript files (Note: You only need jquery.js if you are not currently using any JQUERY on your page.)

Once you download these call them in the HEAD section of your page.

<head>
<script type=”text/javascript” src=”../js/jquery.editinplace.packed.js”></script>
<script type=”text/javascript” src=”../js/edit.js”></script>
<script type=”text/javascript” src=”../js/jquery.js”></script></head>

After this all you need to do is give an element the name “editme1″ like so

<span class=”editme1″ id=”links-title-1′”>This can be changed</span>

Now what I have done is set it up in PHP to separate the id by “-” and get the table name from the first value, the column from the second and the row id in the third like so

id=”table-column-id”

This allows you to reuse this script anywhere and simply change the ID to allow it update any MySQL field.

Here is the php that handles the request. (edit_in_place_server.php)

<?
include(‘../connect.inc’);

$update_value = $_POST['update_value'];
$element_id = $_POST['element_id'];
$original = $_POST['original_html'];

$element = explode(“-”, $element_id);

$table = $element['0'];
$col = $element['1'];
$row_id = $element['2'];

$sql = “UPDATE “.$table.” SET “.$col.”=’”.$update_value.”‘ WHERE id=’”.$row_id.”‘”;
$result = mysql_query($sql) or die(mysql_error());

if($result){ echo $update_value; }

The script echos the new value and it is returned to the page to replace the old value.

Feel free to use this code anywhere you can, I hope it helps.

Posted in Web Development

The best ways to get traffic to your website.

There are a ton of ways to get visitors to your new website. Unfortunately the only constant in SEO is change. Google changes its algorithms constantly so keeping up can be a pain in the ass. However there are a few tried and true methods that will always work to get new visors and more backlinks to your site. There are many creative advertising techniques I want to talk about free traffic today though. I found these to be the best long term and short term ways to not only get free traffic but get quality backlinks.

 

  1. Content, Content, Content Everyone knows content is king and as far as SEO goes this has never been more true. Not only does quality content give users a reason to stay, it gives them a reason to tell there friends to come to your site.
  2. Forum Posting There are forums for almost every industry and market and what better way to find new customers then to go them. When posting on forums be sure to contribute relative useful content and include your link in your signature. Be sure to read the forums terms of service before posting links in your signature many forums do not allow this.
  3. Blog Posting Just like forum posting contributing to relevant blogs is a great way to get more traffic. It is especially important to read the blog post and contribute useful relevant content to avoid looking like spam.
  4. Facebook Facebook links will not help your SEO efforts all of these links are no-follow and will not be indexed by search engines. However Facebook can be a great way to get relevant traffic to your site. It can also be a great way of starting a conversation about your new product or website.
  5. Twitter Building a twitter following is another great way of starting a conversation about your website as well as finding other related sites.
  6. Articles Article marketing is one of the most effective ways of building links and getting quality traffic to your site. Writing articles with useful information and submitting them to sites like ezinearticles has many benefits. First of all Google crawls these sites constantly and your content will get picked up very fast. Secondly these articles will often list very high on Google for searches so it’s a quick way to get free traffic.
  7. Meta Tags While setting up meta tags will not have the same effect on SEO it did years ago many search engines including Google still use meta tags.
  8. Link exchanges Exchanging links with other sites is a good idea as long as you are exchanging links with sites that are relevant to yours.
  9. Directories I have found that directories can either bring you great highly related visitors or do nothing at all. If you can find directories that are popular and related to your niche you can get a flood of great traffic. Directories like dmoz.org and the yahoo directory can be great for link building. Don’t waste your money on the directories that let in everything and have nothing to do with your site paid or free.
  10. YouTube YouTube is actually the second most popular search engine behind Google so it’s not a bad idea if you can to make some videos that showcase the benefits of your site. It’s best to just give away free information then link back to your site. People on YouTube don’t want a commercial.
  11. RSS Feeds If you have a blog setting up an RSS feed is essential. A lot of people subscribe to these and come back for every post.
  12. Social Bookmarking These sites can be good for getting listed in search engines but they don’t lead to real visitors very often.
  13. Press Releases Only use press releases if what your saying is actually press worthy. News sites will pick up on good stories though.
  14. Yellow Pages Listing your business on yellow pages will bring in a lot of local clients as well as give your business a much more reputable appearance.
  15. Google local business listings If you have a physical address this is a great way for customers to find you and your website.
  16. BBB While I have a personal problem with the BBB .(I find them to be a scam) You can list your business with the BBB to improve reputation.
  17. Affiliate Programs An affiliate program is when other people send visitors to you and you pay them a percentage of whatever the visitor buys.
  18. Craigslist Great for advertising your products and services. Time consuming if you are not actually serving a local area though.
  19. Yahoo Answers While it’s up for debate whether Google counts these links you can build backlinks by answering questions on yahoo. When your answers are good you can link to your website as a reference for your answer.
  20. Google groups Start a Google group or join one about your market.
  21. Wikipedia Once you become more popular you can create a Wikipedia entry about your site. This is only for sites with a reputation already.
  22. Squidoo Try creating a Squidoo lens for site these make good backlinks as well as give you a reputation as an expert on your topic.
  23. Digg This is another great way for your site to get found. If it lands on the front page you can expect a lot of traffic as well.
  24. Product Reviews When you have a blog a great way to get new visitors is by reviewing other products and services. People are always looking for reviews of products before they buy them. You can even find out if the product has an affiliate program and try joining it for revenue from your review.
  25. Amazon Create a list on Amazon, people will often find these.
  26. Start a Blog If you don’t already have a blog on your site its a good idea to set one up and post often. Just be sure your posts are well thought out and informative. Give people a reason to come back.
  27. Technorati If you have a blog list it on Technorati you can find new readers and subscribers with it.
  28. Rent Links You can rent links on related websites to get visitors and backlinks. This may not be a good idea for low budget sites though.
  29. Email Lists Email lists are a great way to keep your customers updated on new products you have. Email lists can be rented but I recommend sticking with past clients.
  30. Hold a Contest Have a contest this will bring in a lot of new visitors.
  31. Free Stuff People love free stuff, its a great way to get new leads. Offering a free and paid version of your product can work as well.
  32. Industry Conferences Do a search on industry events and conferences in your area this is a great way to network with possible future clients. Be sure to bring plenty of business cards with your website link on them.
  33. Interview experts Interview an expert and put it on your website this is great way to build authority.

What Not to do! There are even more ways to screw it up! These are often met with penalties in search engines.

  1. Spam Forums Posting unrelated and uninformative posts on forums will often get you banned it is always frowned upon. Try to be helpful on forums and you will gain peoples trust much better.
  2. Spam Blogs Don’t spam blogs there usually just deleted.
  3. Email spam Never spam people by email not only will they not want to buy your product but it will completely devalue your reputation.

In conclusion, focus on your content, when you are selling a product that people want they will find you. Just be sure to make yourself well known in your market and provide good content.

Posted in Internet Marketing
LiveZilla Live Help