Jump to content
php.lv forumi

Izvade ciparu veidā


tk1

Recommended Posts

Sveiki..

 

Nu tā kods -

<?php
// Connecting, selecting database
$link = mysql_connect('localhost', '...', '...')
  or die('Could not connect: ' . mysql_error());
echo '';
mysql_select_db('warezlv') or die('Could not select database');

// Performing SQL query
$query = 'SELECT `member_name` FROM `ibf_sessions` ORDER BY `member_group` DESC LIMIT 0, 30';
$result =  mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  echo "\t<tr>\n";
  foreach ($line as $col_value) {
   echo "\t\t<td>$col_value</td>\n";
  }
  echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>

 

Vinjs tagad izvada visus lietotājus kas iegājuši (vinju nikus), bet man vajadzētu lai izvada viņu kopējo skaitu...Kā to var dabūt gatavu??..

Jav iepriekš paldies!!!

 

-TK*1

Link to comment
Share on other sites

// Performing SQL query

$query = 'SELECT `member_name` FROM `ibf_sessions`';

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

$nums = mysql_num_rows($result);

 

$query = 'SELECT `member_name` FROM `ibf_sessions` ORDER BY `member_group` DESC LIMIT 0, 30';

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

 

 

// Printing results in HTML

echo "<p>Kopā: ".$nums."</p>";

echo "<table>\n";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

echo "\t<tr>\n";

foreach ($line as $col_value) {

echo "\t\t<td>$col_value</td>\n";

}

echo "\t</tr>\n";

}

echo "</table>\n";

 

// Free resultset

mysql_free_result($result);

 

// Closing connection

mysql_close($link);

?>

Edited by Kristabs
Link to comment
Share on other sites

×
×
  • Create New...