Jump to content

articles


xristos86

Recommended Posts

Hello, i'm new in php and i need some help with my site. i'm try to create an article site something like a newspaper.

a user can post edit or delete an article.

So i have a problem on edit section!

 

i want to add an "edit article" button on an article but i don't know how to retrieve  this article from the database.

 

this is the code where the user can see all the availiable articles to edit.

 

...

foreach($articles as $value){

echo '<div class="article_container">';

echo '<h5>'.$value['title'].'<h5>';

echo '<hr>';

echo '<h5>'.$value['date'].'</h5>';

echo '<h5>'.$value['publisher'].'</h5>';

echo '<h5>'.'Article: '.$value['articleid'].'</h5>';

echo '<h5>'.$value['articleid'].'<h5>';

        echo '</div>;

....

and i dont know how to store the "articleid" so i can mke the query on database on an other page

can someone help me?

 

Link to comment
Share on other sites

to store the article id, use a session variable, like this:

$_SESSION['article_id'] = 12345;

That variable will be available on all your pages as long as you make sure you have session_start(); at the beginning of each .php file.

 

to retrieve stuff from the database, you need to connect to it first, select the database, choose the fields you want to pull out and from which table, then grab the results. check out these functions on php.net:

mysql_connect();
mysql_select_db();
mysql_query();
mysql_close(); 

 

hope that helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.