Niloofar24 15 Posting Whiz

Thank you @Aeonix. Could you help me a little more?

When i delete line 24, the value for OS will be echo as Linux.
And if i put it back, the value will be echo as ubuntu.
I want the script to echo bout of them, LInux, Ubuntu.
How can i edit it?

Users may use different linux: arch, ubuntu, fedora and..... I want the script to echo that information.

Niloofar24 15 Posting Whiz

Hi.
With $u_agent = $_SERVER['HTTP_USER_AGENT']; i can get the users information but i just want to echo the OS that users use, something like:

Linux,Ubuntu

How can i get this out from the $u_agent variable?

Niloofar24 15 Posting Whiz

This is my code.
How can i hide it by css or js first?

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<style>
body{
margin: 0;
}
/***************************************************************/

@font-face {
    font-family: 'secondFont';
    src: url('DancingScript-Regular.otf');
}

h2 {
font-family: 'secondFont', sans-serif;
font-size: 20px;
}

/***************************************************************/

.nav {
float: left;
margin-top: 5px; /* Added to dont overlap result box */
width: 100px;
height: 70px;
text-align: center;
background-color: #C2FFC2;
border-radius: 20px;
border: 2px dotted #C2FFC2;
}

.text {
overflow: hidden;
float: left;
margin: 5px;
padding: 5px;
width: 400px;
border-radius: 20px;
border-top: 2px dotted #C2FFC2;
border-bottom: 2px dotted #C2FFC2;
}

.text > p {
font-family: 'secondFont', sans-serif;
font-size: 20px;
margin-left: 10px;
}

#js-greenbox1 {
position: absolute;
z-index: 2;
width: 600px;
margin-top: 30px;
}
</style>
</head>
<body>
<!-- ************************************************************* --->

<div id="js-greenbox1">
    <div class="nav"><h2>greeting</h2></div>
    <div class="text">
    <p>Welcome guest!</p>
    </div>
</div>

<!-- ************************************************************* --->

<script>
$(function(){
    $('.nav').click(function() {
        $('.text p').css({
            'width': $('.text p').width(),
            'height': $('.text p').height()
        });
        $('.text').animate({'width': 'toggle'});
    });
});
</script>

</body>
</html>
Niloofar24 15 Posting Whiz

Hello.
There is a button in the page when i click it, a div will appear or disappear by toggling to the left and right.
I want when the page loaded, user can only see the button and have to click to appear the dive.
But the problem is that when the page loads, the dive is appeared on the page and user doesn't have to click the button to see the content of the hidden div.
What can i do for that?
I want the div to stay hidden till user click the button to make it appear, not be appeared by default!

Niloofar24 15 Posting Whiz

Hello friends:)

I have put this in my script to echo the current date and time:

<?php
    print strftime('%c');
?>

And with this code:

<?php
    $p = $_SERVER['PHP_SELF'];
    $sec = "0.01";
    header("Refresh: $sec; url=$p");
?>

tried to refresh the page in order to show a real clock, i mean a clock wich works well with no problem.
But the script refresh the page very fast without stopping and it doesn't sound good, for example the red circle on the tab that is orbiting so fast with unpleasent pusses because of loading, that's not good. Is there any other way to fix it?

Niloofar24 15 Posting Whiz

I replaced alert('test'); with those 2 lines and a message box with the text "test" appears. So without those 2 files you can't help me with that, well i don't know what to do.

I just downloaded and installed everything but this command on the terminal:
npm install bootbox
And after that place bootstrap.min.js and bootbox.min.js files on the same directory as the html file and next just copied and pasted codes for the dialog box examples.

On the Bootbox.js website there was no more explanation for what to do, just said install bootbox.js with that command or download the zip file by clicking on the link.

Anyway, is there any way to find the problem and solution?!

Niloofar24 15 Posting Whiz

Yes, it works now. Thank you @stbuchok.

Niloofar24 15 Posting Whiz

Well, does it help? Here I'm not sure if it's correct, i've never been using this.
Here i can't upload those bootstrap.min.js and bootbox.min.js files there so the output is not simillar to the image i gave you you it's link.

Niloofar24 15 Posting Whiz

@stbuchok, ok. what do you mean by creating a publicly viewable page that has the issue or creating a jsfiddle? Where can i put the code for dibugging?

Niloofar24 15 Posting Whiz

Hello.
In javascript there is a jQuery slideToggle() Method that toggles up-down but i want it to toggles left-right.
I found a code from here and then i copied and pasted and edited it in this way:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>

