Jump to content
php.lv forumi

Recommended Posts

Posted (edited)

Sveiki,

 

No PHP gandrīz neko nezinu, pēc pamācības aptuveni uzkabināju tabulu, kurā vajadzētu parādīties visiem lietoājiem, vārdam utt. no datubāzes. Viss strādā labi, izņemot to, ka garumzīmes neparādās. Datubāzē garumzīmes ir, tā kā tur nevajadzētu būt vaina.

 

Kāds varētu lūdzu uzmest aci kodam?

 

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<?php

$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="lost"; // Database name 
$tbl_name="jos_users"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Retrieve data from database 
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

// Start looping rows in mysql database.
?>
<table  border="1px" cellspacing="0" cellpadding="3">
<tr>
<td width="150px"><strong>Vārds</strong></td>
<td width="150px"><strong>Uzvārds</strong></td>
<td width="150px"><strong>Telefons</strong></td>
<td width="150px"><strong>Uzņēmums</strong></td>
<td width="150px"><strong>E-pasts</strong></td>
</tr>
</table>
<?php
while($rows=mysql_fetch_array($result)){
?>
<table  border="1px" cellspacing="0" cellpadding="3">
<tr>
<td width="150px"><?php echo $rows['name'];?></td>
<td width="150px"><?php echo $rows['surname'];?></td>
<td width="150px"><?php echo $rows['username'];?></td>
<td width="150px"><?php echo $rows['company'];?></td>
<td width="150px"><?php echo $rows['email'];?></td>
</tr>
</table>

<?php
}
mysql_close();
?>

post-5155-0-07969500-1293620635_thumb.png

Edited by KasparsM
Posted (edited)
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
mysql_query("SET NAMES 'utf8'");

Edited by Blitz
Posted

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
mysql_query("SET NAMES 'utf8'");

 

 

Liels paldies, tikko pats atradu..

Posted (edited)

Es tagad vēl izveidoju kolonu - Reģistrācijas laiks. Varbūt var kāds uz ātro pateikt kā visus tos ierakstus var sakārtot pēc reģistrācijas laika, augošā secībā?

 

Atradu pats, paldies!

Edited by KasparsM

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...