Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Forum: Plugins
    In reply to: wordpress -> error
    Thread Starter ola-hashem

    (@ola-hashem)

    sorry i forget to put screenshot from my code :::
    else if(isset($_GET[“actionName”]) && ($_GET[“actionName”] ==”edit”))
    {
    include(“my_config.php”);
    $upd = “update url set title= ‘”.$_GET[‘new_title’].”‘ and myurl='”.$_GET[‘new_url’].”‘
    where title = ‘”.$_GET[‘old_title’].”‘”;
    mysql_query($upd);
    echo “ur record is updated”;
    } //end-if-edit
    } //end-of-function

    Forum: Plugins
    In reply to: admin plugin
    Thread Starter ola-hashem

    (@ola-hashem)

    i have another problem in this code that the delete button not working.
    when clicking on it, the row is deleted from the admin plugin but this changes not saved in my db (this row isn’t deleted from db)
    and this is the code ::
    <?php

    /*
    Plugin Name: Admin Page
    Description: sample plugin
    Plugin URI: http://www.hotmail.com
    */

    function plugin_menu2()
    {
    add_options_page(“WP Plugin”, “WP select a link”, 10, “wp_plugin”, “wp_back_end”);
    }

    function wp_back_end()
    {

    mysql_connect(“localhost”,”root”,””);
    mysql_select_db(“wordpress”);
    $sel = “select * from url”;
    $result=mysql_query($sel);
    $n=mysql_num_rows($result);
    ?>
    <form method=”post” action=””>
    <table align=”center” border=”2″ bgcolor=”#FFFFFF” id=”table1″>
    <tbody>
    <tr bgcolor=”#66CCFF”>
    <th> Title</th>
    <th> URL Link</th>
    <th></th>
    <th></th>

    </tr>
    <?
    for($i=0;$i<$n;$i++)
    {
    $row = mysql_fetch_array($result);

    ?>
    <tr>
    <td><input type=”text” name=”title1″ value=”<? echo $row[0] ?>”></td>
    <td> <input type=”text” name=”url1″ value=”<? echo $row[1] ?>”></td>
    <td><input type=”button” value=”Delete” name=”del” onclick=”delRow();”>
    <input type=”hidden” name=”h1″ value=”deleterow”></td>

    </tr>

    <?
    } //end-of-for
    ?>

    </tbody>
    </table>

    <input type=”button” value=”Add Row” align=”absmiddle” name=”btn” onclick=”addRow(‘table1’);”>

    </form>

    <script language=”javascript”>

    var count = “1”;
    function addRow(table1)
    {
    form = document.createElement(“form”);

    var tbody = document.getElementById(table1).getElementsByTagName(“TBODY”)[0];
    // create row
    var row = document.createElement(“TR”);

    // create table cell 1 —– title
    var td1= document.createElement(“TD”)
    var strHtml1= “<INPUT TYPE=\”text\” NAME=\”title2\”>”;
    td1.innerHTML = strHtml1.replace(/!count!/g,count);

    // create table cell 2 —– url
    var td2 = document.createElement(“TD”)
    var strHtml2 = “<INPUT TYPE=\”text\” NAME=\”url2\”>”;
    td2.innerHTML = strHtml2.replace(/!count!/g,count);

    //create table cell 3 —-save
    var td3 = document.createElement(“TD”)
    var strHtml3 = “<INPUT TYPE=\”submit\” VALUE=\”Save\”><input type=\”hidden\” name=\”hiddenName\” id=\”hiddenName\” value=\”insertrow\”>”;
    td3.innerHTML = strHtml3.replace(/!count!/g,count);

    var currentElement = document.createElement(“input”);
    currentElement.setAttribute(“type”, “hidden”);
    currentElement.setAttribute(“name”, “hiddenName”);
    //currentElement.setAttribute(“id”, “hiddenName”);
    currentElement.setAttribute(“value”, “insertrow”);
    form.appendChild(currentElement);

    // append data to row
    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    //row.appendChild(td4);
    //row.appendChild(td5);

    // add to count variable
    count = parseInt(count) + 1;
    // append row to table
    tbody.appendChild(row);

    } //end-function-add

    function delRow()
    {
    var current = window.event.srcElement;
    //here we will delete the line
    while ( (current = current.parentElement) && current.tagName !=”TR”);
    current.parentElement.removeChild(current);
    }

    </script>
    <?
    if (isset($_POST[‘hiddenName’]) and $_POST[‘hiddenName’] == ‘insertrow’)
    {
    include(“my_config.php”);
    $insert = “insert into url (title , url) values (‘”.$_POST[‘title2’].”‘,'”.$_POST[‘url2’].”‘)”;
    mysql_query($insert);
    //echo “Your record has inserted into db” ;
    } //end-if-insert

    else if (isset($_POST[‘h1’]) and $_POST[‘h1’] == ‘deleterow’)
    {
    include(“my_config.php”);
    $del= “delete from url
    where title='”.$_POST[‘del’].”‘”;
    //echo $del;
    $result = mysql_query($del);
    echo “<script>
    alert(‘the specified row is deleted from db’)
    </script>”;
    } //end-if-delete

    } //end-of-function

    add_action(“admin_menu”, “plugin_menu2”);
    ?>
    thanks

    Forum: Plugins
    In reply to: admin plugin
    Thread Starter ola-hashem

    (@ola-hashem)

    thanks alot for your help, i followed the points you said and it works .

    Forum: Plugins
    In reply to: admin plugin
    Thread Starter ola-hashem

    (@ola-hashem)

    this my code and i changed in it by writing javascript function to add row in my table but the save button not working.
    <?php

    /*
    Plugin Name: Admin Page
    Description: sample plugin
    Plugin URI: http://www.hotmail.com
    */

    function plugin_menu2()
    {
    add_options_page(“WP Plugin”, “WP select a link”, 10, “wp_plugin”, “wp_back_end”);
    //add_submenu_page(‘post.php’, ‘My Plugin Managment’, ‘My Plugin Managment’, 8, ‘myplugin/myplugin_admin.php’);
    }

    function wp_back_end()
    {

    mysql_connect(“localhost”,”root”,””);
    mysql_select_db(“wordpress”);
    $sel = “select * from url”;
    // where title = ‘”.$_POST[‘title1’].”‘ and url = ‘”.$_POST[‘url1’].”‘” ;
    $result=mysql_query($sel);
    $n=mysql_num_rows($result);
    ?>
    <form method=”post” action=”<?php print $_SERVER[PHP_SELF] ?>”>
    <table align=”center” border=”2″ bgcolor=”#FFFFFF” id=”table1″>
    <tbody>
    <tr bgcolor=”#66CCFF”>
    <th> Title</th>
    <th> URL Link</th>
    <th></th>
    <th></th>

    </tr>
    <?
    for($i=0;$i<$n;$i++)
    {
    $row = mysql_fetch_array($result);
    ?>
    <tr>
    <td><input type=”text” name=”title1″ value=”<? echo $row[0] ?>”></td>
    <td> <input type=”text” name=”url1″ value=”<? echo $row[1] ?>”></td>
    <td>“>Edit</td>
    <td>“>Delete</td>
    </tr>

    <?
    } //end-of-for
    ?>

    </tbody>
    </table>
    <input type=”button” value=”Add Row” align=”absmiddle” name=”btn” onclick=”addRow(‘table1’);”>

    </form>

    <script language=”javascript”>

    var count = “1”;
    function addRow(table1)
    {
    var form = document.createElement(“form”);

    var tbody = document.getElementById(table1).getElementsByTagName(“TBODY”)[0];
    // create row
    var row = document.createElement(“TR”);

    // create table cell 1 —– title
    var td1= document.createElement(“TD”)
    var strHtml1= “<INPUT TYPE=\”text\” NAME=\”title2\”>”;
    td1.innerHTML = strHtml1.replace(/!count!/g,count);

    // create table cell 2 —– url
    var td2 = document.createElement(“TD”)
    var strHtml2 = “<INPUT TYPE=\”text\” NAME=\”url2\”>”;
    td2.innerHTML = strHtml2.replace(/!count!/g,count);

    //create table cell 3 —-save
    var td3 = document.createElement(“TD”)
    var strHtml3 = “<INPUT TYPE=\”submit\” VALUE=\”Save\”>”;
    td3.innerHTML = strHtml3.replace(/!count!/g,count);

    var currentElement = document.createElement(“input”);
    currentElement.setAttribute(“type”, “hidden”);
    currentElement.setAttribute(“name”, “hiddenName”);
    currentElement.setAttribute(“id”, “hiddenName”);
    currentElement.setAttribute(“value”, “insertrow”);
    form.appendChild(currentElement);

    // create table cell 4 —–edit
    // var td4 = document.createElement(“TD”)
    //var strHtml4 = “<INPUT TYPE=\”Button\” VALUE=\”Edit\”>”;
    //td4.innerHTML = strHtml4.replace(/!count!/g,count);

    // create table cell 5 —–delete
    //var td5 = document.createElement(“TD”)
    //var strHtml5 = “<INPUT TYPE=\”Button\” VALUE=\”Delete\”>”;
    //td5.innerHTML = strHtml5.replace(/!count!/g,count);
    // append data to row
    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    //row.appendChild(td4);
    //row.appendChild(td5);

    // add to count variable
    count = parseInt(count) + 1;
    // append row to table
    tbody.appendChild(row);

    } //end-function-add

    </script>
    <?
    if (isset($_POST[‘insertrow’]))
    {
    include(“my_config.php”);
    $insert = “insert into url (title , url) values (‘”.$_POST[‘title2’].”‘,'”.$_POST[‘url2’].”‘)”;
    mysql_query($insert);
    echo “Your record has inserted into db” ;
    } //end-if
    } //end-of-function

    add_action(“admin_menu”, “plugin_menu2”);
    ?>
    thanks

    Forum: Plugins
    In reply to: admin plugin
    Thread Starter ola-hashem

    (@ola-hashem)

    all of them not working “add,delete and edit” .
    the main problem i face is when i put the pages that make this functions”add,delete and edit” in the same folder with my plugin file, nothing work.

    Forum: Plugins
    In reply to: admin plugin
    Thread Starter ola-hashem

    (@ola-hashem)

    i want to create an admin plugin that contain a HTML table and some buttons such as add button to add a new row in that table or edit a row or delete row and the values of that table are saved in a database table also the changes we make .

Viewing 6 replies - 1 through 6 (of 6 total)