Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 544701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:41:00+00:00 2026-05-13T10:41:00+00:00

I am trying to send an extra $php_var with jQuery to an Ajax post

  • 0

I am trying to send an extra $php_var with jQuery to an Ajax post function.
In the 1st $.ajax I have:

    $('.ui-icon-closethick').click(function(e) {
    e.preventDefault();
    var parent = $(this).parent().parent();
    $.ajax({
        type: "POST",
        url: "server_items_reorder.php",
        data: 'id=' + parent.attr('id'),

        success: function() {
            parent.slideUp(300,function() {
                parent.remove();
            });
        }
    });
});

The data: 'id=' + parent.attr('id') needs a extra $php_var sent to the URL: server_items_reorder.php

A little further down in my code I have:

function savelayout(){
var positions = "";
var weight = 0;
var wb_name = "$wb_name";
$(".portlet").each(function(){weight++;positions+=(this.id + "=" + this.parentNode.id + "|" + weight + "&");});

$.ajax({
type: "POST",
url: "server_items_reorder.php",
data: positions
});
}

As you can see, I already tried there to add a $var called wb_name.

Full code here:

/************************************************************************/
/* WB_BlocksManager v1.0                                                */
/* Module for phpnuke 6.x and 7.x by Paulo FERREIRA                     */
/* Copyright (C) 2003 Paulo Ferreira                                    */
/* Web:   http://www.phpnuke-belgique.org/                              */
/* Email: webmaster@phpnuke-belgique.org                                */
/* =====================================================================*/
/* James Johnston                                                       */
/* http://www.techknowpro.com                                           */
/* =====================================================================*/
/* nono                                                                 */
/* http://osc2nuke.org/                                                 */
/* =====================================================================*/
/* PHP-NUKE: Web Portal System                                          */
/* =====================================================================*/
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (!defined('ADMIN_FILE')) {
    die('Access Denied');
}
global $prefix, $db, $admin_file, $wb_name;
$aid = substr($aid, 0, 25);
$row = $db->sql_fetchrow($db->sql_query('SELECT radminsuper FROM ' . $prefix . '_authors WHERE aid=\'' . $aid . '\''));
if ($row['radminsuper'] == 1) {

/*********************************************************/
/* Blocks_Manager Functions                              */
/*********************************************************/

function BlocksManager($wb_name) {
    global $db, $prefix, $currentlang, $multilingual, $bgcolor2, $admin_file;
    OpenHeader(_BLOCKMGR);
    $wb_url="".$admin_file.".php?op=BlocksManager&wb_name=";
    echo "<center><form action=\"".$admin_file.".php\" method=\"post\">\n"
        ._BLOCKMGR_MODULEDROP."&nbsp;<select name=\"wb_name\" size=\"1\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">\n";
    if (!isset($wb_name)) { $wb_name = "admin"; }
    echo "<option value=\"".$wb_url."admin\""; if ($wb_name=="admin") { echo " selected"; } echo ">Admin</option>\n";
    $result = $db->sql_query("SELECT mid, title, custom_title, active, view, inmenu FROM ".$prefix."_modules WHERE active=1 ORDER BY title ASC");
    while(list($mid, $title, $custom_title, $active, $view, $inmenu) = $db->sql_fetchrow($result)) {
        echo "<option value=\"".$wb_url.$title."\""; if ($wb_name==$title) { echo " selected"; } echo ">$custom_title</option>\n";
        if (!isset($wb_name)) { $wb_name = $title; }
    }
    echo "</select>\n"
        ."</form>\n</center>\n";






    echo "<br /><br />";

    echo "<center><b>"._BLOCKMGR_ADDNEWBLOCK."</b></center>\n"
        ."<form name=\"BM_EDIT\" action=\"".$admin_file.".php\" method=\"post\">\n"
        ."<table width=\"80%\" align=\"center\">\n"
        ."<tr>\n";
    //List all inactive Blocks for selected module
    echo "<td align=\"center\" valign=\"top\">\n"
        ._BLOCKMGR_ACTIVE_BLOCKS."<br>\n"
        ."<select name=\"bida[]\" size=\"10\" multiple>\n";
    $sql = "SELECT bid, title FROM ".$prefix."_blocks ORDER BY title ASC";
    $result = $db->sql_query($sql);
    while (list($bid, $title) = $db->sql_fetchrow($result)) {
        $ii = 0; $wb_affiche = 1;
        while ($ii < $i) { if ($wb_tabblocks[$ii] == $bid) { $wb_affiche = 0; } $ii++; }
        if ($wb_affiche == 1) { echo "<option value=\"".$bid."\">$title</option>\n"; }
    }
    echo "</select><br>\n"
        ."<input type=\"submit\" value=\""._BLOCKMGR_ADD_BLOCK."\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Add';\">\n"
        ."</td>\n";

    //List all active Modules
    echo "<td align=\"center\" valign=\"top\">"
         .""._BLOCKMGR_MODULES."<br><select name=\"title[]\" size=\"10\" multiple>\n";
    echo "<option value=\"admin\""; if ($wb_name=="admin") { echo " selected"; } echo ">Admin</option>\n";
    $sql = "SELECT mid, title, custom_title FROM ".$prefix."_modules WHERE active=1 ORDER BY title ASC";
    $result = $db->sql_query($sql);
    while(list($mid, $title, $custom_title) = $db->sql_fetchrow($result)) {
        echo "<option value=\"$title\""; 
        if ($wb_name==$title) { echo " selected"; } 
        echo ">$custom_title</option>\n";
        if (!isset($wb_name)) { $wb_name = $title; }
    }
    echo "</select><br>"
        ."</td>\n";

    //List all active Blocks for selected module
    echo "<td align=\"center\" valign=\"top\">\n"
        ._BLOCKMGR_INACTIVE_BLOCKS."<br>\n"
        ."<select name=\"bidr[]\" size=\"10\" multiple>\n";
    $sql = "SELECT b.bid, b.title FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' ORDER BY title ASC";
    $result = $db->sql_query($sql);
    while(list($bid, $title) = $db->sql_fetchrow($result)) {
        echo "<option value=\"$bid\">$title</option>\n";
    }
    echo "</select><br>\n"
        ."<input type=\"submit\" value=\""._BLOCKMGR_REMOVE_BLOCK."\" onclick=\"document.BM_EDIT.op.value='BlocksManager_Remove';\">\n"
        ."</td>\n"
        ."</tr>\n"
        ."</table>\n"
        ."<input type=\"hidden\" name=\"wb_name\" value=\"$wb_name\">\n"
        ."<input type=\"hidden\" name=\"op\" value=\"BlocksManager_Add\">\n"
        ."</form>\n";

?>








<style type="text/css">
        body { font-size: 62.5%; }
        label, input { display:block; }
        input.text { margin-bottom:12px; width:95%; padding: .4em; }
        fieldset { padding:0; border:0; margin-top:25px; }
        h1 { font-size: 1.2em; margin: .6em 0; }
        div#users-contain {  width: 350px; margin: 20px 0; }
        div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
        div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
        .ui-button { outline: 0; margin:0; padding: .4em 1em .5em; text-decoration:none;  !important; cursor:pointer; position: relative; text-align: center; }
        .ui-dialog .ui-state-highlight, .ui-dialog .ui-state-error { padding: .3em;  }


    .column { width: 170px; float: left; padding-bottom: 100px; }
    .portlet { margin: 0 1em 1em 0; }
    .portlet-header { margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; }
    .portlet-header .ui-icon { float: right; }
    .portlet-content { padding: 0.4em; }
    .ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; }
    .ui-sortable-placeholder * { visibility: hidden; }

    </style>
    <script type="text/javascript">




$(function() {
        $(".column").sortable({
            connectWith: '.column',
            update: savelayout
        });

        $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all delete")

            .find(".portlet-header")
                .addClass("ui-widget-header ui-corner-all")
                .prepend('<span class="ui-icon ui-icon-wrench"></span>')
                .prepend('<span class="ui-icon ui-icon-plusthick"></span>')
                .prepend('<span class="ui-icon ui-icon-closethick"></span>')
            .end()
            .find(".portlet-content").toggle();

      $(".portlet-header .ui-icon-plusthick").toggle(function() {
        $(this).removeClass("ui-icon-plusthick");
        $(this).addClass("ui-icon-minusthick");
        $(this).parents(".portlet:first").find(".portlet-content").toggle();
    }, function() {
        $(this).removeClass("ui-icon-minusthick");
        $(this).addClass("ui-icon-plusthick");
        $(this).parents(".portlet:first").find(".portlet-content").toggle();
    }





    );

    $('.ui-icon-closethick').click(function(e) {
        e.preventDefault();
        var parent = $(this).parent().parent();
        $.ajax({
            type: "POST",
            url: "server_items_reorder.php",
            data: 'id=' + parent.attr('id'),

            success: function() {
                parent.slideUp(300,function() {
                    parent.remove();
                });
            }
        });
    });
    $(".column").disableSelection();
    });
    </script>

<div class="column" id="l">
<?php 
    $sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' AND m.bposition = 'l' ORDER BY weight";

$result = $db->sql_query($sql);
    while(list($bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view) = $db->sql_fetchrow($result)) {

?>
    <div class="portlet" id="<?php echo $bid; ?>">
        <div class="portlet-header" id="<?php echo $bid; ?>"><?php echo $title; ?></div>
        <div class="portlet-content"><?php echo $title . '---(' . $view . ')'; ?></div>
    </div>
<?php
}
?>  

</div>

<div class="column" id="c">
<?php  
    $sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' AND m.bposition = 'c' ORDER BY weight";

$result = $db->sql_query($sql);
    while(list($bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view) = $db->sql_fetchrow($result)) {

?>
    <div class="portlet" id="<?php echo $bid; ?>">
        <div class="portlet-header"><?php echo $title; ?></div>
        <div class="portlet-content"><?php echo $title . '---(' . $bposition . '---' . $wb_name .')'; ?></div>
    </div>
<?php
}
?>  


</div>

<div class="column" id="d">
<?php  
    $sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' AND m.bposition = 'd' ORDER BY weight";

$result = $db->sql_query($sql);
    while(list($bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view) = $db->sql_fetchrow($result)) {

?>
    <div class="portlet" id="<?php echo $bid; ?>">
        <div class="portlet-header"><?php echo $title; ?></div>
        <div class="portlet-content"><?php echo $title . '---(' . $bposition . ')'; ?></div>
    </div>
<?php
}
?>  


</div>  

<div class="column" id="r">
<?php  
    $sql = "SELECT b.bid, b.bkey, b.title, b.url, m.bposition, m.weight, b.active, b.blanguage, b.blockfile, b.view FROM ".$prefix."_blocks b, ".$prefix."_blocks_manager m WHERE b.bid=m.bid AND m.title='$wb_name' AND m.bposition = 'r' ORDER BY weight";

$result = $db->sql_query($sql);
    while(list($bid, $bkey, $title, $url, $bposition, $weight, $active, $blanguage, $blockfile, $view) = $db->sql_fetchrow($result)) {

?>
    <div class="portlet" id="<?php echo $bid; ?>">
        <div class="portlet-header"><?php echo $title; ?></div>
        <div class="portlet-content"><?php echo $title . '---(' . $bposition . ')'; ?></div>
    </div>
<?php
}
?>  


</div>  
<script type="text/javascript">
function savelayout(){
var positions = "";
var weight = 0;
var wb_name = "$wb_name";
$(".portlet").each(function(){weight++;positions+=(this.id + "=" + this.parentNode.id + "|" + weight + "&");});

$.ajax({
type: "POST",
url: "server_items_reorder.php",
data: positions
});
}
</script>


<?php   


    CloseFooter();
}

