Hi,can someone help to add edit button to my page?

Member Avatar for diafol

What do you want us to do with this zip file? Not install it I hope? Post your code so we can see it. Untrusted sources (i.e. you) cannot be deemed safe. Besides, why make us work hard to help you?

This file contains subfolders if i do code will be lots of snipets,to understand what i need.I will try to do ,but will be lots of code

Member Avatar for diafol

but will be lots of code

No it shouldn't be. Just the relevant bits. Don't dump your whole site here. This is probably a trivial issue, so just show us what we need and nothing else.

Please post your codes here instead of giving a link bunch of your sites.. we're trying to help not to complicated this.. :)

This are my functions regarding database with php,i include image how it looks like, so i need to add edit buttonwith functional to edit data to the row ,except IDnum.

<?php
//helper functions for database interaction

function queryInsert($connection,$sql)
{
    try {
        if ($connection->query($sql)===TRUE)  //execute the insert sql
        {
        return 1;  //if successful
        }
        else
        {
        return 0;  //if not successful
        }
    }
    //catch exception
    catch(Exception $e) {
        if (__DEBUG==1) 
            { 
            echo 'Message: ' .$e->getMessage();
            exit('<p class="warning">PHP script terminated');
            }
        else
            {   
            header("Location:".__USER_ERROR_PAGE);
            }
    }
}


function deleteRecord($connection,$sql)  //identical to above so we dont really need it
{
    try {
        if ($connection->query($sql)===TRUE)  //execute the sql
        {
        return 1;  //if successful
        }
        else
        {
        return 0;  //if not successful
        }
    }
    //catch exception
    catch(Exception $e) {
        if (__DEBUG==1) 
            { 
            echo 'Message: ' .$e->getMessage();
            exit('<p class="warning">PHP script terminated');
            }
        else
            {   
            header("Location:".__USER_ERROR_PAGE);
            }
    }
}

function query($connection,$sql)  //generic version
{
    try {
        if ($connection->query($sql)===TRUE)  //execute the  sql
        {
        return 1;  //if successful
        }
        else
        {
        return 0;  //if not successful
        }
    }
    //catch exception
    catch(Exception $e) {
        if (__DEBUG==1) 
            { 
            echo 'Message: ' .$e->getMessage();
            exit('<p class="warning">PHP script terminated');
            }
        else
            {   
            header("Location:".__USER_ERROR_PAGE);
            }
    }
}


?>



<?php
//helper functions

function getTableData($connection,$sql)
{
    try {
        $rs=$connection->query($sql);
        return $rs;
    }
    //catch exception
    catch(Exception $e) {
        if (__DEBUG==1) 
            { 
            echo 'Message: ' .$e->getMessage();
            exit('<p class="warning">PHP script terminated');
            }
        else
            {   
            header("Location:".__USER_ERROR_PAGE);
            }
    }
}

function checkResultSet($rs)
    {
    if($rs === false) {
        if (__DEBUG==1)
        {
        echo 'Wrong SQL: ' . $sql . ' Error: ' . $conn->error;
        exit('<p class="warning">PHP script terminated');
        }
        else
            {   
            header("Location:".__USER_ERROR_PAGE);
            }
    } else {
        $arr = $rs->fetch_all(MYSQLI_ASSOC);  //put the result into an array
        return $arr;
    }
}

function generateTable($tableName, $titlesResultSet, $dataResultSet)
{
    //use resultsets to generate HTML tables

    echo "<table border=1>";

    //first - create the table caption and headings
    echo "<caption>".strtoupper($tableName)." TABLE - QUERY RESULT</caption>";
    echo '<tr>';
    foreach($titlesResultSet as $fieldName) {
        echo '<th>'.$fieldName['Field'].'</th>';
    }
    echo '</tr>';

    //then show the data
    foreach($dataResultSet as $row) {
        echo '<tr>';
        foreach($titlesResultSet as $fieldName) {
            echo '<td>'.$row[$fieldName['Field']].'</td>';}
        echo '</tr>';
        }
    echo "</table>";
}

