Daveyboy Posted December 30, 2006 Share Posted December 30, 2006 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><?phperror_reporting(E_ALL);// Begin your table outside of the arrayecho "<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] Link to comment https://forums.phpfreaks.com/topic/32315-solved-question-on-passing-row-id-to-another-script/ Share on other sites More sharing options...
dbo Posted December 30, 2006 Share Posted December 30, 2006 Instead of this mess you have going on: <a href=\"edit_user.php?id=$row\"[\"id\"]\" \">Edit</a>try this<a href=\"edit_user.php?id=$id\">Edit</a>Employ this same technique everywhere else. You're saving the $row['id'] thing into $id anyways... Link to comment https://forums.phpfreaks.com/topic/32315-solved-question-on-passing-row-id-to-another-script/#findComment-150068 Share on other sites More sharing options...
Daveyboy Posted December 31, 2006 Author Share Posted December 31, 2006 Thanks that works. Link to comment https://forums.phpfreaks.com/topic/32315-solved-question-on-passing-row-id-to-another-script/#findComment-150372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.