[PHP] Mysql table values display
Okay, here is an easy one, I haven't done php in a while so I kinda forgot the most important element of it O_O
Information: I have a mysql server, database and table with values in it, and i can connect to that database and all that good stuff
Problem: How can i have my website display the values from the table in my page?
(just need syntax :sweatdrop)
Re: [PHP] Mysql table values display
$val = mysql(str);
$val = mysql_fetch_row(resouce - $val);
print_r($val);
Enjoi
Re: [PHP] Mysql table values display
what do you mean by str and resource?
post an example with "blah" as a db, and whatever you want as row and column, please :)
thanks :)
Re: [PHP] Mysql table values display
Quote:
Originally Posted by
lothera
(just need syntax :sweatdrop)
That's as close as I can get to just plain syntax...
Connect to the db then use that syntax and it will return the results of whatever query you entered...
Re: [PHP] Mysql table values display
Here's a simple connect DB script
Code:
<?php
mysql_connect("localhost", "user", "pass") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>
Re: [PHP] Mysql table values display
PHP Code:
mysql_connect("localhost", "user", "pass") or die("Connection failed");
mysql_select_db("databasename");
$sql = "SELECT * FROM tablename ORDER BY id ASC";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo $row['id'];
}