Forum Moderators: coopster
I just added 3 new fields (price_sale, price_rental & price_specials) to contain pricing information. I do NOT want to use these fields on the previous listing page.
What I want to do is show this pricing information on individual product pages.
What I have is a page that contains various products. What I want is something like this.
-----------------------------------
<?php
require_once('incl_productlist_dbconnect.php');
require_once('incl_productlist_variables.php');
MYSQL QUERY AND SUPPORTING CODE GOES HERE
?>
<table width="100%">
<tr><th colspan="2">Product Header Goes Here</th></tr>
<tr><td width="50%">Product Images Go Here</td>
<td width="50%">Product Description Goes Here
<?php
// START CODE FOR DISPLAYING PRICING
echo "<table width="100%">";
echo "<tr><td width="50%">Sale Price:</td><td width="50%">$Sale</td></tr>";
echo "<tr><td width="50%">Rental Price:</td><td width="50%">$Rental</td></tr>";
echo "<tr><td width="50%">Special Price:</td><td width="50%">$Special</td></tr></table>";
// END CODE FOR DISPLAYING PRICING
?>
</td><tr></table>
-----------------------------------
THIS IS FOR 1 PRODUCT ON THE PAGE.
Now we repeat this (minus the includes and the query) for each additional product on the page.
In the above code, we need pull the primary field (which is stock_no) and then display the price_sale, price_rental and price_specials values from that row only, then do it again for the next product to be displayed. Maybe make a variable like $Stock1020=row['stock_no']1020. // I don't know, I am just badly guessing here.
Now I am more than able to write html code, but am lost on php.
I already have the DB connect file and the variables file that are used on the other program.
My "incl_productlist_variables.php" file contains this (among other things).
-----------------------------------
$stock_no="stock_no"; // Product Stock #
$Rental="price_rental";
$Sale="price_sale";
$Specials="price_specials";
-----------------------------------
My "incl_productlist_dbconnect.php" contains this (among other things).
-----------------------------------
<?php
$hostname="#*$!.#*$!#*$!xx.#*$!"; // Address to the Database Server
$dbname="#*$!#*$!xx"; // Name of Database
$username="#*$!#*$!xx"; // Username to Access Database
$password="#*$!#*$!xx"; // Password to Access Database
$usertable="inventory"; // Name of the Database Table
?>
-----------------------------------
What I need is the actual code to make this work. I would prefer it if the primary table html structure was not all enclosed in "echo" statements.
Any help would be greatly appreciated.
[edited by: justasiam at 10:52 pm (utc) on Feb. 27, 2009]
[edited by: eelixduppy at 8:35 pm (utc) on Feb. 28, 2009]
[edit reason] no URLs, please [/edit]
What I need is the actual code to make this work.
You need to develop the database query, execute the query and then process the result set. There is a message in the PHP forum library that describes the basics.
I would prefer it if the primary table html structure was not all enclosed in "echo" statements.
One way to accomplish this task is to use the PHP heredoc [php.net] syntax. Simply populate all your dynamic field data and your variables will automatically be interpolated by the PHP engine when it discovers them in the heredoc string.