FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Simple MySQl Web Site





Possum
Hi

Can I do this.

Create a Table that I can add rows to. These rows will be web pages. Actually I guess in this simple example I would only have one column.

When the user clicks links they will view other pages in this table..

No log on required. Its is just a normal web site.

I really need to learn this. As I think this would be a good start..

Thank you..
Marcuzzo
Possum wrote:
Hi
Actually I guess in this simple example I would only have one column.
When the user clicks links they will view other pages in this table..
No log on required. Its is just a normal web site.
I really need to learn this. As I think this would be a good start..
Thank you..


Lets say you have a table called 'Pages'
Code:
CREATE TABLE pages
(
 id int,
 title varchar(50),
 path varchar(250)
)


you insert these pages
Code:
INSERT INTO pages
( id, title, path )
VALUES
( 1, 'page 1', 'full_or_relative_path_to_page.php');

... and more


and then you could generate a menu to those pages using code that looks like this:
Code:
<?php
$con = mysql_connect($host,$user,$password);

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT title, path FROM pages");
echo "<ul>\n";
while($row = mysql_fetch_array($result))
  {
  echo '<li><a href="'. $row['path'] . '">' . $row['title'] . "</a></li>\n";
 
  }
  echo "</ul>";

mysql_close($con);
?>


All the info you need can be found on W3schools
http://www.w3schools.com/php/php_mysql_select.asp
http://www.w3schools.com/sql/default.asp
Possum
Thank you...Now I can start..

Sorry for the late reply.. Work really gets in the way of being on the internet..
jmraker
The database table would need more than one column. At the very least it would need 2. One to use as a key, and one or more to use to store values such as the page contents. It's kind of like a php array, you need use a key to get a single array value.
Related topics
Selling Sigs
QUALITY WEB SITE HOSTING
visit this web site
14 ways to add content to your web site and attract visitors
What i need make here, to make a simple Web Site??
Checking The Web Site Speed
My web site !
Hide Part of Your Web Site from Yahoo!
My frihost web site
Database on Frihost site
NEED HELP IN FLASH WEB SITE
I need a button to my web-site...
Web site idea
My Personal Web Site - especially on the Japan trip
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.