#localhost wordpress
Explore tagged Tumblr posts
Text
How to Move Your WordPress Site from Localhost to a Live Server
Developing a WordPress site on localhost is a great way to build and test your website in a controlled environment. However, the real challenge arises when it's time to move the site from your local server to a live hosting environment. If not done correctly, you could encounter broken links, missing images, or even database errors.
In this blog, we'll guide you through a step-by-step process to successfully move your WordPress site from localhost to a live server.

Step 1: Choose the Right Hosting Provider
Your first step is to select a reliable web hosting provider that meets your website’s needs. Look for:
Server Speed: Fast servers for better performance.
Uptime Guarantee: At least 99.9% uptime to ensure availability.
Ease of Use: User-friendly dashboards and tools.
WordPress Support: Hosting optimized for WordPress websites.
Popular options include Bluehost, SiteGround, and WP Engine.
Step 2: Export Your Local WordPress Database
The database is the backbone of your WordPress site. To export it:
Open phpMyAdmin on your local server (e.g., XAMPP or WAMP).
Select your WordPress database.
Click on the Export tab and choose the Quick Export method.
Save the .sql file to your computer.
Step 3: Upload Your WordPress Files to the Live Server
To move your files:
Compress Your WordPress Folder: Zip your local WordPress installation folder.
Access Your Hosting Account: Use a file manager or an FTP client like FileZilla.
Upload the Files: Transfer the zipped folder to your hosting server's root directory (usually public_html).
Unzip the Folder: Extract the files once uploaded.
Step 4: Create a Database on the Live Server
Now, set up a new database on your live hosting server:
Log in to your hosting control panel (e.g., cPanel).
Navigate to the MySQL Databases section.
Create a new database, database user, and password.
Assign the user to the database with full privileges.
Step 5: Import the Database to the Live Server
Open phpMyAdmin in your hosting control panel.
Select the new database you created.
Click the Import tab.
Choose the .sql file you exported from your localhost.
Click Go to import the database.
Step 6: Update the wp-config.php File
To connect your site to the live database:
Locate the wp-config.php file in your WordPress installation.
Open the file in a text editor.
Update the following lines: define('DB_NAME', 'your_live_database_name'); define('DB_USER', 'your_live_database_user'); define('DB_PASSWORD', 'your_live_database_password'); define('DB_HOST', 'localhost'); // Keep this unless your host specifies otherwise.
Save the file and upload it to your server via FTP.
Step 7: Update URLs in the Database
Your localhost URLs need to be replaced with your live site URLs.
Use a tool like Search Replace DB or run SQL queries in phpMyAdmin.
In phpMyAdmin, run the following query: UPDATE wp_options SET option_value = 'http://your-live-site.com' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://your-live-site.com' WHERE option_name = 'home';
Step 8: Test Your Live Website
Once everything is uploaded and configured, check your website by entering its URL in a browser. Test for:
Broken Links: Fix them using plugins like Broken Link Checker.
Missing Images: Ensure media files were uploaded correctly.
Functionality: Verify forms, buttons, and features work as expected.
Step 9: Set Up Permalinks
To ensure proper URL structure:
Log in to your WordPress admin dashboard on the live site.
Go to Settings > Permalinks.
Choose your preferred permalink structure and click Save Changes.
Step 10: Secure Your Live Website
After migrating, secure your site to prevent vulnerabilities:
Install an SSL Certificate: Most hosting providers offer free SSL certificates.
Update Plugins and Themes: Ensure everything is up to date.
Set Up Backups: Use plugins like UpdraftPlus for regular backups.
Conclusion
Moving your WordPress site from localhost to a live server may seem daunting, but by following these steps, you can ensure a smooth and error-free migration. A successful move allows you to showcase your site to the world, engage your audience, and achieve your goals.
Start today and take your WordPress project live with confidence!
0 notes
Video
youtube
The ABSOLUTE BEST Way to Install WordPress on XAMPP in 8 Minutes
🎥📢 Want to set up WordPress on your own computer? Then this video is for you! 💻🔥
In this tutorial, I’ve shown how to easily install WordPress on localhost using XAMPP. Start practicing web development from the comfort of your home! 🚀
👇 Watch the video now and don’t forget to share!
1 note
·
View note
Text
How to Install WordPress Locally on Your MacBook (Easy Guide)
🚀 Exciting news for all you WordPress developers and enthusiasts! 🎉 Just published a new blog post on how to easily install WordPress locally on your MacBook! 💻 Perfect for testing themes, plugins, and building websites offline. No more messing with live servers! 🙌 This step-by-step guide walks you through the entire process, making it super simple even for beginners. Whether you're using MAMP, XAMPP, or another local development environment, this tutorial has you covered. 🤓 Check it out now and start building your WordPress projects locally! 👇 #WordPress #LocalDevelopment #MacBook #Installation #Tutorial #WebDev #MAMP #XAMPP #Localhost #PHP #MySQL #WordPressTutorial #WebDevelopment #Coding #Tech #BlogPost #NewBlog #LearnToCode #RTFM #100DaysOfRTFM #Innovation #Technology #Creativity #LocalWP #SoftwareDevelopment #DigitalStrategy #DigitalMarketing
So, you’re ready to dive into the world of WordPress development, but you don’t want to mess with a live server just yet? Great idea! Setting up WordPress locally on your MacBook is the perfect way to experiment, test themes and plugins, and build your website in a safe environment. This guide will walk you through the process step-by-step. Why Install WordPress Locally? Before we jump in, let’s…
#Installation#Local Development#Localhost#MacBook#MAMP#MySQL#PHP#Tutorial#Web Development#WordPress#XAMPP
0 notes
Video
youtube
Apprenez à Installer WordPress sur WampServer en 5 Étapes Simples
1 note
·
View note
Text
How To Install WordPress On Localhost Right Now
View On WordPress
#article#blog#blogging#development#howto#instruction#instructions#localhost#wamp#wampserver#web#webdev#webdevelopment#website#wordpress
0 notes
Text
How to Delete Wordpress Site
Deleting a WordPress site should be done with caution, as it permanently removes all of your site's content, settings, and data. Make sure you have a backup of any data you want to keep before proceeding. Here's a step-by-step guide on how to delete a WordPress site:
Before you begin:
Backup your site: Use a WordPress backup plugin or your hosting provider's backup feature to create a backup of your site's content and database. This is crucial in case you change your mind or need to restore your site later.
Export Content: If you want to save any posts, pages, or other content, export it using the WordPress export tool. This will create an XML file you can import into another WordPress site if needed.

#how to delete wordpress site#how to delete wordpress site and start over#how to delete wordpress site hostinger#how to delete wordpress site from cpanel#how to delete wordpress site 2022#how to delete wordpress site from localhost#how to delete wordpress site godaddy#how to delete wordpress site 2023#how to delete your wordpress site and start again#how to delete a wordpress site on bluehost
1 note
·
View note
Text
ローカルでwordpressのインポート容量を増やす
.htaccessに下記を追記して任意の数値に変更
php_value upload_max_filesize 85280M php_value post_max_size 90128M php_value memory_limit 256M php_value max_execution_time 800 php_value max_input_time 800
0 notes
Text
Learn how to set up local testing environments for WordPress development and streamline your workflow.
0 notes
Text
Choose the Right Web Hosting
Thinking of switching web hosting providers but worried about losing your website or breaking something important? You're not alone. Many website owners hesitate to make the move because they’re unsure about how the process works. But the truth is, with the right steps, you can move your website to a new host safely and easily — even as a beginner.
In this guide, we’ll walk you through a simple and safe way to transfer your website, while also helping you choose the right web hosting for long-term success. If you ever need quick assistance, feel free to call +91 9818 62 9898.
Why People Change Web Hosting Providers
Before we dive into the steps, let’s understand why someone might need to move their website:
Slow website performance
Frequent downtime or server issues
Poor customer support
Limited features or outdated technology
High renewal costs
If any of these issues sound familiar, it’s a clear sign that you need to move on and choose the right web hosting provider. For expert help during the switch, call us directly at +91 9818 62 9898.
Pre-Move Checklist: What You Need to Prepare
To ensure a smooth transfer, gather the following:
Access to your current hosting account
Access to your domain registrar
A backup of your website files and database
Login credentials for your new hosting provider
Some time (ideally during non-peak hours)
If you get stuck at any point, just dial +91 9818 62 9898 — our team is here to help.
Step-by-Step Guide to Move Your Website Safely
Step 1: Choose the Right Web Hosting Provider
The first and most important step is to choose the right web hosting for your current and future website needs. Look for:
99.9% uptime guarantee
High server speed
Free migration services
24/7 support
User-friendly dashboard
Not sure which provider is right for you? Get a quick recommendation by calling +91 9818 62 9898.
Step 2: Backup Your Website Files and Database
Always create a full backup before migrating.
For WordPress: Use plugins like All-in-One WP Migration or Duplicator to back up both files and database.
For non-WordPress sites: Download your files via FTP and export your database using phpMyAdmin.
Need help taking a backup? Reach out at +91 9818 62 9898.
Step 3: Upload Files to the New Host
Once your new host is ready, it’s time to upload:
WordPress Users:
Install WordPress on the new host
Import the backup using your chosen plugin
Non-WordPress Sites:
Upload via FTP
Recreate the database and import your .sql file
For technical support, don’t hesitate to call +91 9818 62 9898.
Step 4: Update Database Settings
If your website is database-driven (like WordPress), update the config file with new database credentials.
For WordPress, modify wp-config.php with:
sql
CopyEdit
define('DB_NAME', 'new_db_name'); define('DB_USER', 'new_db_user'); define('DB_PASSWORD', 'new_db_password'); define('DB_HOST', 'localhost');
Not sure where to find these details? We’re one call away at +91 9818 62 9898.
Step 5: Preview the Website on New Host
Before changing your domain settings, preview your site using:
A temporary URL (provided by your new host)
Hosts file modification (advanced users)
Ensure everything works — images load, forms submit, pages function properly. If you see issues, give us a call at +91 9818 62 9898 for quick troubleshooting.
Step 6: Change Domain DNS Settings
Now it’s time to go live.
Log in to your domain registrar
Update the DNS (nameservers) to your new host’s settings
Wait for DNS propagation (can take 24–48 hours)
During this period, avoid editing the website. If you're unsure how to do this, call +91 9818 62 9898 and we’ll walk you through it.
Step 7: Test After DNS Propagation
After DNS has updated, test your site:
Load pages
Test forms
Check mobile responsiveness
Verify email services (if connected to domain)
Pro Tips for a Smooth Migration
Migrate during low-traffic hours
Inform your visitors if there will be downtime
Keep your old host active for at least a week
Clear browser and site cache after the move
Always double-check backups
Need guidance through any of these steps? Talk to our web experts at +91 9818 62 9898.
Final Thoughts
Switching your hosting might feel scary, but it’s easier than it looks — especially when you follow the right steps. The key is to be prepared, follow a structured process, and above all, choose the right web hosting that meets your performance and support expectations.
Whether you're unhappy with your current provider or just want to upgrade, now is the perfect time to make the move. And if you ever feel stuck, don’t worry — just call +91 9818 62 9898, and we’ll guide you every step of the way.
Want expert help with your hosting migration? Call us now at +91 9818 62 9898 and get started without stress.
0 notes
Text
WordPress ›Error
Warning: mysqli_real_connect (): (Hy000/2002): NO SUCH File or Directory in /home/queenmobi/domains/queenmobile.vn/public_html/wp-includes/class-wpdb.php on line 1982 WordPress ›Error No such file or directory This either mean the username and password information in your wp-config.php File is incorrect or contact with the database server at localhost Could not be esterned. This Could Mean Your…
0 notes
Text
Backing Up Your Localhost WordPress Site: Methods and Tools
Creating backups of your localhost WordPress site is an essential practice for safeguarding your work and ensuring you can recover from unexpected errors or data loss. Whether you are testing themes, developing plugins, or building a new website, a reliable backup process can save you time and stress. This blog outlines effective methods and tools to back up your localhost WordPress site.

