Hello.

I have gone through various checks, and I can't seem to figure this one out...

while($row_sizes = mysql_fetch_array($sql_sizes));
					{	
						$sizes = $row_sizes['size'];
						$product_list .= count($sizes);
						$product_list .= "<li>".$sizes."</li>";
					}

Its not outputting any sizes. However, my count($sizes) outputs 0. And that shouldn't because I have

$sql_colors = mysql_query("SELECT * FROM colors WHERE $id = product_id");
		$sql_sizes = mysql_query("SELECT * FROM size WHERE $id = product_id");
while($row_colors = mysql_fetch_array($sql_colors))
					{
						$colors = $row_colors['color'];
						$product_list .= "<li>".$colors."</li>";

					}

And the color portion in my code works! But not the size!? Its exactly the same coding, but just had different words?

Can someone help me detect what I'm missing?

Thanks

what do your mySQL tables look like?

i have an id, product_id, size

I also tried outputting product_id with

$row_sizes['product_id'];

but that doesn't work either. I thought it would be the mysql_fetch_array, but it looks right to me?

Check you connection string, trim database names, see if firewall is not blocking any MySQL port. If that dont work, use die statement and post the exception here, if you cant figure out.

do like this:

$sql = "your_query";
	$con = mysql_connect(your_connection_string) or die("error ".mysql_error());
	if (!$con)
  	{
  		die('Could not connect: ' . mysql_error()."\n");
  	}
  	mysql_select_db("your_database", $con);
  	$result = mysql_query($sql);
  	if (!$result)
  	{
  		die('error in query: ' . mysql_error()."\n");
  	}
  	while($row = mysql_fetch_array($result))
  	{
  		//stuff	
  	}
	mysql_close($con);

maybe this will give you an idea of what is happening :)

are ther two tables or just one???

why not try

$sql_colors = mysql_query("SELECT * FROM `colors` WHERE `id` ='$product_id'");
$sql_sizes = mysql_query("SELECT * FROM `size` WHERE `id` ='$product_id'");

that is assuming that product_id is a variable ( e.g. $product_id = $_GET[id]; )
might fix it

id and product_id are numbers

I think your mysql query is just a little confused, assuming you are saying that you are trying to get the id from the `product_id` you would use this code:

$sql_colors = mysql_query("SELECT * FROM `colors` WHERE `product_id`='$id'");
$sql_sizes = mysql_query("SELECT * FROM `size` WHERE `product_id`='$id'");

Hope that fixes it :)

:( I wished that was the case. But it doesn't seem like that worked. I mixed it up as well but still not producing what its supposed to

while($row_sizes = mysql_fetch_array($sql_sizes));
					{	
						$sizes = $row_sizes['size'];
						$product_list .= count($sizes);
						$product_list .= "<li>".$sizes."</li>";
					}

your main error now that I see it is:

you have a ; after your while

it should be

while($row_sizes = mysql_fetch_array($sql_sizes)){
	
						$sizes = $row_sizes['size'];
						$product_list .= count($sizes);
						$product_list .= "<li>".$sizes."</li>";
					}

OH MY GOSH! Thank you!!

Yes that worked!

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.