function generateDeleteTable($tableName, $primaryKey, $titlesResultSet, $dataResultSet)
{
    //use resultsets to generate HTML tables

    echo "<table border=1>";

    //first - create the table caption and headings
    echo "<caption>".strtoupper($tableName)." TABLE - QUERY RESULT</caption>";
    echo '<tr>';
    foreach($titlesResultSet as $fieldName) {
        echo '<th>'.$fieldName['Field'].'</th>';
    }
    echo '<th>DELETE</th>'; 
    echo '<th>EDIT</th>'; //////////////////////////////////////////////////////////////////
    echo '</tr>';

    //then show the data
    foreach($dataResultSet as $row) {
        echo '<tr>';
        foreach($titlesResultSet as $fieldName) {
            echo '<td>'.$row[$fieldName['Field']].'</td>';}
        echo '<td>';
        //set the button values and display the button ton the form:
        $id=$row[$primaryKey];  //get the current PK value
        $buttonText="Delete";
        include 'FORMS/buttonWithText2.txt';
        echo '</td>';
        echo '</tr>';
        }



    echo "</table>";
}

function generateDeleteTableCheckBox($tableName, $titlesResultSet, $dataResultSet)
{
    //use resultsets to generate HTML tables

    echo "<table border=1>";

    //first - create the table caption and headings
    echo "<caption>".strtoupper($tableName)." TABLE - QUERY RESULT</caption>";
    echo '<tr>';
    foreach($titlesResultSet as $fieldName) {
        echo '<th>'.$fieldName['Field'].'</th>';
    }
    echo '<th>DELETE</th>';
    echo '</tr>';

    //then show the data
    foreach($dataResultSet as $row) {
        echo '<tr>';
        foreach($titlesResultSet as $fieldName) {
            echo '<td>'.$row[$fieldName['Field']].'</td>';}
        echo '<td>';
        $buttonText="1";
        include 'FORMS/checkbox.txt';
        echo '</td>';
        echo '</tr>';
        }
    echo "</table>";
}



?>


here is the functions for form:

<div><p>
<form  class="button" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input name="newTable" type="submit" id="sendButton" value="<?php echo $buttonText?>">
</form>
</div>



<form  class="small_button" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<button class="smallBtn" name="delrecord" type="submit" value="<?php echo $id;?>"><?php echo $buttonText; ?></button>
</form>


<form class="register" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div>
<h2>New Lecturer Registration Form</h2>
<table class="form">
<tr><td>
<label>
<span>Lecturer ID</span><input name="lectID" type="text" >
<span>First Name</span><input name="lectFirstName" type="text" >
<span>Last Name</span><input name="lectLastName" type="text" >
<span>Password</span><input name="lectPass1" type="password" >
<span>Re-enter Password</span><input name="lectPass2" type="password" >
</label>
</td></tr>

<tr><td>
</td></tr>

<tr><td>
<label>
<span>Hit Enter to Register</span>
<input name="send" type="submit" id="sendButton" value="Enter">
</label>
</td></tr>
</table>
</div>
</form>




<form class="register" method="post" autocomplete="off" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div>
<h2>New Lecturer Registration Form (with validation)</h2>
<table class="form">
<tr><td>
<label>
<span>Lecturer ID</span><input name="lectID" type="text" required="true"  title="Lecturer ID (10 Characters)" pattern="[a-zA-Z0-9]{1,10}" data-tip="Enter Characters A-Z,a-z and/or numbers 0-9">
<span>First Name</span><input name="lectFirstName" type="text" required="true" title="First Name (up to 45 Characters)" pattern="[a-zA-Z0-9σαιν']{1,48}">
<span>Last Name</span><input name="lectLastName" type="text" required="true" title="Last Name (up to 45 Characters)" pattern="[a-zA-Z0-9σαιν']{1,48}">
<span>Password</span><input name="lectPass1" type="password" required="true" title="Password (min 5 to 8 Characters)" pattern="[A-Za-z-0-9_]{5,8}">
<span>Re-enter Password</span><input name="lectPass2" type="password" required="true" title="Password (5 to 8 Characters a-z,A-Z,0-9 and underscore)" pattern="[A-Za-z-0-9_]{5,8}">
</label>
</td></tr>

