Jump to content

Dynamic Table Problems


muat

Recommended Posts

I have a dynamic table which is based on a table in my dayabase called 'brands'

in the table i hold a value 'country' which is a int

this number corrosponds to the 'countrycode' in my country table

 

i want to be able to view the country name in my dynamic table not the country code

 

i have managed to get this idea workin in aonther part of my system but for some reason it wont work here and i have looked at it that much it doesnt make sence ne more!!

 

below id my code

 

$sql = " SELECT * FROM brand where brandcode >0 ORDER by brand";
//put the SQL result into a variable
//take the results from the results from the SQL suery and place in a variable $result
$result = mysql_query($sql) or die(mysql_error());
//count the number of rows in the variable and store the answer in $num
$num = mysql_num_rows($result);
$row = mysql_fetch_assoc($result,MYSQL_ASSOC);
extract ($row);

 

$sql2 = "SELECT * FROM country Where CountryCode = '$row[Country]'";
$result2= mysql_query($sql2) or die(mysql_error());
$row2 = mysql_fetch_array($result2,MYSQL_ASSOC);

  while($row=@mysql_fetch_array($result))
  //$row_color = ($row_count % 2) ? $color1 : $color2; 
  {
  	if ($row_counter == 1)
	{
	$bgcolour = $color1;
	$borderc = $color1;
	$row_counter =0;
	}
	else
	{
	$bgcolour = $color2;
	$borderc = $color2;
	$row_counter =1;
	}
    //?>
        <tr bgcolor="<? echo $bgcolour; ?>" bordercolor="<? echo $borderc;?>">
          <td><?php echo $row[brand]; ?>
              <input name="brandcode" type="hidden" id="brandcode" value="<? echo $row[brandCode]; ?>" /></td>
          <td><?php echo $row[Packer]; ?> </td>
          <td><?php echo $row2[country]; ?></td>
	  <td><?php echo $row[appNo]; ?></td>
          <td> </td>
          <td><a href="../admin/DeleteBrand.php?brandcode=<? echo $row[brandCode];?>"><img src="../../images/delete.png" width="16" height="16" /></a></td>
          <td><a href="../admin/AmendBrand.php?brandcode=<? echo $row[brandCode];?>"><img src="../../images/pencil.gif" width="20" height="21" border="0" /></a></td>
        </tr>
        <?php
// Increment the row count 
//$row_count++;   
//$row_count++;
} 
  ?>

 

database code

Create table brand
(
BrandCode int(5)AUTO_INCREMENT,
Brand Varchar(200),
Packer Varchar (200),
Country int(200),
appNo varchar (30),
primary key(BrandCode)
)
;

 

Create table country
(
CountryCode int(5)AUTO_INCREMENT,
country char(200),
primary key(CountryCode)
)
;

 

Any Thought any one??

Link to comment
https://forums.phpfreaks.com/topic/98810-dynamic-table-problems/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.