Jump to content

Recommended Posts

What are the columns in your database? Does it contain the user's name or anything that you can use to get the particular user's inventory?

 

I`ll just post the code:

 

<?php
if(!$offset) $offset=0;
  $recent = 0;
  $res = mysql_query("SELECT id,name FROM clothing ORDER BY name ASC")or die( mysql_error() );
  while( $c = mysql_fetch_row($res) ){	  
if( $recent >= $offset && $recent < ($offset + 200000000 )){

$res2 = mysql_query("SELECT COUNT(*) FROM clot_sell WHERE item='$c[0]'");
$count1 = mysql_fetch_row($res2);
mysql_free_result($res2);

$res3 = mysql_query("SELECT COUNT(DISTINCT bought) FROM userdata WHERE bought='$c[0],'");
$count2 = mysql_fetch_row($res3);
mysql_free_result($res3);

$total = $count1[0] + $count2[0] ;

echo "$c[1] -> <b>$total</b><br>";
}
}
$res4 = mysql_query("SELECT COUNT(*) FROM clot_sell");
$count3 = mysql_fetch_row($res4);
mysql_free_result($res4);

$res5 = mysql_query("SELECT COUNT(*) FROM clothing");
$count4 = mysql_fetch_row($res5);
mysql_free_result($res5);

echo "<p>Total for Sale: <b>$count3[0]</b>";
echo "<br>Total of types available: <b>$count4[0]</b><p>";
?>

You can use the code The Little Guy posted, which is based on thorpe's idea.

 

I'm unsure how you want to do this. Do you want to get 1 person's data or all?

 

Something like this?

<?php
$res3 = mysql_query("SELECT bought FROM userdata");
if ($res || (mysql_num_rows($res3) > 0)){
echo array_count_values(explode(",",$res['bought']));
}
?>

You can use the code The Little Guy posted, which is based on thorpe's idea.

 

I'm unsure how you want to do this. Do you want to get 1 person's data or all?

 

Something like this?

<?php
$res3 = mysql_query("SELECT bought FROM userdata");
if ($res || (mysql_num_rows($res3) > 0)){
echo array_count_values(explode(",",$res['bought']));
}
?>

 

Yes, I wanted to count up all. I basically just wanted to see how many copies of an item was floating around.

 

I posted your code in but that seems to have made no effect.

Well if you know the item ID number, then you can do this:

 

<?php
$res3 = mysql_query("SELECT bought FROM userdata");
if ($res || (mysql_num_rows($res3) > 0)){
$arr = array_count_values(explode(",",$res['bought']));
// in this line, just say $arr[id] where id is the number you're looking for //
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.