0
<div>
                    <?php
                    include 'connect.php';

                    if(isset($_GET['id'])){

                    $page_id = $_GET['id'];

                    $select_query = "SELECT * FROM articles WHERE articles_id='$page_id'";

                    $run_query = mysql_query($select_query);

                    while($row=mysql_fetch_array($run_query)){

                        $articles_id = $row['articles_id'];
                        $articles_date = $row['articles_date'];
                        $articles_title = $row['articles_title'];
                        $articles_category = $row['articles_category'];
                        $articles_image = $row['articles_image'];
                        $articles_content = $row['articles_content'];

                    ?>
                    <h3>
                    <a href="articlespage.php?id=<?php echo $articles_id; ?>">
                    <?php echo $articles_title; ?>
                    </a>
                    </h3>

                    <p><i>Published on <b><?php echo $articles_date; ?></b></i></p>

                    <center>
                    <img src="<?php echo $articles_image; ?>" width="300" height="250">
                    </center>

                    <p align="justify"><?php echo $articles_content; ?></p>

                    <hr>

                    <?php } } ?>

</div>

<div>


            <form method="post" action="articlespage.php" enctype="multipart/form-data">

                <table width="300" align="center" border="0">

                    <tr>
                        <td align="right">Name</td>
                        <td><input type="text" name="author"></td>
                    </tr>

                    <tr>
                        <td align="right">Email</td>
                        <td><input type="text" name="email"></td>
                    </tr>


                    <tr>
                        <td align="right">Comment</td>
                        <td><textarea type="text" name="content" cols="30" rows="10"></textarea></td>
                    </tr>

                    <tr>
                        <td align="center" colspan="6"><input type="submit" name="submit" value="Publish Now"></td>
                    </tr>

                </table>
            </form>


            <?php
            include 'connect.php';
            if (isset($_POST['submit'])){


            // my problem is
            // i cannot get the article_id to store it on com_art_id,
            // the articles_id is already showing on url bar
            // i have no idea how to place it on com_art_id





            ////     $com_art_id = $articles_id;
                 $comment_date = date('d-m-y');
                 $comment_name = $_POST['author'];
                 $comment_email = $_POST['email'];
                 $comment_content = $_POST['content'];

                if ($comment_name=='' or $comment_email=='' or $comment_content==''){

                    echo '<center><b><font color="red">All fields are required.</font></b></center>';

                }else{

                    $insert_query = "INSERT INTO comments(com_art_id, comment_date, comment_name, 
                    comment_email, comment_content) 
                    VALUES('$com_art_id', '$comment_date', '$comment_name', '$comment_email', '$comment_content')";

                    if(mysql_query($insert_query)){

                        //echo "<center>Submitted sucessfully.</center>";
                        header("Location: articlespage.php?");
                    }

                }



            }
            ?>

</div>

Edited by 2mhzbrain

3
Contributors
9
Replies
44
Views
3 Years
Discussion Span
Last Post by 2mhzbrain
0

Can you provide more information? how is anyone supposed to figure out what to do with the title and code you provided?

A more detailed description of the problem, what you are trying to accomplish, etc.. will likely get you more help.

0

sorry, i included it on comment, my problem is i cannot get the article_id to store it on com_art_id, the articles_id is already showing on url bar, i have no idea how to place it on com_art_id, can i use GET function? show me how to do it, im realy new at php

Edited by 2mhzbrain

1

Ok, i see it in your code as commented...

Refer to this page in the online PHP manual: http://www.php.net/manual/en/reserved.variables.get.php

If you want to get the query string, use $_GET

Say your URL is articlespage.php?id=1, your code to get that query string parameter called "id" would be... $_GET["id"]

Therefore... $com_art_id = $_GET["id"]; should work.

You should consider performing some check(s) prior to assuming that the value in the query string is going to be a value you expect.

Edited by JorgeM

0
$com_art_id = $_GET["id"];

this doesnt work, also please tell me why year is always wrong and all months and days are 1-14, it always saved 0 as com_art_id

Edited by 2mhzbrain

Attachments Untitled.jpg 62.29 KB
0
$comment_date = date('Y-m-d');

this solved the date, i still cant put article_id as the value of com_art_id

0

how to place article id on a user comment so that if user submitted the comment, it will have the article id, then we can show all comments for specific article

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.