/    Sign up×
Community /Pin to ProfileBookmark

MySQL read help?

how can I read some data that I have in a mysql database and table? And output it on the screen?

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@HHCOwnerJul 27.2009 — You can use this ...

[code=php]
<?

include "../connect.php";

$sql="SELECT * FROM whatever WHERE whatever='whatever'";
$result=mysql_query($sql,$conn);

$data=mysql_fetch_assoc($result);

if (mysql_num_rows($result) > 0 ) {
echo "{$data['NAME OF COLUMN 1']} {$data['NAME OF COLUMN 2']} {$data['NAME OF COLUMN 3']}";
} else {
echo "Sorry, We couldn't find anything.";
}

?>
[/code]


Hope this helps. ?
Copy linkTweet thisAlerts:
@MindzaiJul 27.2009 — You should also read up on SQL Injection and XSS before you use a database on a public site.
Copy linkTweet thisAlerts:
@DanielDudeauthorJul 27.2009 — You can use this ...

[code=php]
<?

include "../connect.php";

$sql="SELECT * FROM whatever WHERE whatever='whatever'";
$result=mysql_query($sql,$conn);

$data=mysql_fetch_assoc($result);

if (mysql_num_rows($result) > 0 ) {
echo "{$data['NAME OF COLUMN 1']} {$data['NAME OF COLUMN 2']} {$data['NAME OF COLUMN 3']}";
} else {
echo "Sorry, We couldn't find anything.";
}

?>
[/code]


Hope this helps. ?[/QUOTE]


It just displays 1 or 0....?

I wan't it to display the data in the column...
Copy linkTweet thisAlerts:
@vonshavingcreamJul 27.2009 — i would recommend reading this tutorial.

http://www.phpfreaks.com/tutorial/php-basic-database-handling

moderators .. this link does go to another "forum" type site. If this is not allowed, please forgive me and delete the post accordingly.

Thanks

-V
Copy linkTweet thisAlerts:
@HHCOwnerJul 27.2009 — Just out of curiosity, what exactly are you trying to display?
Copy linkTweet thisAlerts:
@criterion9Jul 27.2009 — I'm thinking a basic tutorial may help best...

http://www.freewebmasterhelp.com/tutorials/phpmysql
Copy linkTweet thisAlerts:
@DanielDudeauthorJul 27.2009 — Just out of curiosity, what exactly are you trying to display?[/QUOTE]

game stats
×

Success!

Help @DanielDude spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...