ger_mac74 Posted March 6, 2006 Share Posted March 6, 2006 Hi i am new to php.Can anyone help me finish off this? Here is what I have put together so far. When someone clicks on say the '10th century articles' link my webpage I want to connect to the database and then grab whatever articles are from the tenth century. The database will have a column called century and in this column I will have tenth, eleventh and so on...depending on what century the article url is about.<html><head><title>List of articles</title></head><body><h1>List of articles about 10th Century</h1><?php$db = mysql_connect(“localhost”, “username”, “password”);mysql_select_db(“databasename”, $db);/// How do I use $_GET method to check if the century in my table states for example“tenth” or “eleventh” /// etc.$result = mysql_query(“SELECT * FROM SELECT `articles` WHERE `century` = '".$_GET['century'],"databasename");?><table rules=all><thead><tr><th>Column1</th><th>Column2</th><th>Column3</th></tr></thead><tbody><?phpWhile ($myrow = mysql_fetch_row($result)){printf (“<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n,$myrow[0], $myrow[1], $myrow[2]);?></tbody><.table></body></html>On my main page I have an <a href="index.php?century=tenth">10 Century Articles</a> I have been told I need to name link like this. Can you explain why? Basically what I want to happen is as follows:Someone visits my page. Click on a link called 'view all articiles that are about the tenth century'. The site will connect to database. select all tenth century articles and then display on website. It will, for example, display in 3 columns ...one for article name one for article url and one for whatever. These columns will also be in database.Maybe someone could help me out with a snippet of code that I may have wrong or am missing??Thanks in advance... Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 7, 2006 Share Posted March 7, 2006 Try this:[code]<html><head><title>List of articles</title></head><body><h1>List of articles about 10th Century</h1><?php$db = mysql_connect(“localhost”, “username”, “password”);mysql_select_db(“databasename”, $db);/// How do I use $_GET method to check if the century in my table states for example“tenth” or “eleventh” /// etc.$century=$_GET['century'];$result = mysql_query(“SELECT * FROM `articles` WHERE `century` = '$century'");?><table rules=all><thead><tr><th>Column1</th><th>Column2</th><th>Column3</th></tr></thead><tbody><?phpWhile ($myrow = mysql_fetch_row($result)){printf (“<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n,$myrow[0], $myrow[1], $myrow[2]);?></tbody><.table></body></html>[/code]Think that should do the job your looking for :) Quote Link to comment 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.