$('.nav').click(function() {
   $('.text p').css({
      'width': $('.text p').width(),
      'height': $('.text p').height()
   });
   $('.text').animate({'width': 'toggle'});
});

</script>

<style>

body {
   font-size: 10px;
   color: #333; 
   }

.nav {
   float: right;
   margin-top: 30px; /* Added to dont overlap result box */
   width: 50px;
   height: 30px;
   text-align: center;
   background: #ccc;
   border: 1px solid #333; 
   }

.text {
   overflow: hidden;
   float: right;
   margin: 5px;
   padding: 5px;
   width: 400px;
   background: #e4e4e4;
   }

</style>
</head>

<body>
  <div class="nav">Nav</div>
  <div class="text">
     <p>
       This is the paragraph to end all paragraphs.  You
       should feel <em>lucky</em> to have seen such a paragraph in
       your life.  Congratulations!
     </p>
    </div>
</body>
</html>

But it doesn't work. The box won't be toggeled, it doesn't move at all. Where is the problem?

Niloofar24 15 Posting Whiz

No answer?! It seems this forum is not activate enough.

Niloofar24 15 Posting Whiz

I placed those 2 files in the same directory as the html page and now when i click the Alert word, i face with it: (why it appears like this?)

Look at here please

Niloofar24 15 Posting Whiz

Both bootstrap.min.js and bootbox.min.js files are in home directory. Should i place them in a cartain place?!
No there is no errors.

Niloofar24 15 Posting Whiz

Well, first of all i copied this code:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My page</title>

<!-- CSS dependencies -->
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
</head>
<body>

<p>Content here. <a class="alert" href=#>Alert!</a></p>

<!-- JS dependencies -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="bootstrap.min.js"></script>

<!-- bootbox code -->
<script src="bootbox.min.js"></script>
<script>
$(document).on("click", ".alert", function(e) {
bootbox.alert("Hello world!", function() {
console.log("Alert Callback");
});
});
</script>
</body>
</html> 

from here (in the Usage Instructions part in that page) and just pasted in a blanck file. But it didn't wok. The result was a white page with the text Content here Alert! and the "Alert!" word was underlined as a link and when i clicked, nothing changed.

Niloofar24 15 Posting Whiz

Hello.
I'm working on my own CMS. I want to use Bootbox.js which is a small JavaScript library which allows us to create programmatic dialog boxes using Bootstrap modals, without having to worry about creating, managing or removing any of the required DOM elements or JS event handlers.
And this is the website

I have downloaded installed it with via npm, by this command: npm install bootbox
But i don't know what to do after that... why when i copy and paste example codes from the website, it doesn't work? I searched the net but couldn't find the answer.

Has anyone use this library?

Would you mind guide me a little please?
Thank you

Niloofar24 15 Posting Whiz

Thank you @joshuajames.delacruz.

Thank you @lps.

Niloofar24 15 Posting Whiz

I understood. Before marking this discussion as solved, just want to ask one more question.

@joshuajames.delacruz, would you please explaine this part of code for me? Specially this part ('/^.{1,260}\b/s', $body, $match).
I read about preg_match() but didn't understand it clearly.

    $line = $body; //$row['Content']
    //from min boundery 1st char up to max boundery
    // 260 char you may change the max boundery
    if (preg_match('/^.{1,260}\b/s', $body, $match))
    {
    $line=$match[0];
    }
Niloofar24 15 Posting Whiz

I understood, but @lps, if you use the first model, it may breaks a word, am i right?! How would you solve it for yourself?
I mean if you want to set Read more for your posts, then what would you do for that? It's correct that it depends on what we like to have but even with any style you want to use, if you use the first model you may have problem with word breaking.

I'm not sure if i could point into the question that is in my mind.
What is your own solution for avoiding word breaking With using substr($row['Content'], 0, a number)?

Niloofar24 15 Posting Whiz

Thank you i finally could edit my script as well as possible and now it works well, the script will echo 3 posts in every page and will start from recent posts.

@lps do you remember this part:

    $per_page = 3;
    $pages = isset($_GET['page']) ? $_GET['page'] : 1; //default the page to page number 1
    $from = ($pages - 1) * $per_page;
    $to = $pages * $per_page;

As the 3th parameter in $output = array_slice($final_result, $from, $to); is length, not ending, so there is no need to calculate $to variable, because the $to variable is going to set how many posts should be printed in the page, so must be fixed and shouldn't change in different pages.

