Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Search Button

  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    87
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Search Button

    I'm familiar with PHP but have no clue of how to achieve the following tasks for a website I'm constructing:
    1. To make my search button functional but searching through a database for data.
    2. To make the first ten posts appear on the archives page, but provide a link at the bottom of loading the next ten posts i.e. page 1, 2, 3......with each page having at most ten posts.
    3. To send an email to subscribed members immediately I post an article.

    Someone please help. I will be deeply grateful. Thank you.

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    709
    Thanks
    20
    Thanked 84 Times in 84 Posts
    1) there are many ways to search a database, do you just want to search 1 column in 1 table or many columns?

    file.php?search=Maina
    PHP Code:
    $searchterm $_GET['search']
    SELECT 
        
    *
    FROM 
        yourtable
    WHERE 
        id LIKE 
    '%$searchterm%' 
        
    OR position LIKE '%$searchterm%'
        
    OR category LIKE '%$searchterm%'
        
    OR location LIKE '%$searchterm%'
        
    OR description LIKE '%$searchterm%'
        
    OR refno LIKE '%keyword%'

    2) its called pagination and again there are many ways to implement this,

    this would fetch the first ten entrys
    file.php
    PHP Code:
    "SELECT * FROM yourtable LIMIT 0, 10" 
    file.php?page=2

    PHP Code:
    $frompost = ($_GET['page']-1)*10//page=2 would start at 10 etc
    "SELECT * FROM yourtable LIMIT $frompost, 10" 
    3) in your script that you use to INSERT on successfull you can SELECT email FROM users WHERE subscribed=1

    then use the mail() command to email them.

    PHPMAILER (google it) is good for batch emails
    Last edited by Arcticwarrio; 03-20-2013 at 11:26 PM.
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    87
    Thanks
    18
    Thanked 0 Times in 0 Posts

    PHP/MySQL Syntax for the latest column

    Arcticwarrio, thanks for your help. I've run into another problem. What is the MySQL/PHP Syntax for the latest column to be updated in a database table? In this case, I'm talking of the column with the latest date/time. I would like to display data in the latest column on a webpage. Thanks.

  • #4
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    709
    Thanks
    20
    Thanked 84 Times in 84 Posts
    "select * from table order by date ASC"
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •