Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: show 4 latest registries from mysql

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default show 4 latest registries from mysql

    Hallo, I want to call and show 4 latest regitered accounts to my page. How I can seperate 4 latest from others? What php script must look like? Thanks
    Last edited by auriaks; 11-06-2009 at 10:25 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can I see your database structure please? Thank you.
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    PHP Code:
    INSERT INTO infos (infoaboutdatetimeurl) ... 
    You ment this??

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    The following should help you get started. This assumes that you have a database and table set up. Replace

    host with host name
    username with database username
    password with database password
    maincontent with your table name
    ID with column names(s)

    PHP Code:
    <?php
    $conn
    =mysql_connect("host""username""password");
    mysql_select_db("database_name",$conn) or die("Unable to select database");
    $query "SELECT ID FROM maincontent ORDER BY ID desc limit 0,3";
      
    $result mysql_query($query,$conn) or die ("Couldn't execute query.");
    while (
    $list_info mysql_fetch_array($result,MYSQL_ASSOC)) {
    $tadaa$list_info['ID'];$me.="pop $tadaa pop<br>";}
    echo 
    "$me";
    ?>
    To choose the lesser of two evils is still to choose evil. My personal site

  5. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Yes, that is what I mean. Does date respresent the time the user registered? (can I see an example of date being used?)
    Jeremy | jfein.net

  6. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    doh, you're right Nile. He is using date and time. I really need to slow down and read the posts a little more carefully before I reply.

    It seems to me that it would be best to use datetime as opposed to date and time. Then again I use two sets of time for my articles as well; one for the date the article was written and the second for the date last it was last updated.
    To choose the lesser of two evils is still to choose evil. My personal site

  7. #7
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Haha. Every one makes mistakes .

    Just to clarify (for auriaks) when I said example, I meant an example of a value that might be inserted into the date column, like: dd-MM-yy. Or something like that.
    Jeremy | jfein.net

  8. #8
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    OK, here is all I got - i created this table:
    PHP Code:
    # create links table
        
    $SQL " CREATE TABLE culture (";
        
    $SQL $SQL " id INT NOT NULL AUTO_INCREMENT, ";
        
    $SQL $SQL " product VARCHAR(500), ";
        
    $SQL $SQL " about VARCHAR(1000), ";
        
    $SQL $SQL " date DATE, ";
        
    $SQL $SQL " time TIME, ";
        
    $SQL $SQL " url VARCHAR(1000),";
        
    $SQL $SQL " PRIMARY KEY(id) );"
    I use this script for registration:

    PHP Code:
    //connect to the database 
    //select table 

    $date date("Y-m-d"); 
    $time date("H:i:s");
    $type $_POST['type'];

    if(
    $_POST['product'] == '') {
        
    $error .= "<li>None or same name</li>";
    }
    if(
    $_POST['about'] == '') {
        
    $error .= "<li>Insert your description</li>";
    }
    if(
    $_POST['url'] == '') {
        
    $error .= "<li>Insert Net</li>";
    }
    if(isset(
    $_POST['submit'])) {
        if(isset(
    $error)) {
            echo 
    '<font color="#ff0000">Cant insert. Mistakes:';
            echo 
    '<ol>'.$error.'</ol></font>';
        } else {
            echo 
    '<font color="Green">Inserted!</font>';
            
    mysql_query("INSERT INTO $type (product, about, date, time, url) 
            VALUES('
    $_POST[product]', '$_POST[about]', '$date', '$time', '$_POST[url]')") or die(mysql_error());
        }
    }

    ?> 
    thx

  9. #9
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ok, give this a try:
    Go into your PhpMyAdmin.
    Click the database your table is in.
    Click the table your information is in.
    Click "Export"
    Scroll down and click "Go"
    Copy and paste all the information here in between [quote] tags.

    Good luck.
    Jeremy | jfein.net

  10. #10
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    PHP Code:
    -- phpMyAdmin SQL Dump
    -- version 2.11.9.6
    -- http://www.phpmyadmin.net
    --
    -- 
    Darbin&#279; stotis: localhost
    -- Atlikimo laikas:  2009 mLapkri&#269;io 06 d.  22:48
    -- Serverio versija5.0.85
    -- PHP versija5.2.11

    SET SQL_MODE
    ="NO_AUTO_VALUE_ON_ZERO";

    --
    -- 
    Duombaz&#279;: `buynsel`
    --

    -- --------------------------------------------------------

    --
    -- 
    Sukurta duomen&#371; struktūra lentelei `culture`
    --

    CREATE TABLE IF NOT EXISTS `culture` (
      `
    idint(11NOT NULL auto_increment,
      `
    productvarchar(1000) default NULL,
      `
    aboutvarchar(1000) default NULL,
      `
    datedate default NULL,
      `
    timetime default NULL,
      `
    urlvarchar(1000) default NULL,
      
    PRIMARY KEY  (`id`)
    ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;

    --
    -- 
    Sukurta duomen&#371; kopija lentelei `culture`
    --

    INSERT INTO `culture` (`id`, `product`, `about`, `date`, `time`, `url`) VALUES
    (2'The Magic Of Making Up (Get Your Ex Back).''A Hungry Crowd That Is Desperate For Help Makes You A Lot Of Easy Sales. Help Keep Relationships Together And Make 75% Commission Too. Virtually Unlimited Traffic Now And In The Future. For Free Articles, Video And Help See Affiliate Page.''2009-10-30''20:01:27''http://aad7133cpxun0vb6mammlsuy9k.hop.clickbank.net/?tid=BUY'),
    (
    3'Government-Records.com - **Pool Your Bonuses With Our Sites!''Over 200 Million Real Public Records And Growing! Promote The Highest Quality Public Records Service On Cb! Telephone Customer Support Coming Soon. Always Raising The Bar!''2009-10-30''20:02:07''http://ce6c8x9ep-ul7r3fzt32ec5yvm.hop.clickbank.net/?tid=BUY'),
    (
    4'Home Made Energy - The Best Diy Offer!''Home Made Energy - The Best Diy Offer!''2009-10-30''20:02:52''http://e746936jsyxp8lbbtjkkf3n0ua.hop.clickbank.net/?tid=BUY'),
    (
    5'Save My Marriage Today!''Save My Marriage Today!''2009-10-31''22:07:54''http://bcc83v4hx3tg8m6dpgfbnb45o3.hop.clickbank.net/?tid=BUY2'); 
    lithuanian, but maybe you'll understand

Bookmarks

Posting Permissions

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