homepage Welcome to WebmasterWorld Guest from 54.196.62.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How to create a link out of document "Titles"?
Senmar50




msg:1293544
 1:44 am on Oct 11, 2004 (gmt 0)

Hi Dreamcatcher,

Thanks for the great advice. I have another question. How would I turn the titles of my database news articles into links. I would like for the visitor to click the title, and be taken to the actual page the article is located? Can that be done?

Thanks in Advance,
Senmar

(insert.php script)
<?php
// connect to the mysql server
mysql_connect("localhost","moot","ok") or die (mysql_error());
echo "Connected to Mysql<br/>";

// select the database
mysql_select_db("News_Articles") or die
(mysql_error());
echo "Connected to Database<br/>";

// insert data into ccds_news table
$sql = "INSERT INTO ccds_news(article_title, author_name, subject, date_created, content, EMAIL) VALUES('" . $_POST['article_title'] . "', '" . $_POST['author_name'] . "', '" . $_POST['subject'] . "', '" . $_POST['date_created'] . "', '" . $_POST['content'] . "', '" . $_POST['EMAIL'] . "' )";

// run the query
mysql_query($sql);
echo "DATA ENTERED!";

?>

 

eggy ricardo




msg:1293545
 6:27 am on Oct 11, 2004 (gmt 0)

Hi Senmar,

I'm not quite sure what you're trying to do (it's early in the morning so i'm not quite with it). Perhaps you could tell us what pages these articles are displayed on, or is that what you are asking about?

Cheers
Richard

mincklerstraat




msg:1293546
 7:48 am on Oct 11, 2004 (gmt 0)

Obviously, you'll need echo and some knowledge of variables or arrays. Then, look at the 'parameters' your script is making in the urls - ht*p://mysite.com/index.php?this=whatever&that=whatever - parameters here being 'this' and 'that' - these produce elements of the array $_GET on the page that the link goes to - you'll want to figure out how to 'echo' out links that look like this with the proper parameters. If you don't have a link structure like this, you'll have to figure out what your link structure is, and produce url's according to that.

The php.net tutorial has a page on forms at [be2.php.net...] and you might want to get a book on paper too.

Happy coding!

dreamcatcher




msg:1293547
 8:54 am on Oct 11, 2004 (gmt 0)

Like mincklerstraat mentions, you`ll need to look into arrays and query strings. When you pull your data, you`ll need to loop through the entries and assign the article ID to a query string, ie: www.yoursite.com/articles.php?id=ID. Use mysql_fetch_array() to loop the entries.

When any link is clicked, you simply pull data based on the value of 'id' in the query string.

if (isset($_GET['id']))
{
$query = "SELECT FROM table WHERE id = '" . $_GET['id'] . "' LIMIT 1";
//rest of code
}

I would suggest you follow the link that mincklerstraat has posted, it should point you in the right direction.

jamie




msg:1293548
 9:27 am on Oct 11, 2004 (gmt 0)

hi senmar,

are you talking about links like this:

www.mysite.com/news/freddie-star-ate-my-hamster.htm

for a story with the title: "freddie star ate my hamster"?

you need to google for 'search engine friendly URLs'. this article by sitepoint is a great starter: [sitepoint.com...] (although it might not work unless you have register_globals on in your php setting.) have a read and come back with questions.

good luck

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved