xristos86 Posted June 8, 2011 Share Posted June 8, 2011 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? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 8, 2011 Share Posted June 8, 2011 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. Quote Link to comment Share on other sites More sharing options...
xristos86 Posted June 9, 2011 Author Share Posted June 9, 2011 yeah i have to read more about sessions! thank you for the replay Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 9, 2011 Share Posted June 9, 2011 there's nothing to it. Store stuff in session, retrieve stuff from session. keep session_start(); at the beginning of each file and you should be ok. 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.