≡
×
Plus
Manual
Examples
Reference
Download
Blog
Community
Support
sql database
sql database
szafar
Posts: 12
Questions: 2
Answers: 0
April 2014
edited April 2014
in
General
how can i load data from sql database for a field
Replies
Rawland_Hustle
Posts: 94
Questions: 16
Answers: 0
April 2014
I'm a total noob and I don't know if this is right for you. This is how I did it though.
I use the code below which I found. Replace "hidden" and "country", "city" and "population" with your information.
[code]
<?php
$dbhost = 'hidden';
$dbuser = 'hidden';
$dbpass = 'hidden';
$dbname = 'hidden';
// Create connection
$con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
$result = mysqli_query($con,"SELECT * FROM world");
echo "
Column1
Column2
Column3
";
while($row = mysqli_fetch_array($result))
{
echo "";
echo "" . $row['country'] . "";
echo "" . $row['city'] . "";
echo "" . $row['population'] . "";
echo "";
}
echo "";
mysqli_close($con);
?>
[/code]
This discussion has been closed.
Replies
I use the code below which I found. Replace "hidden" and "country", "city" and "population" with your information.
[code]
<?php
$dbhost = 'hidden';
$dbuser = 'hidden';
$dbpass = 'hidden';
$dbname = 'hidden';
// Create connection
$con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
$result = mysqli_query($con,"SELECT * FROM world");
echo "
Column1
Column2
Column3
";
while($row = mysqli_fetch_array($result))
{
echo "";
echo "" . $row['country'] . "";
echo "" . $row['city'] . "";
echo "" . $row['population'] . "";
echo "";
}
echo "";
mysqli_close($con);
?>
[/code]