<tr><td>
</td></tr>

<tr><td>
<label>
<span>Hit Enter to Register</span>
<input name="send" type="submit" id="sendButton" value="Enter">
</label>
</td></tr>
</table>
</div>
</form>




<form class="register" method="post" autocomplete="off" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div>
<h2>New Lecturer Registration Form (with validation)</h2>
<table class="form">
<tr><td>
<label>
<span>Lecturer ID</span><input name="lectID" type="text" required="true"  title="Lecturer ID (10 Characters)" pattern="[a-zA-Z0-9]{1,10}" data-tip="Enter Characters A-Z,a-z and/or numbers 0-9">
<span>First Name</span><input name="lectFirstName" type="text" required="true" title="First Name (up to 45 Characters)" pattern="[a-zA-Z0-9σαιν']{1,48}">
<span>Last Name</span><input name="lectLastName" type="text" required="true" title="Last Name (up to 45 Characters)" pattern="[a-zA-Z0-9σαιν']{1,48}">
<span>Password</span><input name="lectPass1" id="password" type="password" required="true" title="Password (min 5 to 8 Characters)" pattern="[A-Za-z-0-9_]{5,8}">

<span>Re-enter Password</span><input name="lectPass2"  type="password" required="true" title="Password (5 to 8 Characters a-z,A-Z,0-9 and underscore)" pattern="[A-Za-z-0-9_]{5,8}">

</label>
</td></tr>

<tr><td><span style="color:#E31717" >Password Strength Indicator-->: </span><span id="result"></span>
</td></tr>

<tr><td>
<label>
<span>Hit Enter to Register</span>
<input name="send" type="submit" id="sendButton" value="Enter">
</label>https://www.mymeteor.ie/
</td></tr>
</table>
</div>
</form>



<div><p>
<form  class="button" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input name="newTable" type="submit" id="sendButton" value="Select Another Table">
</form>
</div>



<form class="getinput" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div>
<h2>Select Table Form</h2>
<table class="form">
<tr><td>
<label>
<span>Enter TABLE name</span><input name="tableName" type="text" id="tableField">
</label>
</td></tr>

<tr><td>
</td></tr>
<tr><td>
<label>
<span>Hit Enter to display table</span>
<input name="send" type="submit" id="sendButton" value="Enter">
</label>
</td></tr>
</table>
</div>
</form>

I know looks too much,but will appreciate
if someone could help to add edit button,with functional.

Member Avatar for diafol

Ok your code and markup all mixed up. What exactly do you want and where ? Which part of the 356 lines are relevant to your question?

<button name="edit">Edit</button>

But I suspect you want more than that. Without a full explanation, I doubt very much whether you will get an answer that meets your needs.

well,if you try to open last zip,its jpg of page and right on side need button edit,same,like delete.

Member Avatar for diafol

sorry not opening any zips. I don't trust you - nothing personal

Without picture,i am not able to explain exactly the problem.Ok,thanks anyway,try to get help from different forums.

Member Avatar for diafol

You can upload pictures via this editor.

Untitled.jpg here is the picture

Member Avatar for diafol

I'm assuming that you want an edit button next to the delete button?

Member Avatar for diafol

Sorry to say but this code is a bit of a mess with the various txt file includes. I think you're looking at

line 174:

    echo '<td>';
    //set the button values and display the button ton the form:
    $id=$row[$primaryKey];  //get the current PK value
    $buttonText="Delete";
    include 'FORMS/buttonWithText2.txt';
    echo '</td>';

I have an inkling that you need to place something here, but not sure what as we need to see the file FORMS/buttonWithText2.txt

Thats why i had a zip,where everything in folders and labeled for easy understanding.

Member Avatar for diafol

Not back to that again are we? Most of us - well those of us who care about security - will not download random stuff from the internet. If you want prompt help, lay out all the releveant information in the forum. After all, this is why we have "code tags" and image uploading facilities in the editor. Don't make people work hard to help you. In the time it took you to reply above, you could have posted the content of the text file.

OK, I've had enough here, good luck with it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.