Why Backup Your Localhost WordPress Site?
Prevent Data Loss
Unintentional file deletions, database errors, or hardware failures can result in losing hours of work.
Streamline Testing
Backups enable you to revert to a previous state if something breaks during theme or plugin testing.
Ease Migration
Backing up your localhost site simplifies the process of moving it to a live server or another environment.
Experiment Freely
Knowing you have a backup allows you to experiment with code or settings without fear of permanent damage.
Components to Back Up
A WordPress site consists of two primary components:
WordPress Files
These include core files, theme files, plugin files, and uploaded media stored in the wp-content folder.
Database
The database stores your website’s content, settings, and user data. It is usually managed through tools like phpMyAdmin or MySQL Workbench.
Methods for Backing Up Localhost WordPress Sites
1. Manual Backup
Steps:
Copy WordPress Files
Navigate to the directory where your WordPress installation resides (e.g., htdocs in XAMPP).
Copy all files and folders to a secure location, such as an external hard drive or cloud storage.
Export the Database
Access phpMyAdmin or your database management tool.
Select your WordPress database and click on the "Export" option.
Choose the "Quick" export method and save the .sql file.
Advantages:
Complete control over the backup process.
No additional tools required.
Disadvantages:
Time-consuming and prone to human error.
2. Using Plugins
Many WordPress backup plugins work seamlessly on localhost installations. Here are some popular choices:
UpdraftPlus
Schedule and automate backups for both files and databases.
Store backups locally or on cloud platforms like Google Drive, Dropbox, or OneDrive.
Duplicator
Create complete site backups, including files and databases.
Ideal for migrating your localhost site to a live server.
All-in-One WP Migration
Export your site’s files and database into a single file.
Easily import backups to restore your site.
Steps to Use a Plugin:
Install the chosen plugin on your localhost WordPress site.
Follow the plugin’s setup instructions to create and save backups.
Store the backups in a secure location.
Advantages:
Automated and user-friendly.
Additional features like scheduling and cloud integration.
Disadvantages:
Some advanced features may require a premium version.
3. Using Command Line Tools
If you are comfortable with the command line, tools like WP-CLI can streamline the backup process.
Steps:
Backup Files
Use commands to compress your WordPress directory into a zip file:zip -r backup.zip /path/to/wordpress
Backup Database
Export your database using WP-CLI:wp db export backup.sql
Advantages:
Fast and efficient for advanced users.
Scriptable for regular backups.
Disadvantages:
Requires familiarity with the command line.
4. Using Localhost Management Tools
Tools like Local by Flywheel and DevKinsta come with built-in backup options, making the process simpler.
Steps:
Locate the backup feature in your chosen tool.
Follow the instructions to create and store a backup.
Restore the backup if needed.
Advantages:
Integrated with the localhost environment.
Minimal setup required.
Disadvantages:
Limited to specific tools.
Best Practices for Backing Up Localhost WordPress Sites
Schedule Regular Backups
Set a schedule to ensure backups are created consistently.
Use Multiple Storage Locations
Keep backups in at least two locations, such as an external drive and cloud storage.
Test Your Backups
Regularly restore backups to verify their integrity and functionality.
Document Your Process
Maintain a clear record of your backup and restoration steps for future reference.
Secure Your Backups
Encrypt sensitive backups and limit access to authorized users.
Conclusion
Backing up your localhost WordPress site is a vital step in ensuring the safety and continuity of your work. Whether you choose manual methods, plugins, or advanced tools, the key is consistency and reliability. By implementing these best practices, you can safeguard your projects and work with confidence, knowing that you’re prepared for any challenges that come your way.
0 notes
Text
Use GPhoto2Server camera preview in OBS
One can use GPhoto2Server to capture video feed from digital cameras as an input in OBS In order to do so, run GPhoto2Server, and in OBS studio add “Media Source” with this configuration: Disable “local file” checkbox Set “Input” to be http://localhost:8080/stream.mjpeg Optionally set Network Buffering to 0 and reconnect delay to 1S Continue reading Use GPhoto2Server camera preview in OBS
View On WordPress
1 note
·
View note
Text
How to Install XAMPP for Windows 10 - XAMPP WordPress For Beginners
To install XAMPP on Windows 10 and set it up for WordPress, follow these steps:
Step 1: Download XAMPP
Go to the official XAMPP website.
Click on the "XAMPP for Windows" button.
Once the installer is downloaded, locate the .exe file (usually in the Downloads folder).
Step 2: Install XAMPP
Double-click the .exe file to start the installation process.
Choose the components you want to install. For WordPress, you need at least Apache, MySQL, and PHP. These are selected by default, so you can leave them as is.
Choose the installation folder (default is usually fine).
Click "Next" and follow the prompts.
During installation, the installer may ask if you want to start the XAMPP Control Panel. Leave it checked and click "Finish."
Step 3: Start Apache and MySQL
Open the XAMPP Control Panel (it should have opened automatically, or you can search for it in the Start menu).
Click the "Start" button next to Apache (this will run the web server).
Click the "Start" button next to MySQL (this will start the database server).
Make sure both Apache and MySQL show "Running" in green.
Step 4: Install WordPress
Download the latest version of WordPress from the official WordPress website.
Extract the WordPress ZIP file.
Move the extracted folder (the WordPress folder) into the htdocs folder of your XAMPP installation (usually located at C:\xampp\htdocs).
Step 5: Create a Database for WordPress
Open your browser and go to http://localhost/phpmyadmin/.
In the phpMyAdmin dashboard, click on "Databases."
Create a new database for WordPress. Give it a name (e.g., wordpress_db) and click "Create."
Step 6: Configure WordPress
Open your browser and go to http://localhost/wordpress (or the folder name you chose).
The WordPress installation screen should appear.
Select your language and click "Continue."
On the next screen, enter your database details:
Database Name: The name you created (e.g., wordpress_db).
Username: root (default for XAMPP).
Password: Leave this blank (default for XAMPP).
Database Host: localhost (default).
Table Prefix: Leave as wp_ unless you want to change it.
Click Submit and then Run the Install.
Step 7: Complete the WordPress Setup
Fill in the site details (site title, admin username, password, and email).
Click "Install WordPress."
Once the installation is complete, you’ll see a success message. You can now log in to your WordPress dashboard at http://localhost/wordpress/wp-admin.
Final Notes
To stop your server, go to the XAMPP Control Panel and click "Stop" for Apache and MySQL.
If you need to make your local WordPress site public, you'll have to configure port forwarding or use a tool like Local by Flywheel or XAMPP for public access.
#installxampp#xamppforbeginners#xamppwindows10#wordpressinstallation#localserversetup#runwordpresslocally#xamppwordpress#webdevelopment#phpdevelopment#wordpressforbeginners#tutorial2025#localwordpress#xamppsetup#installingwordpress#wordpresssetup#beginnerfriendly#xamppguide#developmenttutorial#learnwordpress#wordpresslocally
0 notes
Text
How Can I Create a Website Without a Domain Name? Here’s How!
Creating a website without a domain name is possible and can be ideal for testing or personal projects. This guide explains how to build a website without buying a domain while keeping it functional and visible on the web.
Why Create a Website Without a Domain Name?
Many people choose to skip a custom domain when
1.Use a Website Builder’s Free Subdomain
Platforms like Wix, WordPress, and Weebly offer free website creation with their subdomains. For instance, instead of “yourwebsite.com,” it might look like “yourwebsite.wixsite.com.”
Advantages:
- No need for hosting, as most builders provide free hosting for subdomains.
- Fast and easy to set up.
- Free or low-cost setup.
Disadvantages:
-Limited customization and branding.
Less professional-looking URL.
2.Utilize GitHub Pages for Coding Projects
For developers or those with coding knowledge, GitHub Pages provides a free hosting solution where your site can be accessible at "username.github.io/project."
Advantages:
-Ideal for static sites, personal projects, or portfolios.
Free SSL (secure connection).
Disadvantages:
- Requires basic coding knowledge.
- Limited to HTML, CSS, and JavaScript.
3.Free Hosting Providers with Temporary URLs
Some hosting providers like InfinityFree and 000WebHost offer free plans with temporary URLs. These temporary URLs allow you to create, test, and host sites without a purchased domain.
Advantages:
- Cost-free hosting options.
- Access to control panels for site management.
- Option to add a custom domain later.
Disadvantages:
- Advertising may be displayed.
- Limited support and resources.
4.Use a Localhost Environment for Offline Testing
For complete control over site functionality, set up a local server using software like XAMPP or Local by Flywheel to run your website offline. While this won’t make your site publicly accessible, it’s perfect for building and testing.
Advantages:
- Full control over testing without online exposure.
- No internet required for access.
- Great for testing advanced functionalities.
Disadvantages:
- Requires technical setup.
- Not accessible over the web.
Key Considerations for Websites Without a Domain Name
Creating a website without a domain can be useful but often comes with limitations. As your project grows or turns commercial, transitioning to a custom domain can increase credibility and improve search engine rankings.
Conclusion
Building a website without a domain name is a viable option, especially for beginners or those working on non-commercial projects. Free subdomains, GitHub Pages, free hosting services, and localhost environments make it easy to establish a web presence. Once ready to grow, consider registering a domain to enhance branding and professionalism.
0 notes
Link
看看網頁版全文 ⇨ 為什麼我放在Docker Hub的映像檔不能用了? / Why My Docker Image on Docker Hub Cannot Be Used? https://blog.pulipuli.info/2024/11/why-my-docker-image-on-docker-hub-cannot-be-used.html 我們現在能開心地使用各種Docker環境,都是多虧了Docker Hub保存了這些Docker映像檔。 Docker Hub也可以稱得上是賽博菩薩了吧?但這免費資源可不是讓你毫無限制的使用喔!。 We can now happily use various Docker environments thanks to Docker Hub saving all these Docker images. You could say Docker Hub is like a Cyber Bodhisattva, right? However, this free resource is not for you to use without limit!。 ---- # 用Docker架設網站 / Setting Up a Website Using Docker。 https://medium.com/@habibridho/how-to-easily-setup-wordpress-using-docker-a798081dc577。 現在的軟體工程偏好採用虛擬化的環境來開發,以此確保各種元件都能在合適的版本、設定裡正常運作。 舉例來說,如果我們要在已經安裝好Docker環境的電腦上運作WordPress部落格系統的話,我們只要執行以下指令:。 [Code...] 然後就能打開瀏覽器,用 http://localhost:8080 來啟用WordPress了。 是不是很簡單呢?。 但你有沒有想過,這個WordPress系統到底是怎麽來的呢?以前學習架設WordPress的時候,不是還要安裝Apache跟PHP才能運作嗎?為什麼現在用一行指令就能安裝了呢?雖然嚴格來說,WordPress還要接上資料庫才能正式運作,不過從這裡就能看到Docker容器虛擬化的強大之處。 # Docker映像檔 / Docker Image。 我們之所以能夠輕易架設WordPress,這一切複雜的架構都以容器虛擬化的形式保存在Docker映像檔裡面。 在執行這個單純的指令時,Docker會檢查本機是否有Docker映像檔。 如果沒有,則會嘗試去下載網路上的Docker映像檔。 部分開發者也可能會選擇用編譯的方式來產生Docker映像檔,不過那脫離了本篇要講的範圍了。 ---- 繼續閱讀 ⇨ 為什麼我放在Docker Hub的映像檔不能用了? / Why My Docker Image on Docker Hub Cannot Be Used? https://blog.pulipuli.info/2024/11/why-my-docker-image-on-docker-hub-cannot-be-used.html
0 notes
Text
Script PHP Menampilkan Artikel Terkait
Apakah Anda sedang belajar membuat script CMS sendiri? Jika ya, rasanya belum lengkap deh tanpa fitur yang menampilkan daftar artikel yang terkait dengan sebuah artikel yang sedang dibaca oleh pengunjung blog. Dengan adanya fitur ini, pengunjung akan diarahkan ke artikel lain yang masih berhubungan dengan artikel yang sedang dibacanya sehingga bisa menambah wawasan lebih bagi mereka. Sedangkan efek positif bagi Anda sebagai pemilik situs adalah meningkatnya impression atau page view situs Anda, dan juga membuat visitor lebih tahan berlama-lama untuk menjelajahi situs Anda.
Apabila Anda menggunakan WordPress atau blogging software yang lain, maka fitur untuk menampilkian artikel terkait ini bisa langsung ditanam menggunakan plugin yang disediakan, misalnya YARPP. Namun, bagi Anda yang membuat CMS sendiri tentunya hal ini menjadi tantangan tersendiri. Oleh karena itu dalam artikel ini, saya akan mencoba memaparkan ide untuk membuat modul script yang menampilkan artikel terkait dengan PHP.
Misalkan kita mempunyai CMS dengan struktur tabel database untuk menyimpan data artikel seperti di bawah ini: CREATE TABLE `artikel` ( `id` int(11) AUTO_INCREMENT, `judul` varchar(100), `konten` text, `tanggal` date, PRIMARY KEY (`id`) );
dan andaikan kita sudah memiliki data artikel sbb:
https://web.archive.org/web/20231123143542im_/https://lh3-testonly.googleusercontent.com/blogger_img_proxy/ALY8t1uolFM_KTcIGadsDyfVT-Nqk4sIFcgxrKAWlFjJAsqyxHvnRZEH9_7zfRXNMZIURmoa4lYOX-1sQTswBeoovTbv66XA-vkv45YM8cUXycUJYm21npmQAl7QNlrbJLYcrdAm4R4NvPblf5GcXRg=s0-d
Selanjutnya, kita buat script untuk menampilkan detail isi artikelnya berdasarkan id artikel nya. artikel.php <?php // koneksi ke database mysql_connect('localhost', 'username', 'password'); mysql_select_db('database'); // membaca id artikel $idartikel = abs((int) $_GET['id']); // membaca data detail artikel berdasarkan id artikel $query = "SELECT * FROM artikel WHERE id = '$idartikel'"; $hasil = mysql_query($query); $data = mysql_fetch_array($hasil); ?> <html> <head> <title><?php echo $data['judul']?></title> </head> <body> <h1><?php echo $data['judul']?></h1> <small><em>Tanggal publikasi: <?php echo $data['tanggal']?></em></small> <div> <?php echo $data['konten']?> </div> <div> <h3>Artikel Terkait</h3> <?php include "function.php"; artikelTerkait($idartikel); ?> </div> </body> </html>
Script di atas digunakan untuk menampilkan konten dari sebuah artikel berdasarkan id artikelnya, dimana untuk menampilkan konten suatu artikel menggunakan URL http://namahost/artikel.php?id=… Perhatikan perintah $idartikel = abs((int) $_GET['id']);
perintah tersebut digunakan untuk mencegah SQL injection melalui GET method sebagaimana yang dulu pernah saya tulis artikelnya.
Jika kita perhatikan dari script di atas, maka di bawah isi artikelnya ada bagian sbb:<div> <h3>Artikel Terkait</h3> <?php include "function.php"; artikelTerkait($idartikel); ?> </div>
Selanjutnya kita tinjau apa isi dari function artikelTerkait(). Dalam contoh ini, keterkaitan artikel yang dimaksud di sini ditinjau dari kemiripan judul artikelnya. Adapun idenya adalah, kita baca semua judul
artikel yang ada dalam database kecuali artikel yang menjadi acuan (artikel ber ID $idartikel). Selanjutnya untuk semua judul artikel ini, kita lihat kemiripannya dengan judul dari artikel yang ber ID $idartikel ini. Kita bisa melihat kemiripan dari judul artikel ini menggunakan function similar_text() yang pernah saya bahas di artikel lain tentang uji kemiripan teks.
Kemudian, karena hasil dari penggunakan similar_text() ini berupa angka dalam bentuk prosentase kemiripan, maka sebaiknya kita membuat semacam batas minimal prosentase atau threshold, yang nantinya digunakan untuk memberi batas minimal kemiripannya. Sebagai contoh misalkan daftar artikel terkait yang ditampilkan hanya artikel yang memiliki tingkat kemiripan 50% ke atas. Hal ini berfungsi untuk memfilter mana artikel yang benar-benar mirip atau tidak. Artikel yang jauh dari mirip, akan memiliki prosentase kemiripan kecil. Tapi besar kecilnya threshold ini sepenuhnya terserah Anda, karena Andalah yang menentukan.
Hal yang menjadi pemikiran berikutnya adalah, bagaimana jika jumlah artikel yang terkait itu ada banyak, misalkan ada 100 buah? tentunya tidak mungkin kita tampilkan semua karena halaman page artikelnya bisa jadi penuh dengan judul-judul artikel sehingga tidak menarik bagi pengunjung. Oleh karena itu kita sebaiknya batasi jumlah artikel terkaitnya. Untuk mengimplementasikan hal ini, setiap judul artikel yang kemiripannya di atas threshold, maka kita simpan ke dalam sebuah array. Selama jumlah artikel dalam array tersebut belum memenuhi batas maksimum jumlah artikel nya, maka judul-judul terkait itu bisa ditambahkan dalam array. Setelah proses ini selesai, barulah kita tampilkan list judul artikel terkaitnya yang ada dalam array tersebut.
Nah… dari ide di atas, kita bisa membuat scriptnya sbb:
function.php <?php // koneksi ke database mysql_connect('localhost', 'username', 'password'); mysql_select_db('database'); function artikelTerkait($id) { // batas threshold 40% $threshold = 40; // jumlah maksimum artikel terkait yg ditampilkan 3 buah $maksArtikel = 3; // array yang nantinya diisi judul artikel terkait $listArtikel = Array(); // membaca judul artikel dari ID tertentu (ID artikel acuan) // judul ini nanti akan dicek kemiripannya dengan artikel yang lain $query = "SELECT judul FROM artikel WHERE id = '$id'"; $hasil = mysql_query($query); $data = mysql_fetch_array($hasil); $judul = $data['judul']; // membaca semua data artikel selain ID artikel acuan $query = "SELECT id, judul FROM artikel WHERE id <> '$id'"; $hasil = mysql_query($query); while ($data = mysql_fetch_array($hasil)) { // cek similaritas judul artikel acuan dengan judul artikel lainnya similar_text($judul, $data['judul'], $percent); if ($percent >= $threshold) { // jika prosentase kemiripan judul di atas threshold if (count($listArtikel) <= $maksArtikel) { // jika jumlah artikel belum sampai batas maksimum, tambahkan ke dalam array $listArtikel[] = "<li><a href='artikel.php?id=".$data['id']."'>".$data['judul']."</a></li>"; } } } // jika array listartikel tidak kosong, tampilkan listnya // jika kosong, maka tampilkan 'tidak ada artikel terkait' if (count($listArtikel) > 0) { echo "<ul>"; for ($i=0; $i<=count($listArtikel)-1; $i++) { echo $listArtikel[$i]; } echo "</ul>"; } else echo "<p>Tidak ada artikel terkait</p>"; } ?>
Mudah bukan membuatnya?
Nah… selanjutnya Anda bisa kembangkan sendiri script di atas, misalnya jika di dalam CMS Anda ada semacam kata kunci atau tag, maka artikel terkait bisa berdasarkan tag tersebut atau kategori artikel. Bisa juga, list artikel terkait yang muncul disorting dahulu dengan tingkat kemiripan paling tinggi terletak di urutan paling atas misalnya.
Selamat mencoba…
0 notes