Jump to content

Question plz


esoom

Recommended Posts

assuming you have a table called 'table' and some columns called 'name' and 'email' for example purposes:

[code]
//database information used to connect
$host = 'localhost'; // the host name for the database. usually 'localhost' works
$user = 'username'; // the database username
$pass = 'password'; // the database password
$dbname = 'databasename'; //name of your database

//connect to the database
$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
$db = mysql_select_db($dbname) or die(mysql_error();

//select all the information from the table
$sql = "select * from table";
$result = mysql_query($sql, $conn) or die(mysql_error());

//get the results of the query and print it out
while ($listinfo = mysql_fetch_array($result)) {
   echo $listinfo['name'] . " " . $listinfo['email'] . "<br>";
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/10154-question-plz/#findComment-37849
Share on other sites

another thing

ive written this code

<?php
$cat="Rock";
$result=@mysql_query("SELECT Title, Artist
FROM Stock WHERE Category='$cat'");
while ($item=@mysql_fetch_array($result))
{
extract($item);
print("<p>$Title $Artist</p>");
}
$number=@mysql_num_rows($result);
print("<p>$number matches found</p>");
?>

but how do i generate this in html when this run
Link to comment
https://forums.phpfreaks.com/topic/10154-question-plz/#findComment-38003
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.