function BlocksManager_Add($bid, $title) {
    global $db, $prefix;

    foreach($title as $tKey => $tValue) {
        $sql = "SELECT MAX(weight) FROM ".$prefix."_blocks_manager WHERE title='$tValue'";
        $result = $db->sql_query($sql);
        list($weight, $bposition) = $db->sql_fetchrow($result);
        foreach($bid as $bKey => $bValue) {
            $weight++;
            $db->sql_query("INSERT INTO ".$prefix."_blocks_manager VALUES ($bValue, '$tValue', 'l', $weight)");
        }
        BlocksManager_FixWeight($tValue);
    }
}

function BlocksManager_Remove($bid, $title) {
    global $db, $prefix;

    foreach($title as $tKey => $tValue) {
        foreach($bid as $bKey => $bValue) {
            $db->sql_query("DELETE FROM ".$prefix."_blocks_manager WHERE bid='$bValue' AND title='$tValue'");
        }
        BlocksManager_FixWeight($tValue);
    }
}

function BlocksManager_FixWeight($wb_name) {
    global $db, $prefix;
    $position[] = 'l';
    $position[] = 'r';
    $position[] = 'c';
    $position[] = 'd';
    $position[] = '';
    foreach($position as $pKey => $pValue) {
        $result = $db->sql_query("SELECT bid FROM ".$prefix."_blocks_manager WHERE title='$wb_name' AND bposition='$pValue' ORDER BY weight ASC");
        $weight = 0;
        while(list($bid) = $db->sql_fetchrow($result)) {
            $weight++;
            if ($pValue != '') : $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weight' WHERE title='$wb_name' AND bid='$bid'");
            else : $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weight', bposition='l' WHERE title='$wb_name' AND bid='$bid'<br>");
            endif;
        }
    }
}