So i changed it into: (if ($get_pages == 0))

        $pages = 1;
        $per_page = 3;
        $from = ($pages - 1) * $per_page;

and this for else part:

         $pages = 1 + $get_pages;
         $per_page = 3;
         $from = ($pages - 1) * $per_page;

and there is this part too in the script for setting $get_pages variable:

        $get_pages = isset($_GET['page']) ? $_GET['page'] : 0;

and finally i used $per_page instead of $to:

         $output = array_slice($final_result, $from, $per_page);

Thank you alot @lps for answers, helps, guidance and for the linkes.

Thank you @coreyavis for your helps too.

Niloofar24 15 Posting Whiz

What i did finally was:

    foreach($result as $key => $row) {
                   echo "
                        <tr>
                            <td>$row[ID]
                            <td><a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a>
                            <td>$row[Author]
                            <td>" . substr($row['Content'], 0, 60) . "... <a href='/this/story'>Read More</a>
                         ";
    } 

But then i changed it into this:

    foreach($result as $key => $row) {
                   echo "
                        <tr>
                            <td>$row[ID]
                            <td><a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a>
                            <td>$row[Author]
                            <td>" . substr($row['Content'], 0, (strrpos(substr($row['Content'], 0, 60), ' '))) . "... <a href='/this/story'>Read More</a>
                         ";
    } 

Is it ok @lps or is better to use the first model?
With the first model, the text will be broken in the middel of words but with the second model, no word breaking happen.

Niloofar24 15 Posting Whiz

But @lps, what about breaking words?
Without using $string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a href="/this/story">Read More</a>'; the text breaks in the middle of words.

This is what i tested:

    // strip tags to avoid breaking any html
    $string = strip_tags($row['Content']);
    if (strlen($string) > 60) {
    // truncate string
    $stringCut = substr($string, 0, 60).'... <a href="/this/story">Read More</a>';
    // make sure it ends in a word so assassinate doesn't become ###...
    //$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a href="/this/story">Read More</a>';
    }
    echo $stringCut;

As you see i didn't use the last line of code and the result was:

ONE DOLLAR AND EIGHTY-SEVEN CENTS. THAT WAS ALL. AND SIXTY C... Read More

So without using strrpos() and strrpos($stringCut, ' ') here, how can i cut the text without breaking words? Is there any better way to use?

Niloofar24 15 Posting Whiz

@joshuajames.delacruz, would you please explain strrpos() for me?
I have read about it.
strrpos(string,find,start) please give me an example that contains the start part.

strrpos($stringCut, ' ') means that variable $stringcut holds a text, and says come backwards from the end of that text untill to find space, then cut the text exactly right there to be sure no words will be cut, and cutting will happen from the last space in the text, correct? Did i understand it correctly?
So just want an example of strrpos(string,find,start) to understand what the start parameter says.

What is the usage of strip_tags()?
We can use this:
$string = "full text";
instead of this:
$string = strip_tags($string);
What do you mean by:

to avoid breaking any html

Niloofar24 15 Posting Whiz

Well i changed it a little:

    $output = array_slice($final_result, $from, $to);

    echo "--- output:--- <br>" . $output . "<br> --- <br>";
    print_r($output);

Still didn't find how to echo the variable:

--- output:---
Array
---
Array ( [0] => Array ( [Title] => The Gift of the Magi [Author] => O. Henry ) [1] => Array ( [Title] => line break [Author] => writter ) [2] => Array ( [Title] => delete test [Author] => me ) ) 

How can i echo array index in php?

Niloofar24 15 Posting Whiz

How can i echo the value of $output variable?

        $output = array_slice($final_result, $from, $to);

        echo "--- output:--- <br>" . $output;
        print_r($output);

Line 3 doesn't echo anything and line 4 echo like this:

--- output:---
ArrayArray ( [] => Array ( [Title] => Each morning [Author] => Groucho Marx [Content] => Each morning when I open my eyes I say to myself: I, not events, have the power to make me happy or unhappy today. I can choose which it shall be. Yesterday is dead, tomorrow hasn't arrived yet. I have just one day, today, and I'm going to be happy in it. ) )

Niloofar24 15 Posting Whiz

So what can i do for my cms posts? I want it to link to actual post like what we see it wordpress.

Niloofar24 15 Posting Whiz

Hi.
I want to set read more for my cms posts.
The code i found was <?php the_content( $more_link_text , $strip_teaser ); ?> but still don't know how and where to use it.
Any suggestion?

Niloofar24 15 Posting Whiz

