English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1. There is a database called "products". It contains the fields "productName", "productID", and "productDescription".

2. This database is queried, and the results are placed in an array called productArray. ProductArray is passed to a function called showSearchResults.

3. showSearchResults uses a foreach loop to display the "productName" of each element in the array. Each displayed name is hyperlinked to a page called "showMoreInfo.php".

4. When any of these hyperlinks are clicked, "showMoreInfo.php" will display the "productDescription" of whichever product's hyperlink was clicked.



It's steps 3 and 4 that I can't seem to figure out. I'm not even sure that I can use the foreach loop, because, if I use it to display the productNames, it acts as if $productId doesn't exist. I also don't know how to tell showMoreInfo.php which hyperlink was clicked.

I'd appreciate specific coding suggestions for the showSearchResults function and the showMoreInfo.php page,

2006-11-09 03:58:00 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

on the showresults page your php would look something like this:

$sql= "SELECT productID, productName FROM $products";

create the array as a variable (ie $result)
then create a way it will display

$product_list = "

    ";
    while ($row = mysql_fetch_array($result)) {
    $id = $row['productID'];
    $productName = $row['productName'];

    $product_list .="
  • $productName
  • ;
    }

    $product_list .="
";


Then create your html





2006-11-09 04:20:25 · answer #1 · answered by arus.geo 7 · 0 0

fedest.com, questions and answers