Jump to content
php.lv forumi

Lūdzu palīdziet izvilkt datus


LinuX

Recommended Posts

Sveiki palīdziet lūdzu pareizi izvilkt datus no datubāzes, man vajag izvilkt tikai vienu rindu no datubāzes piemēram rindu kur id ir vienāds ar 1. Paldies jau iepriekš.

$txt = $_GET['txt'];

mysql_connect("$host", "$user", "$pass") or die("cannot connect db");
mysql_select_db("$db_name") or die ("cannot select db");

$sql = "SELECT txt FROM $tbl_name WHERE id = '$_GET[\'id\']' ";
$result = mysql_query($sql);

while($rows = mysql_fetch_array($result))
{
$check_name = strip_tags($rows['txt']);
$wrap = wordwrap($check_name, 100, "<br>");

	echo $wrap;
}

Edited by LinuX
Link to comment
Share on other sites

Šajā rindiņā liekas ka vajadzēja rakstīt šādi, ja atmiņa neviļ:

Nevis:

$sql = "SELECT txt FROM $tbl_name WHERE id = '$_GET[\'id\']' ";

Bet:

$sql = "SELECT txt FROM $tbl_name WHERE id = '$_GET[id]' ";

 

Bet var jau arī vispirms:

$id = $_GET['id'];

Un tad:

$sql = "SELECT txt FROM $tbl_name WHERE id = '$id' ";

Link to comment
Share on other sites

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