function BlocksManager_BlockPosition($bid, $wb_name, $position) {
    global $db, $prefix;
    $db->sql_query("UPDATE ".$prefix."_blocks_manager SET bposition='$position' WHERE bid='$bid' AND title='$wb_name'");
    BlocksManager_FixWeight($wb_name);
}

function BlocksManager_BlockOrder($wb_name, $weightrep, $weight, $bidrep, $bidori) {
    global $db, $prefix;
    $result = $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weight' WHERE bid='$bidrep'");
    $result2 = $db->sql_query("UPDATE ".$prefix."_blocks_manager SET weight='$weightrep' WHERE bid='$bidori'");
    BlocksManager_FixWeight($wb_name);
}

function OpenHeader($title="") {
    include("header.php");
    GraphicAdmin();
    title($title);
    OpenTable();
}

function CloseFooter() {
    CloseTable();
    include("footer.php");
}

switch($op) {

    case "BlocksManager":
    BlocksManager($wb_name);
    break;

    case "BlocksManager_Add":
    BlocksManager_Add($bida, $title);
    Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$wb_name");
    break;

    case "BlocksManager_Remove":
    BlocksManager_Remove($bidr, $title);
    Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$wb_name");
    break;

    case "BlocksManager_BlockPosition":
    BlocksManager_BlockPosition($bid, $title, $position);
    Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$title");
    break;

    case "BlocksManager_FixWeight":
    BlocksManager_FixWeight($wb_name);
    Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$wb_name");
    break;

    case "BlocksManager_BlockOrder":
    BlocksManager_BlockOrder ($title, $weightrep, $weight, $bidrep, $bidori);
    Header("Location: ".$admin_file.".php?op=BlocksManager&wb_name=$title");
    break;  
}

} else {
    echo "Access Denied";
}

