PHP SQL in wordpress

Thanks for any help in advance
i have a site that im trying to add features in but im not that good with php yet... my normal coding language is coldfusion.

what im trying to do is get my image slider on my front page to look like the posted image which i have but the only thing i cannot get is the price from the database to display as well... mainly because i dont understand the relationship between the post and postdata tables....

so what i need is some help to write the code that with get the price and display it on top of the images that rotate every 5 secs on my front page....

also, wordpress makes the php code very confusing for me.... am i just really crap at php or is wordpress really advance php??? or just confusing to everyone lol..

please any help would be wonderful...

 mul23072-wrdp2--1-.xls  template-front.php image of what the page needs to look like
LVL 1
Rcollins207Asked:
Who is Participating?
 
jrm213jrm213Connect With a Mentor Commented:
it looks like you could also use get_post_meta($post_id, $key, $single); http://codex.wordpress.org/Function_Reference/get_post_meta

so

instead of

<?php echo "<h1>testing</h1>"; ?>

you could try:

<?php echo(get_post_meta(get_the_ID(), 'price', true)); ?>


Wordpress just has things encapsulated for you, so you need to find the function that gets what you want. You could write your own function to connect and query the database, but they already have the functions in place for you.
0
 
jrm213jrm213Commented:
Hi,

If the price is in a custom field as part of each post, you get it using the function get_post_custom http://codex.wordpress.org/Function_Reference/get_post_custom

It looks like the excel that you attached is the posts table, the price data should not be in there. The only other thing I could think is that the price data is in a separate table. How does it get entered?

0
 
Rcollins207Author Commented:
a custom field... but the price data is in the other tab in excel called postdata which is the other table..... and i kinda need help with the code as i suck at php sorry
0
 
jrm213jrm213Commented:
I think you could replace:

<?php echo "<h1>testing</h1>"; ?>

with

<?php
$key = "name_of_your_custom_field";
$custom_values = get_post_custom_values($key, get_the_ID());
//I am going to guess you only have one value for the key, but just in case...
 foreach ( $custom_values as $key => $value ) {
    $myvalue = $value;
  }
//maybe do a check to make sure value is what you expect, then if it is echo it out...
echo($myvalue);
?>
0
 
Rcollins207Author Commented:
ty
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.