RE: DB CODEING HELP!!!!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> this is bugging me. I have tried everything and I cant develop
> the code without an error. Can someone plese write me simple code
> that will go through a table and print 3 collums of that table? I
> cant figure it out

I don't know which database you're using but say for example it was MySQL
here's a very quick and dirty example ....

<?
$link = mysql_connect('localhost','user','password') or die(mysql_error());
if (mysql_select_db('mydatabase',$link)) {
	$rs  = mysql_query('select col1, col2, col3 from mytable') or die
(mysql_error());
	$num = mysql_num_rows($rs);
	for ($i=0;$i<$num;$i++) {
		$row = mysql_fetch_assoc($rs);
		echo 'Col 1: '.$row['col1'].' Col 2: '.$row['col2'].' Col 3:
'.$row['col3'].'<br />';
	}
}
mysql_close($link);
?>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux