Forum Moderators: coopster
Maybe something like this.
$total = 0;
$sql = "SHOW TABLE STATUS";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo "row ".$row['Data_length']+$row['Index_length']."<br>";
$total += $row['Data_length']+$row['Index_length'];
}
echo($total);
I think this is pretty close to the mark but i havent tested it. (as ever)
Ally
I suppose you could select all columns for the particular row and count up the total characters in each column for that row. It would certainly be an ugly kludge though.
Another alternative may be to use a variable percentage. Get the overall table size and use the number of rows you are interested in to calculate it's percentage of the overall table size.
It would certainly be an ugly kludge though.
Did you try to "SELECT * FROM table" and then loop through the result: (not sure if strlen "behaves" when it gets date or boolean values - but you can surely refine this. Since you're probably interested in text values only, the rest being of identival size, cou could as well just add up those text fields.)
while ($row = mysql_fetch_assoc ($queryresult)) {
$rowlen = 0;
foreach ($row AS $value) {
$rowlen += strlen ($value);
}
echo $rowlen . "<br>";
}
btw. does anybody know how to indent (tab) program examples here?