Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-10-2009, 05:11 PM   #1 (permalink)
 
Newb Techie

Join Date: Mar 2009

Location: San Marcos CA

Posts: 15

Hereisfun is on a distinguished road

Send a message via AIM to Hereisfun
Default PHP MySql help :]

Uhmmm I want to make a comment system thing...
I have the form and then the INSERT thing right
So i can insert stuff into my database from my form but i dont know how to get the info from my database and onto the place where i want the comments to be shown, so everyone can see them...
If anyone could help, that would be awesome
If you need the codes to see i can post on here
Hereisfun is offline  
Old 04-10-2009, 07:58 PM   #2 (permalink)
 

Join Date: Jul 2005

Location: England

Posts: 2,159

kmote has a spectacular aura aboutkmote has a spectacular aura about

Default Re: PHP MySql help :]

What are you stuck on specifically? The SQL command to use to get data back out of the database is select MySQL :: MySQL 5.1 Reference Manual :: 12.2.8 SELECT Syntax.
__________________
MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11


There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
kmote is offline  
Old 04-10-2009, 08:54 PM   #3 (permalink)
 
Newb Techie

Join Date: Mar 2009

Location: San Marcos CA

Posts: 15

Hereisfun is on a distinguished road

Send a message via AIM to Hereisfun
Default Re: PHP MySql help :]

Well selecting the database is fine, but right now i have it so you can enter information into my database via a form. I want to take that data that was inserted into my database and have it posted right under the form. The book i bought told me how to use INSERT INTO and SELECT but then skipped the part i needed...

...It's hard for me to explain it..uhggg
Sorta like when i click post right here, it goes into the database and then onto the forum.
Mine just gets added into the database...
If you want to see what i mean go to :

Comment
Hereisfun is offline  
Old 04-10-2009, 09:12 PM   #4 (permalink)
 

Join Date: Jul 2005

Location: England

Posts: 2,159

kmote has a spectacular aura aboutkmote has a spectacular aura about

Default Re: PHP MySql help :]

Post the code.
__________________
MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11


There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
kmote is offline  
Old 04-10-2009, 09:20 PM   #5 (permalink)
 
Newb Techie

Join Date: Mar 2009

Location: San Marcos CA

Posts: 15

Hereisfun is on a distinguished road

Send a message via AIM to Hereisfun
Default Re: PHP MySql help :]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Comment</title>
<style type="text/css">
<!--
body {
background-image: url(Http://www.hereisfun.com/images/backgroundfun.jpg);
background-repeat: repeat;
}
-->
</style>
</head>

<body>

<table width="200" height="500" border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td><font color="#FFFFFF"><form method="post" action="maybe.php">
<label for="firstname">First Name:</label>
<input type="text" id="firstname" name="firstname" /><br />
<label for="lastname">Last Name:</label>
<input type="text" id="lastname" name="lastname" /><br />
<label for="email">email:</label><br />
<input type="text" id="email" name="email" /><br />
<label for ="comment">Comment: </label>
<input name="comment" type="text" id="comment" value="" /><br />
<input type="submit" value="Enter Comment" name="submit" />
</form></font>
</td>
</tr>
</table>


</body>
</html>

And here is my other page that the form goes to
<html>
<head>
<title> Thank you for entering your comment. </title>
</head>
<body>

<?php

$firstname = $_POST[ 'firstname' ];

$lastname = $_POST[ 'lastname' ];

$email = $_POST[ 'email' ];

$comment = $_POST[ 'comment' ];

$dbc = mysqli_connect('databaselocation', 'mysql username', 'mysq password', 'database')
or die('Error connectiong to MYSQL server.');

$query = "INSERT INTO cmmnts (first_name, last_name, email, cmmnt) " .
"VALUES ('$firstname', '$lastname', '$email', '$comment')";

$result = mysqli_query($dbc, $query) or die('Error querying database.');
mysqli_close($dbc);
echo 'Thanks for submitting the form into the database!<br />';
echo ' ' . $firstname;
echo ' ' . $lastname . '<br />';
echo 'Email: ' . $email . '<br />';
echo 'Comment: ' . $comment . '<br />';
?>
<p><a href="form.php"> Post another comment. </a></p>

</body>


All of this works it just puts the stuff into the database
it doesnt put it on my site :/
i changed to password and database location and stuff but im 100% they work
Hereisfun is offline  
Old 04-10-2009, 10:05 PM   #6 (permalink)
 

Join Date: Jul 2005

Location: England

Posts: 2,159

kmote has a spectacular aura aboutkmote has a spectacular aura about

Default Re: PHP MySql help :]

Quote:
Originally Posted by Hereisfun View Post
All of this works it just puts the stuff into the database
it doesnt put it on my site :/
Well lets see the page that displays the data from the database.
__________________
MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11


There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
kmote is offline  
Old 04-10-2009, 10:37 PM   #7 (permalink)
 
Newb Techie

Join Date: Mar 2009

Location: San Marcos CA

Posts: 15

Hereisfun is on a distinguished road

Send a message via AIM to Hereisfun
Default Re: PHP MySql help :]

Ahh yesh thats what iwant
iwnt the data to be posted on my website
what people comment


uhmmm heres the link

hereisfun.com/form.php

i want the comments to be posted under that form
if you just type in junk and look at what the next page says thank you it was inserted into the database

when i view the database
i can see my columns in the table i made
and then the inserts which the form has inserted from people filling it out
Hereisfun is offline  
Old 04-11-2009, 07:12 PM   #8 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: PHP MySql help :]

PHP Code:
<?php

$dbc 
mysqli_connect('databaselocation''mysql username''mysq password''database')
or die(
'Error connectiong to MYSQL server.');

$sql mysqli_query($dbc"SELECT * FROM cmmnts");

while (
$row mysqli_fetch_array($sqlMYSQLI_ASSOC)) {
    echo 
'First Name: '.$row['first_name'].'<br />
          Last Name: '
.$row['last_name'].'<br />
          Email: '
.$row['email'].'<br />
          Comment: '
.$row['cmmnt'].'<br /><br />';
}

?>
I'm not 100% sure if this will work, because I never use mysqli...but try it.
__________________

Need website help? PM me!
CrazeD is offline  
Old 04-12-2009, 12:17 AM   #9 (permalink)
 
Newb Techie

Join Date: Mar 2009

Location: San Marcos CA

Posts: 15

Hereisfun is on a distinguished road

Send a message via AIM to Hereisfun
Default Re: PHP MySql help :]

Kmote: Thank you for helping me :]
CrazeD: Man your a genius! Code worked! Second time you helped me out!!! If theres anything i can do for you don't hesitate to ask! If there is anything i can do for you...lol
Hereisfun is offline  
 
Closed Thread

Thread Tools
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
A Guide to Installing Apache, PHP, MySQL, and PHPMyAdmin on Windows CrazeD Programming Discussions 17 06-17-2009 04:27 PM
PHP - what it does and what it doesn’t Osiris Programming Discussions 1 02-16-2009 04:09 PM
connecting mysql database with php linux1880 Programming Discussions 5 04-27-2008 08:41 AM
Calling all PHP and MySql experts murdocsvan Programming Discussions 4 04-17-2008 01:51 PM
New Site Project - Flash + PHP + MySQL + CSS theone_trent Web Graphics, Design, Digital Images 2 06-30-2007 01:12 PM