Jump to content

[SOLVED] question on passing row id to another script


Daveyboy

Recommended Posts

I have this script below that displays rows from MySql, one column is a delete link that will pass the row id to a delete_user.php page. I can't figure out how to pass the row id properly to the delete_user.php page. I know it is something to do with this line; <a href=\"delete_user.php?dump=$row\"[\"id\"]\" \">Delete</a>  Please help.

[code]
<html>
<body>
<?php
error_reporting(E_ALL);
// Begin your table outside of the array

echo "<table width= '90%' border= '1' cellpadding='4' cellspacing='0'>
    <tr>
    <td><b> edit </b></td>
<td><b> delete </b></td>
    <td><b> id </b></td>
        <td><b> First Name </b></td>
<td><b> Last Name </b></td>
<td><b> Age </b></td>
<td><b> Date Submitted </b></td>
    </tr>";


include ("./mysql_connect_databasetest.php");
// Define your colors for the alternating rows

$color1 = "#CCFFCC";
$color2 = "#BFD8BC";
$row_count = 0;

// Perform an statndard SQL query:

$sql_events = mysql_query("SELECT * FROM info ORDER BY `id`  ASC") or die (mysql_error());

// We are going to use the "$row" method for this query. This is just my preference.

// Show how many users records there are before table   
    $num = (mysql_num_rows($sql_events));
    if ($num > 0){
    echo "<p><b>There are currently $num registered users in database</b></p>";
    }else{
    echo 'There are no registred users at this time';
    }    


    while ($row = mysql_fetch_array($sql_events)) {
    //$delete= $row["
    $edit= $row["id"];
    $delete= $row["id"];
    $id = $row["id"];
    $firstname = $row["firstname"];
    $lastname = $row["lastname"];
    $age= $row["age"];
    $datesubmitted= $row['datesubmitted'];

    /* Now we do this small line which is basically going to tell
    PHP to alternate the colors between the two colors we defined above. */

    $row_color = ($row_count % 2) ? $color1 : $color2;
    // Echo your table row and table data that you want to be looped over and over here.
    echo "<tr>
    <td width= '110' bgcolor='$row_color' nowrap>
    <a href=\"edit_user.php?id=$row\"[\"id\"]\" \">Edit</a>
    </td>
    <td width= '110' bgcolor='$row_color' nowrap>
    <a href=\"delete_user.php?dump=$row\"[\"id\"]\" \">Delete</a>
    </td>
    <td width= \"110\" bgcolor=\"$row_color\" nowrap>
    $id</td>
    <td width= \"110\" bgcolor=\"$row_color\" nowrap>
    $firstname</td>
    <td width= \"110\" bgcolor=\"$row_color\" nowrap>
    $lastname</td>
    <td width= \"110\" bgcolor=\"$row_color\" nowrap>
    $age</td>
    <td width= \"110\" bgcolor=\"$row_color\" nowrap>
    $datesubmitted</td>
    </td></tr>";

    // Add 1 to the row count

    $row_count++;
}

// Close out your table.

echo "</table>";
print_r($delete);
?>
</body>
</html>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.