how can i match this?

Discussion in 'PHP' started by baris22, Feb 15, 2009.

  1. #1
    Hello,

    I am adding content into wordpress database. On the database there are two columns They are: id (which is set to auto_increment) and guid.

    Guid contains url and has got the same value with id.

    Forexample

    id:1
    guid: http://localhost/wordpress/?p=1

    id:2
    guid: http://localhost/wordpress/?p=2

    What do i need to do to insert id and guid correctly into the database?

    Thanks
     
    baris22, Feb 15, 2009 IP
  2. Scripten

    Scripten Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well I don't have time to install WP and try it but it should be easy with the following script(only if you use the GET method):

    
    <?php
    $id = $_GET['p'];
    $url = "http://localhost/wordpress/?p=" . $id . "";
    $insert = mysql_query("INSERT INTO links_table('id', 'guid') VALUES('" . $id . "', '" . $url . "')");
    ?>
    
    PHP:
     
    Scripten, Feb 15, 2009 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I got it working.
    I did this

    
    
    	$query = "SELECT COUNT(*) as num FROM wp_posts";
    	$total_pages = mysql_fetch_array(mysql_query($query));
    	$total_pages = $total_pages[num];
    	$total_pages = $total_pages +1;
    
    
    PHP:
     
    baris22, Feb 15, 2009 IP