Need Help In a Theme Wordpress

Discussion in 'PHP' started by riteshsanap, Sep 8, 2010.

  1. #1
    Hi Friends I m not that Good or I dont know PHP So i am asking for an Help in PHP ,

    <a rel="nofollow" class="dwnload" href="http://www.example.com/download/<?php echo get_post_meta($post->ID, "dwn_id", $single = true); ?>/">
    <?php $dwn_count = $wpdb->get_var("SELECT file_hits FROM wp_downloads WHERE file_id = 2"); ?><?php echo '( ' . $dwn_count . ' Downloads )'; ?>
    PHP:
    I m using the Above code to show statistics from SQL it works fine but when i replace the Code "file_id = 2" with the Custom Field of dwn_id means ex : "file_id = dwn_id" or "file_id = $dwn_id"

    both didnt work :(
    which i use to define the ID of that file then it won't work please help with it.

    Glossary (Made So you Understand Problem More Easily and Give me Correct Solution Quickly :p ) :
    
    dwn_id = Custom Field used in Post to define the ID of the download
    
    dwn_count = Used to display the Statistics of the Download
    
    2 = is used to test the code and its works when i use the number but dont work when i use dwn_id instead of number :( 
    
    PHP:
    Hope i get a Quick reply With Correct Solution :D
     
    riteshsanap, Sep 8, 2010 IP
  2. Eager2Seo

    Eager2Seo Member

    Messages:
    72
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Change:
    <?php echo get_post_meta($post->ID, "dwn_id", $single = true); ?>
    Code (markup):
    to:
    <?php echo $dwn_id = get_post_meta($post->ID, "dwn_id", $single = true); ?>
    Code (markup):
    Then:
    "SELECT file_hits FROM wp_downloads WHERE file_id = {$dwn_id}"
    Code (markup):
    The brackets are optional, unless you have an array, but I like to put them in
     
    Eager2Seo, Sep 8, 2010 IP
  3. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #3
    Hehehehe Thanks It really Worked thank you very much it also increased my knowledge in PHP you are great, For this Help i have Rep you
     
    riteshsanap, Sep 8, 2010 IP
  4. Eager2Seo

    Eager2Seo Member

    Messages:
    72
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #4
    :) No problem
     
    Eager2Seo, Sep 8, 2010 IP