• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

MySQL and recalling values

Ive created a mysql database that contains say a product id, and then about 10 other variables, how do I implement this into my html code so I can recall each individual variable based on the specified product id at various locations within the html code ?
0
MirageSF
Asked:
MirageSF
2 Solutions
 
harwantgrewalCommented:
just concatdinate the id with the variable name

harry
0
 
HatembenCommented:
<?php

$sqlhostname = "localhost";
$login = "uname";
$password = "passwd";
$base = "database";

// product id
$id = "";

$db_connect = mysql_connect($sqlhostname,$login,$password);
$base_selection = mysql_select_db($base,$db_connect);

$query = "Select * from product_tbl WHERE product_id ='$id'";
$req = mysql_query($query);

if (!$req)
{ echo "<B>Error ".mysql_errno()." :</B> ".mysql_error()."";
exit; }
$res = mysql_num_rows($req);

if ($res == 0)
   { echo "<center><b>Sorry there is no result.</b></center>";}
else
   { while($row = mysql_fetch_array($req))
            {
               extract($row);

                echo"$id<BR>
          $field_1<BR>
          $field_2<BR>
          $field_3<BR>";
    }
mysql_free_result($req);
}

?>
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now