sorry if i sound like a newb the truth is i am.
database help
Moderator: General Moderators
database help
How do i make it so a page will go into a mysql table thingo. like http://www.phpcomplete.com/content.php?id=10 <-- how do you make it so a page is assosciated with a table id? or do i have to make a page in php and make it include the information i want? this must be easier than making 50 html pages or no one would do it.
sorry if i sound like a newb the truth is i am.
sorry if i sound like a newb the truth is i am.
You would have a mySQL table with a few rows such as id, content, title, date etc and then you would have a page template with a header and footer, then in the middle you would have code maybe like this:
Code: Select all
<?php
include "header";
$db = mysql_connect("localhost","username","Password");
mysql_select_db("database");
$result = mysql_query("SELECT * FROM content WHERE id = '". $_GETї'id']."'");
if(mysql_num_rows($result) != 1) echo "Page not found.";
else
{
$page = mysql_fetch_array($result);
echo "<h1>".pageї'title']."</h1>";
echo "<p>".pageї'content']."</p>";
}
include "footer";
?>when i use your code i get this error.
Parse error: parse error, expecting `','' or `';'' in /home/sites/site22/web/php2/index.php on line 10
then when i took out the html "<h1>" etc. all i got was.
.page['title'].
.page['content'].
can you tell me if i have configured something wrong?
i got the footer and header thing done aswell thanks.
Parse error: parse error, expecting `','' or `';'' in /home/sites/site22/web/php2/index.php on line 10
then when i took out the html "<h1>" etc. all i got was.
.page['title'].
.page['content'].
can you tell me if i have configured something wrong?
i got the footer and header thing done aswell thanks.
Code: Select all
echo "<h1>".pageї'title']."</h1>";
echo "<p>".pageї'content']."</p>";Code: Select all
echo "<h1>".$pageї'title']."</h1>";
echo "<p>".$pageї'content']."</p>";k thanks for your help. 
can you suggest a tutoral where it explains how to totally setup the ?id=1 thingo. I have gotten it working now but i just want to make the main page. when you just go to the main page you get "Page not found" im trying to make it say. all the titles in the table and links to there id numbers. But i still want it to say page not found when they come accross a not used id number. If thats possible
can you suggest a tutoral where it explains how to totally setup the ?id=1 thingo. I have gotten it working now but i just want to make the main page. when you just go to the main page you get "Page not found" im trying to make it say. all the titles in the table and links to there id numbers. But i still want it to say page not found when they come accross a not used id number. If thats possible