@lps, would you please guide me more with the array part?
How should i set data after foreach($result as $key => $row) { line in an array?

And please give me an example of how i can call for example the fifth index of that array wich is the fifth ID of posts, to set it into a variable or to echo it... i have a little problem with working array in php, thank you.

@coreyavis, i tried but it didn't work.

Niloofar24 15 Posting Whiz

Of course not @lps! I didn't copy and past your codes!
This is what i did:

    $count = 0;
    while($count < 3){
        $stmt = $conn->prepare("SELECT ID, Title, Author, Content FROM Posts WHERE ID=(:id)");
        $stmt->bindParam(':id', $last_id, PDO::PARAM_INT);
        $stmt->execute();

        $result = $stmt->fetchAll();
        foreach($result as $key => $row) {
            echo $row['Title'] . "<br>";
            $count++;
            $a--;
        }
        }

The problem backs to $a-- which must be $last_id-- and out of the Foreach loop :|

Now please look at this:

<?php

    include('connection.php');
    $error = FALSE;
    $result = FALSE;
    try {
        $row = $conn->query("SELECT MAX(id) AS last_id FROM Posts")->fetch(PDO::FETCH_OBJ);
        echo $row->last_id;
        echo "<hr>";
        $last_id = $row->last_id;




         $total = $conn->query("SELECT COUNT(id) as rows FROM Posts")
                 ->fetch(PDO::FETCH_OBJ);

        $perpage = 3;
        $posts = $total->rows;
        $pages = floor($posts / $perpage);

        $get_pages = isset($_GET['page']) ? $_GET['page'] : 0;

        $number = trim($get_pages);
        $number = filter_var($number, FILTER_VALIDATE_INT, $data);

        $prev = $number - 1;
        $next = $number + 1;





        if($get_pages == 0){
        $per_page = 3;
        $count = 0;
        while($count < $per_page){
            $stmt = $conn->prepare("SELECT ID, Title, Author, Content FROM Posts WHERE ID=(:id)");
            $stmt->bindParam(':id', $last_id, PDO::PARAM_INT);
            $stmt->execute();
            $result = $stmt->fetchAll();

            foreach($result as $key => $row) {
                echo $row['Title'] . "<br>";
                $count++;
            }
            $last_id--;
        }
        $n = $last_id;
        echo "---" . $n . "---";
        session_start();
        $_SESSION["Number"] = $n;

        }else{

        session_start();
        $a = $_SESSION["Number"];
        $per_page = 3;
        $count = 0;
        while($count < $per_page){
            $stmt = $conn->prepare("SELECT ID, Title, Author, Content FROM Posts WHERE ID=(:id)");
            $stmt->bindParam(':id', $a, PDO::PARAM_INT);
            $stmt->execute();
            $result = $stmt->fetchAll();

            foreach($result as $key => $row) {
                echo $row['Title'] . "<br>";
                $count++;
            }
            $a--; …
Niloofar24 15 Posting Whiz

@lps, i removed the else part just to check the if part but it didn't work.

I used this but why it doesn't work?!

        if($get_pages == 0){

            $sql = "SELECT TOP 3 * FROM Posts ORDER BY ID DESC";
            $result = $conn->query($sql);

            foreach($result as $key => $row) {
                echo $row['Title'] . "<br>";
                }
        }

It should works but it gives this error:

Query error:SELECT TOP 3 * FROM Posts ORDER BY ID DESC
SQLSTATE: Syntax error or access violation:  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3 * FROM Posts ORDER BY ID DESC' at line 1 

@coreyavis, how can i use LIMIT x,y in this?

$sql = "SELECT * FROM Posts ORDER BY ID DESC";

The x part sets the start point, but i have set it by ORDER BY ID DESC before.

Niloofar24 15 Posting Whiz

Well, it didn't work, nothing happend just the page try to load! And finally a blank page will be loaded.

Niloofar24 15 Posting Whiz

Anny suggestion?!

Niloofar24 15 Posting Whiz

Oh! How easy it was!!
Thank you @AleMonteiro!

Niloofar24 15 Posting Whiz

Hello friends!
I want the script when user clicks the Delete botton to delete that post, a confirm message appears and ask if the user is sure to delete that post or not, if the user clicks the cancel button, nothing happen but if clicks the ok button, then the script delete that post.
this is the main code:

<?php
include('connection.php');
try {
    $sql = "SELECT ID, Title, Author, Content FROM Posts";
    $result = $conn->query($sql);
    echo "<h4>LOGGED IN AS: " . $_SESSION["Username"] . "</h4>";
    echo "<p id='err_msg'></p>";
    echo "<table cellspacing='0' cellpadding='20' border='1px solid black' border-collapse='collapse'>";
    echo "<tr><th> POST ID </th><th> POST TITLE </th><th> POST AUTHOR </th><th> ACTION </th></tr>";
    foreach($result as $row) {
        echo "<tr class='tr'><td>" . $row['ID'] . "</td><td> <a href='single-post-page.php?post=" . $row['ID'] . "'>" . $row['Title'] . "</a> </td><td>" . $row['Author'] . "</td><td> <a id='".$row['ID']."' class='btn_dlt' href='#'> delete </a> <br> <a href='edit-page.php?post=" . $row['ID'] . "'>Edit</a></td></tr>";
    }
    echo "</table>";
} catch(PDOException $e) {
    echo "Query error:".$sql . "<br>" . $e->getMessage();
}
$conn = null;
?>



<html>
<head>
<title>admin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
    $(".btn_dlt").click(function(){
        var btn_dlt = $(this); 
        $.ajax({
            type: "POST",
            url: "./delete-action.php", 
            data: { id: btn_dlt.attr("id") } 
        }).done(function( msg ) { 
            alert(msg);
            if(msg == "Success"){  
                btn_dlt.closest('.tr').remove();
            }else{
                $('#err_msg').html(msg);  err_msg field
            }
        });
    });
});
</script>


<style>
a {
#text-decoration:none;
color:black;
}

h4 {
margin-left: 500px;
}

table {
background:#f3faf1;
}
</style>
</head>
<body>
<hr>
<a href='writing-post.php'>Write new post</a><br><br>
<a href='user-view-page.php'>Log out</a>
</body>
</html>

And the delete-action.php file:

<?php
    include('connection.php');
    try {

        $id=$_POST['id'];
        $sql = "DELETE …
Niloofar24 15 Posting Whiz

Well, the solution i found and works well: (Will post it for other members may have this problem too)

    $username = $_POST['username'];

    $sql = ("SELECT ID FROM Users WHERE Username = '$username'");
    $result = $conn->query($sql);

    foreach($result as $row) {
        $row['ID'];
        }
    if($row['ID'] == null){

        $sql = "INSERT INTO Users (Username, Password)
        VALUES ('$username', '$password')";

        $conn->exec($sql);
    }

Anyway thank you for answer!

Niloofar24 15 Posting Whiz

Hi.
I'm working on my own CMS, i want the script to echo 3 posts in every page, and want the script to echo from the recent post and back to the oldest post. I mean like this:

For example there is totaly 30 posts;

First page => posts 30-29-28
Second page => posts 27-26-25
....

This is my script:

<?php

    include('connection.php');
    $error = FALSE;
    $result = FALSE;
    try {
        $row = $conn->query("SELECT MAX(id) AS last_id FROM Posts")->fetch(PDO::FETCH_OBJ);
        echo $row->last_id;
        echo "<hr>";
        $last_id = $row->last_id;



         $total = $conn->query("SELECT COUNT(id) as rows FROM Posts")
                 ->fetch(PDO::FETCH_OBJ);

        $perpage = 3;
        $posts = $total->rows;
        $pages = floor($posts / $perpage);

        $get_pages = isset($_GET['page']) ? $_GET['page'] : 0;

        $number = trim($get_pages);
        $number = filter_var($number, FILTER_VALIDATE_INT, $data);

        $prev = $number - 1;
        $next = $number + 1;



        if($get_pages == 0){
        $b = $last_id - 3;
        for($a = $last_id ; $a > $b ; $a--){

            $stmt = $conn->prepare("SELECT ID, Title, Author, Content FROM Posts WHERE ID=(:id)");
            $stmt->bindParam(':id', $a, PDO::PARAM_INT);
            $stmt->execute();

            $result = $stmt->fetchAll();
            foreach($result as $key => $row) {
                echo $row['Title'] . "<br>";
            }
        }
        }else{
            echo $get_pages . "<br>";
            $b = ($last_id - (3 * $get_pages));
            echo $b . "<br>";
            $c = $b - 3;
            echo $c . "<br>";
            for($a = $b ; $a > $c ; $a--){
                echo $a . "<br>";
                $stmt = $conn->prepare("SELECT ID, Title, Author, Content FROM Posts WHERE ID=(:id)");
                $stmt->bindParam(':id', $a, PDO::PARAM_INT);
                $stmt->execute();

                $result = $stmt->fetchAll();
                foreach($result as $key => $row) {
                    echo $row['Title'] . "<br>";
                }

            }
        }

    } …
Niloofar24 15 Posting Whiz

Yes it works ok now, thank you @creal.

Niloofar24 15 Posting Whiz

hi:)
I want the script to check the db table to see if there is the same username as what the user has submit with the register form, then stop the script from registering, but if the user has submited a new username, then registering.
I think the script should chack db and store all usernames in Array, and then in the If part check the value of $username with all values of that Array but i don't know how to do that.
This is my script but it need to be edited:

    $username = $_POST['username'];

    $sql = ("SELECT Username FROM Users");
    $result = $conn->query($sql);

    foreach($result as $key => $row) {
        $array = array($row['Username']);
    }

    if($row['Username'] != $username) {
    include('connection.php');
    $sql = "INSERT INTO Users (Username, Password)
    VALUES ('$username', '$password')";

    $conn->exec($sql);
    }

Is this part correct?!

            $array = array($row['Username']);

How should i edit this part?

if($row['Username'] != $username) {
Niloofar24 15 Posting Whiz

I understood your explanation.
Would you please help me more by give an example?
Should i change this:
$last_id = $conn->lastInsertId();
to This?
$last_id = "SELECT MAX(ID) FROM Posts";
Or like this? Because it seems like sql syntax.

    include('connection.php');
    $sql = "SELECT MAX(ID) FROM Posts";
    $result = $conn->query($sql);
    foreach($result as $key => $row) {
        echo $row;
    }
Niloofar24 15 Posting Whiz
<?php

    include('connection.php');
    try {
        $last_id = $conn->lastInsertId();

        for($a = $last_id ; $a > 0 ; $a--){

            $stmt = $conn->prepare("SELECT ID, Title, Author, Content FROM Posts WHERE ID=(:id)");
            $stmt->bindParam(':id', $a, PDO::PARAM_INT);
            $stmt->execute();

            $result = $stmt->fetchAll();
            foreach($result as $key => $row) {
                echo $row['Title'] . "<br>";
            }
        }

    } catch(PDOException $e) {
        echo "Query error:".$sql . "<br>" . $e->getMessage();
    }

    $conn = null;
?>
Niloofar24 15 Posting Whiz

Hello!
I have a little problem with a For Loop, this is a For Loop in my script:

        $last_id = $conn->lastInsertId();

        for($a = $last_id ; $a > 0 ; $a--){
            code....
        }

But it doesn't work because of ($a = $last_id ;, the variable $a can't be set to the value of $last_id, but if set this for example ($a = 5 ; it will work.

Niloofar24 15 Posting Whiz

WOW :) I finally found where the problem comes from!
I changed this:
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
With this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
And then when i clicked delete button, the alert message pointed at that html part you asked me to delete from delete-action.php, and now when i click delete button, a popup message appears with text "Success" and the html table refresh itself at the same time, great:)

Niloofar24 15 Posting Whiz

oops! no sorry, i typed succes here in my last post wrongly, was my typing mistake. both messages were "Success", i checked again.

oh...what a complicated problem! ok, thank you for all answers.

Niloofar24 15 Posting Whiz

I did. Now when i click delete button, a popup message appears with the text "Succes" and when i click the "ok" button, the alert message disappers and a message appears above the html table with the text "Success" again, and the html table still won't refresh itself.

Niloofar24 15 Posting Whiz

sorry i didn't understand where to alert(msg); exactly.

Niloofar24 15 Posting Whiz
Niloofar24 15 Posting Whiz

So it must be this:
Click Here

Niloofar24 15 Posting Whiz

So it must be this:
Click Here

Niloofar24 15 Posting Whiz

Or you refer what I shown?

Where did you show me?
My request url was http://www.my_domain_name/cms/admin.php
Is it ok or needed to get screenshot to show?
I still didn't understand where the problem backs to.

Niloofar24 15 Posting Whiz

I know! i changed exactly those 2 parts you are pointing at them, but it didn't solve the problem. I changed them correctly but they didn't work well.
I soved it by using <?php echo str_replace("<br />","",$row['Content']); ?>.

Niloofar24 15 Posting Whiz

Well F12->network, after that i clicked the button and 2 rows appears, the type of first row was html and for the second row was js. On the right column the request url was admin.php .

Click on that and view the response tab. Is it totally the words "Success" only? or it havig other echo?

There is a menu bove that right column which the request url was written there, on the menu the forth icon is Response. Is it the response tab you pointed to?