Reply
Showing SQL Data on a Website
Old 07-15-2007, 09:27 AM Showing SQL Data on a Website
Junior Talker

Posts: 3
Name: Carys
Location: wales
Hi there

Me and my other half have a website for our game server...we would like to show stats that relate to the game that are stored on a SQL database on the website...any help would be appreciated

Thanks
ickle is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-18-2007, 01:46 AM Re: Showing SQL Data on a Website
Skilled Talker

Latest Blog Post:
Care for some Java?
Posts: 59
I am still a novice so I'm not 100% sure but I believe you can do that with PHP.
einsteinsboi is offline
Reply With Quote
View Public Profile
 
Old 07-18-2007, 08:20 AM Re: Showing SQL Data on a Website
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
How do you collect your stats, is this user input?

Ibbo
__________________
www.nationalclubgolfer.com www.sportspub.co.uk www.bespokecc.co.uk www.centralmarquees.co.uk
Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 07-18-2007, 11:16 AM Re: Showing SQL Data on a Website
Experienced Talker

Posts: 44
Yea php would work...use this (Change DB_HOST, DB_USERNAME, DB_PASSWORD, and DB_NAME to fit your specific database details.)

<?php

if (isset($_POST['submitted']))
{
if (!empty($_POST['gametitle']))
{
$gt = $_POST['gametitle'];

@mysql_connect (DB_HOST, DB_USERNAME, DB_PASSWORD) or die('Error');

@mysql_select_db (DB_NAME) or die ('Error');

$query = "SELECT column_name FROM table_name WHERE column_name='%$gt%'";

$result = @mysql_query($query);

if (mysql_num_rows($result) > 0)
{

$data = mysql_fetch_array($result, MYSQL_NUM);

foreach($data as $dbdata)
{
echo "<br><br>" . $dbdata;
}
}
else
{
echo "No results found";
}
}
else
{
echo "Please specify a game title!";
}
}

?>

<form action="" method="post">
Search game: <input type="text" name="gametitle"><br>
<input type="submit" name="submit" value="Search">
<input type="hidden" name="submitted" value="TRUE">
</form>

Last edited by JLEville : 07-18-2007 at 11:30 AM.
JLEville is offline
Reply With Quote
View Public Profile
 
Old 07-19-2007, 03:08 AM Re: Showing SQL Data on a Website
Skilled Talker

Latest Blog Post:
Care for some Java?
Posts: 59
Quote:
Originally Posted by JLEville View Post
Yea php would work...use this (Change DB_HOST, DB_USERNAME, DB_PASSWORD, and DB_NAME to fit your specific database details.)

<?php

if (isset($_POST['submitted']))
{
if (!empty($_POST['gametitle']))
{
$gt = $_POST['gametitle'];

@mysql_connect (DB_HOST, DB_USERNAME, DB_PASSWORD) or die('Error');

@mysql_select_db (DB_NAME) or die ('Error');

$query = "SELECT column_name FROM table_name WHERE column_name='%$gt%'";

$result = @mysql_query($query);

if (mysql_num_rows($result) > 0)
{

$data = mysql_fetch_array($result, MYSQL_NUM);

foreach($data as $dbdata)
{
echo "<br><br>" . $dbdata;
}
}
else
{
echo "No results found";
}
}
else
{
echo "Please specify a game title!";
}
}

?>

<form action="" method="post">
Search game: <input type="text" name="gametitle"><br>
<input type="submit" name="submit" value="Search">
<input type="hidden" name="submitted" value="TRUE">
</form>
Nice post . This will be helpful to me. I am learning PHP now so every tip helps!
einsteinsboi is offline
Reply With Quote
View Public Profile
 
Old 07-19-2007, 04:40 PM Re: Showing SQL Data on a Website
Experienced Talker

Posts: 44
Add to my talkapation man!
JLEville is offline
Reply With Quote
View Public Profile
 
Old 07-19-2007, 05:16 PM Re: Showing SQL Data on a Website
Skilled Talker

Latest Blog Post:
Care for some Java?
Posts: 59
Quote:
Originally Posted by JLEville View Post
Add to my talkapation man!
Done!! Sorry about, still new here, learning the ropes and the lingo .

It was a good post definitely worth the talkaptation!
einsteinsboi is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Showing SQL Data on a Website
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15257 seconds with 12 queries