Jump to content

Recommended Posts

hi guys,

 

Basically, what I did was i displayed my database information by a table. on which on the last column there's 2 link, which is edit and delete.

 

My question is what code should i put that when I click on the edit or delete link, so that it can indicate that particular data (or ID) has been selected (or stored) ?

 

sorry for my poor english.

hope u guys understand what i need.

thanks and help pls  :shrug:

 

SQLversion: 5.5.8

 

<?php

//connects to database
require('connect.php');

//select table
$select = mysql_query("SELECT * FROM studentinfo") or die('No table exist!');
$numrows = mysql_num_rows($select);

        echo <<<EOM
                <table border='1'>
                <tr>
                        <th>Student Number</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>Email Address</th>
                        <th>Phone Number</th>
                        <th>Actions</th>
                </tr>
EOM;

while ($row = mysql_fetch_assoc($select))
{
        echo <<<EOM
                <tr>
                        <td>{$row['StudentNumber']}</td>
                        <td>{$row['FirstName']}</td>
                        <td>{$row['LastName']}</td>
                        <td>{$row['EmailAddr']}</td>
                        <td>{$row['PhoneNumber']}</td>
                        <td><a href='update.php'>Edit</a>  <a href='delete.php'>Delete</a></td>

                </tr>

EOM;
}

        echo <<<EOTABLE

        </table>

EOTABLE;

?>

I'm guessing the StudentNumber is unique? Something by which you can identify one and only one record in the table?

 

Example:

update.php?sn=(student number goes here)

if (isset($_GET["sn"])) {
    $sn = (int)$_GET["sn"];
    // do whatever
} else {
    // no student number given. redirect someplace? show an error message?
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.