Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple SQL help needed!


Guest

Recommended Posts

Ok, I am a beginer at PHP, but have a little SQL knoweldge.

 

I'm simply wanting to select a field from a table. The table is called 'sources' a simply 2 collums table with sources_name and sources_id.

 

I'm wanting to print the sources_name vlaue given sources_id value.

 

This is what I've tried:

 

$my_query = tep_db_query("select sources_name from sources where sources_id = '6'");

<?php echo $my_query; ?>

 

This brings back Resource id #5, which I know (via google) is because I'm missing a step in the PHP, but I can't figure it out! :(

 

Many thanks for the help!

 

(PS The sources contrib is #1888/, but I'm wanting to use the results in other sections of the admin.)

Link to comment
Share on other sites

Try this piece of code not tested and not syntax checked....

 

$my_query = tep_db_query("select sources_name from sources where sources_id = '6'");
while ($my_array = tep_db_fetch_array($my_query)) {
  $my_sources = $my_array['sources_name'];
   echo "got $my_sources";
};

 

Tom

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...