Jump to content
php.lv forumi

Nesanāk parādīt visus datus no datu bāzes


Dooling

Recommended Posts

Lieta tāda, ka mans kods, parāda tikai vienu ierakstu no datu bāzes, bet man vajag, lai parāda visus datus

 

$hostname = "localhost";  
$dbuser = "turists";     
$dbpass = ""; 
$dbname = "BDA";  
mysql_connect($hostname,$dbuser,$dbpass); 
mysql_select_db("$dbname"); 

  $query = "select * from monitori"; 
  $result = mysql_query($query);       
  while($row = mysql_fetch_array($result)) 
  { 
  $nos = $row["nosaukums"]; 
  $raz = $row["razotajs"]; 
  $ser = $row["serija"]; 
  $mod = $row["modelis"]; 
  $yrs = $row["iz_gads"]; 
  $stat = $row["statuss"]; 
  $com = $row["comment"]; 
} 
echo $nos;
echo $raz;
echo $ser; 
echo $mod; 
echo $yrs; 
echo $stat;
echo $com;

 

Kā lai parāda visus datus no datu bāzes?

Link to comment
Share on other sites

tu izvadi mainīgos tikai pēc tam kad while cikls tev ir pārskrējis visas rindas (resp. tikai pēdējo rindu)

 

jābūt:

while($row = mysql_fetch_array($result)) 
{ 
 //izvads ar echo vai tml. šeit, piem:
  print_r($row);
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...