SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query string display no var value

    Hi guys,

    I would like to edit data from a mysql db using a php form.

    I populate the data in a table and next to each row i have a edit url, i want the url(query string) to pass the the id of the current row to edit_process.php so that i can SELECT the relevant Record to Edit.

    please advise me what is the best way to do this, because my method below only pass the query string, but not the ID from the record. So its useless.

    Thanks

    RESLOVED

    Code PHP:
     
    //my select_domains_table.php page with "edit" url
    <?php
     
    require('conn.php');
     
    	$result = mysql_query("SELECT * FROM domains");
     
    	print "<table border='1'>
    			  <tr>
    			    <th>ID</th>
    			    <th>Domains</th>
    				<th>Sex</th>
    				<th>E-mail</th>
    				<th>Edit</th>
    				<th>Delete</th>
    			  </tr>";
     
     
    //Print table script
     
    			    while($row = mysql_fetch_array($result))
    				  {
    				    print "<tr>";
    					print "<td>" . $row['id']. "</td>"; 
    					print "<td>" . $row['domain']. "</td>"; 
    					print "<td>" . $row['sex']. "</td>"; 
    					print "<td>" . $row['mail']. "</td>";
     
    					$id =  $row['id'];
    					print "<td><a href='edit_process.php?action=edit&id=$id'>Edit</td>";
     
    					print "<td>Delete</td>";
     
    				    print "</tr>";
    				  }
     
    	print "</table>";
    	print "<br/><br/>";
     
    	$result_02 = mysql_query("SELECT * FROM domains WHERE sex='F'");
    	$num_rows = mysql_num_rows($result_02);
     
    	print "<p>$num_rows women have added data to the table.</p>\n";
     
    	$result_03 = mysql_query("SELECT * FROM domains WHERE sex='M'");
    	$num_rows_02 = mysql_num_rows($result_03);
    	print "<p>$num_rows_02 men have added data to the table.</p>\n";
     
    	mysql_close($con);
    ?>
     
    <a href="index.php">home</a>
     
    //my edit_process.php page
     
    <?php
     
    if ($_GET['action'] == 'edit') {
        print "i received the query string $id";
    }  
    else
    	{
    	print "no query";
    	}
     
    ?>
    Last edited by kingr; Jul 21, 2009 at 03:44. Reason: answer found

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    print "<td><a href='edit_process.php?action=edit&id=" $row['id']. "'>Edit</td>";

    // print id
    if ($_GET['action'] == 'edit') {
        print 
    "i received the query string " $_GET['id'];

    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    PHP Code:
    print "<td><a href='edit_process.php?action=edit&id=" $row['id']. "'>Edit</td>";

    // print id
    if ($_GET['action'] == 'edit') {
        print 
    "i received the query string " $_GET['id'];



    you rock. thanks man.

    now i can continue with the rest


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •