I want to include some variables in an HTML table. The variables are stored in phpmyadmin and my site a CartWeaver site, I'm using Dreamweaver.

How do I insert variables into separate table cells? I thought this would work but it isn't so:

<?php echo($row_rsCWResults["product_ShortDescription"] . "<br />") ?>

Recommended Answers

All 6 Replies

Much simpler:

What is the code to display the value of the field "product_style" in an HTML table cell?

Your pulling this $row_rsCWResults["product_ShortDescription"] from a separate page in your script.

The best option for what you have going on is to query the db again to pull that value for the page where it's needed.

A generic query would look something like this ... you can fill in the table info as needed.

$query=mysql_query("SELECT col_name FROM table_name WHERE  col_name='$some_value'");
while($row=mysql_fetch_array($query)){
$product=$row['col_name'];}

echo "$product"; 
// OR 
<?=$product?>

my database is qcdb my table is tbl_products and the variable is product_style, how does it go?

what is $some_value?

Assuming that you have more than one product style listed in your table, $some_value would be the specific product style you want to display. Let's say you have 3 different product styles (example1, example2, and example3) and you want to display the product style of example2.

$query=mysql_query("SELECT product_style FROM tbl_products WHERE  product_style='example2'");
while($row=mysql_fetch_array($query)){
$product=$row['product_style'];}
 
echo "$product"; // <-- will output 'example2'

You can pull other information as well related to that item. Price, description, etc.
It may be worth for it for you to check out a tutorial that will break it down for you step by step and you can try a few things out for yourself.
http://www.w3schools.com/php/default.asp

I'll be hammering as many tuts as I can over the weekend. I'm not sure we're talking about the same thing though.

I want it to pull the style associated with the current product, not pull the product according to the style I want, though..

That wouldn't be a problem at all, the query just needs to be changed a bit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.