Phsycoslaya Posted November 12, 2006 Share Posted November 12, 2006 Hello, im kinda new to the whole thing. Well not really I Got the basics. But this shouldn't be to hard..http://razrwow.game-host.org I set up the database and all that stuff I know how to do that much so I can work the admin stuff but I wanna make my own site like that cause I downloaded that whole setup I just setup the database in MySql and stuff..So first of all. I want to beable to type in this memo and make it show up on my webpage.[URL=http://imageshack.us][IMG]http://img155.imageshack.us/img155/3728/tableft8.jpg[/img][/URL]The Database is called, phpsiteThe password is Passwordthe UserName is rootthe Host name is LocalhostPlease setup a PhP thingy for me to look at so I can find out how to do it.. like..<?php echo '$memofromthemysqlthing' ?> or w/e you have to do. Just right it all out, doesnt have to be fancy just something to link the two.. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/ Share on other sites More sharing options...
bqallover Posted November 12, 2006 Share Posted November 12, 2006 This will display the contents of that field, but you'll have to specify an 'id' (from the first column) or some other clause. This should get you started though.[code]<?php // Specify the id here, or pass it in a $_POST or $_GET variable$id = 1;// Connect to the MySQL database, returning a connection link id// in $conn, or abort displaying an error message if can't connect$conn = mysql_connect('Localhost', 'root', 'Password') or die('Could not connect: ' . mysql_error());// Before running any queries, we must select the database to use// or abort if we can'tmysql_select_db('phpsite', $conn) or die('Could not select database');// Next, select only the 'body' field from the table 'notes' for// the row with the given id. This data is then stored in $result// which can be accessed with functions below$sql = "SELECT body FROM notes WHERE id=$id";$result = mysql_query($sql) or die (mysql_error());// Next fetch the returned row as an array with key-names that// correspond to the field names of the table$row = mysql_fetch_array($result, MYSQL_ASSOC);// Display the contents of the field 'body'echo $row['body'];// Free up MySQL resourcesmysql_free_result($result);mysql_close($conn);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123411 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 WAnna explain what each command does so I can get it stuck in my head =P? Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123412 Share on other sites More sharing options...
bqallover Posted November 12, 2006 Share Posted November 12, 2006 I've edited the code and added comments. Also, you might want to look at [url=http://uk.php.net/manual/en/ref.mysql.php]the MySQL section[/url] from the PHP manual, and if you're not familiar with SQL, you can check out some tutorials on this site or do a google.HTH :) Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123421 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 Thank you ooooo so much! Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123422 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 Hm howcome the title doesnt wanna show?I typed this [code]<?php$id = 1;$conn = mysql_connect('Localhost', 'root', 'password')or die('Could not connect: ' . mysql_error());mysql_select_db('phpsite', $conn) or die('Could not select database');$sql = "SELECT body FROM notes WHERE id=$id";$sqll = "SELECT title FROM notes WHERE id=$id";$resultt = mysql_query($sqll) or die(mysql_error());$result = mysql_query($sql) or die(mysql_error());$row = mysql_fetch_array($result, MYSQL_ASSOC);$roww = mysql_fetch_array($result, MYSQL_ASSOC);echo $row['body'];echo $roww['title'];mysql_free_result($result);mysql_close($conn);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123424 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 NVRMIND! I got it, had a typo. once again thanks muchly ill shutup now =P Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123426 Share on other sites More sharing options...
bqallover Posted November 12, 2006 Share Posted November 12, 2006 No worries.BTW, instead of [code]$sql = "SELECT body FROM notes WHERE id=$id";$sqll = "SELECT title FROM notes WHERE id=$id";$resultt = mysql_query($sqll) or die(mysql_error());$result = mysql_query($sql) or die(mysql_error());$row = mysql_fetch_array($result, MYSQL_ASSOC);$roww = mysql_fetch_array($result, MYSQL_ASSOC);echo $row['body'];echo $roww['title'];[/code]you could just have[code]$sql = "SELECT body, title FROM notes WHERE id=$id";$result = mysql_query($sql) or die(mysql_error());$row = mysql_fetch_array($result, MYSQL_ASSOC);echo $row['body'];echo $row['title'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123430 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 Fixed it was missing a = Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123437 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 Can anybody link me a tutorial, on how to add an Edit / New / Delete button onto it and stuff.. I wanna get technical. Thanks hope to see your reply.*To be more specific* I want it so I can click edit to edit a news thing or w/eor clikc New to make a new news paragraphor click Delete to delete that news thingy. Help. Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123443 Share on other sites More sharing options...
Phsycoslaya Posted November 12, 2006 Author Share Posted November 12, 2006 Can anybody link me a tutorial, on how to add an Edit / New / Delete button onto it and stuff.. I wanna get technical. Thanks hope to see your reply.*To be more specific*I want it so I can click edit to edit a news thing or w/eor clikc New to make a new news paragraphor click Delete to delete that news thingy. Help. Quote Link to comment https://forums.phpfreaks.com/topic/26992-mysql-memo-to-webpage/#findComment-123494 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.