Page 1 of 1

QUERYING PROBLEM PLS HELP!

Posted: Wed Dec 28, 2005 11:45 pm
by khaki_monster
hello pepz!

i have a problem here... i cant output a single query of a record. bellow is a code of my simple
query and a sample structure of 'news_tbl'. pls., help whats missing whit the code. :)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="../../default.css" rel="stylesheet" type="text/css">
<link href="../../balita.css" rel="stylesheet" type="text/css">
</head>
<body>

<!--

CREATE TABLE `news_tbl` (
`id` int(8) unsigned NOT NULL auto_increment,
`date` varchar(10) NOT NULL,
`location` char(3) NOT NULL default '0',
`section` int(1) NOT NULL default '0',
`title` varchar(150) NOT NULL default '',
`author` varchar(35) default NULL,
`lead` text NOT NULL,
`body` text NOT NULL,
`comments` text,
PRIMARY KEY (`id`)
)

-->

<?php
$host = 'localhost';
$user = 'root';
$pass = 'admin';
$dbse = 'mydb';
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($dbse) or die(mysql_error());
?>

<div align="center">
<?php
$loc = 'CBU';
$sec = 2;
conn_db($host, $user, $pass, $dbse);
$query = "title, author, body from news_tbl
where id = 1 and location = '$loc' and section = '$sec'";
$result = mysql_query($query);
$prv = mysql_fetch_array($result);
?>
<table width="590" border="0" cellpadding="3" cellspacing="0" class="tble">
<tr>
<td width="594" height="79"><div id="divalign">
<p class="dtitle"><?php echo $title = $prv[title]; ?> </p>
<p class="byline"><?php echo $author = $prv[author]; ?> </p>
<br>
<p>
<?php echo $body = nl2br($prv[body]); ?>
</p>
</div></td>
</tr>
</table>
</div>
</body>
</html>

THANKS IN ADVANCED!

cheerz!

Posted: Wed Dec 28, 2005 11:52 pm
by Charles256
um..what went wrong? use php tags.etc.etc.

Posted: Wed Dec 28, 2005 11:56 pm
by khaki_monster
it just didn't give me the output. if you could only see the code what went wrong...

QUERYING PROBLEM PLS HELP!(RESOLVED)

Posted: Thu Dec 29, 2005 12:06 am
by khaki_monster
haha... sorry i already found the problem! thanx for interest anyway...