The purpose of the code is to control a block system by modules. You can move/add/change/delete blocks by its module.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:41:00+00:00Added an answer on May 13, 2026 at 10:41 am

    You need to mix your PHP inline with your AJAX request:

    $('.ui-icon-closethick').click(function(e) {
        e.preventDefault();
        var parent = $(this).parent().parent();
        $.ajax({
            type: "POST",
            url: "server_items_reorder.php",
            data: 'id=' + parent.attr('id') + '&php_var=<?php echo $php_var; ?>',
            success: function() {
                parent.slideUp(300,function() {
                    parent.remove();
                });
            }
        });
    });
    

    And for your second example:

    function savelayout(){
        var positions = "";
        var weight = 0;
        var wb_name = "<?php echo $wb_name; ?>";
        $(".portlet").each(function(){
            weight++;
            positions += (this.id + "=" + this.parentNode.id + "|" + weight + "&");
        });
    
        $.ajax({
            type: "POST",
            url: "server_items_reorder.php",
            data: positions
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 257k
  • Answers 257k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this: $('#parent').html($('#subchildtext')).prepend('foobar<b>foodbarbold</b>'); May 13, 2026 at 10:41 am
  • Editorial Team
    Editorial Team added an answer Sometimes an API will take a parameter that can be… May 13, 2026 at 10:41 am
  • Editorial Team
    Editorial Team added an answer Read-only for a property is easy, just create a getter… May 13, 2026 at 10:41 am

Related Questions

I am trying to launch an Intent to send an email. All of that
I have a form which contains a whole heap of data entry fields that
I am trying to find an elegant framework to arrange all of my server
I am trying to conceptually work through a model for a client-server socket application
We have an application with multiple subsystems running in different threads (ie one thread

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.