I-AM-OBODO Posted May 22, 2012 Share Posted May 22, 2012 hi all. how can i link each row so that when i click the edit, it takes me to a new page where i can edit the row associated with the edit link? thanks in advance. my code <?php $result = mysql_query("SELECT * FROM domain_info") or die(mysql_error()); echo "<table border='0' cellspacing='2' cellpadding='2'>"; echo "<tr> <th bgcolor='#0cc' align='center'><font color='#fff'>Id</th> <th bgcolor='#0cc' align='center'><font color='#fff'>Clients' Name</font></th> <th bgcolor='#0cc' align='center'><font color='#fff'>Domain Name</th> <th bgcolor='#0cc' align='center'><font color='#fff'>Size</th><th bgcolor='#0cc' align='center'><font color='#fff'>Cost</th><th bgcolor='#0cc' align='center'><font color='#fff'>Created Date</th><th bgcolor='#0cc' align='center'><font color='#fff'>Last Renew</th><th bgcolor='#0cc' align='center'><font color='#fff'>Expiry Date</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td width='25'>"; echo "$row['id']; echo "</td><td width='150'>"; echo $row['client']; echo "</td><td width='250'>"; echo $row['domain_name']; echo "</td><td width='50'>"; echo $row['size']; echo "</td><td width='50'>"; echo $row['cost']; echo "</td><td width='100'>"; echo $row['create_date']; echo "</td><td width='100'>"; echo $row['last_renewed']; echo "</td><td width='100'>"; echo $row['expiry_date']; echo "</td><td width='100'>"; echo "<a href='www.dis.com'> edit</a>"; // this is the edit link that should be linked to the rows echo "</td></tr>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/262916-link-rows-for-edit/ Share on other sites More sharing options...
trq Posted May 22, 2012 Share Posted May 22, 2012 Just pass the id via the link then use that id in the next page to lookup the same data, this time displaying it in an editable html element. Quote Link to comment https://forums.phpfreaks.com/topic/262916-link-rows-for-edit/#findComment-1347589 Share on other sites More sharing options...
ManiacDan Posted May 22, 2012 Share Posted May 22, 2012 echo "<a href='edit.php?id={$row['id']}'> edit</a>"; // this is the edit link that should be linked to the rows Also, note that your code is colored wrong, you have an errant double quote in your second echo inside the loop. You're also going to have to actually write an edit page. Quote Link to comment https://forums.phpfreaks.com/topic/262916-link-rows-for-edit/#findComment-1347591 Share on other sites More sharing options...
I-AM-OBODO Posted May 22, 2012 Author Share Posted May 22, 2012 echo "<a href='edit.php?id={$row['id']}'> edit</a>"; // this is the edit link that should be linked to the rows Also, note that your code is colored wrong, you have an errant double quote in your second echo inside the loop. You're also going to have to actually write an edit page. thanks. but what's the right way for my coloring? Quote Link to comment https://forums.phpfreaks.com/topic/262916-link-rows-for-edit/#findComment-1347602 Share on other sites More sharing options...
ManiacDan Posted May 22, 2012 Share Posted May 22, 2012 The coloring indicates that your quotes are misplaced, so the auto-coloring function "breaks" because your code is broken. This code will not even run due to the extra quote. Quote Link to comment https://forums.phpfreaks.com/topic/262916-link-rows-for-edit/#findComment-1347621 Share on other sites More sharing options...
I-AM-OBODO Posted May 23, 2012 Author Share Posted May 23, 2012 thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/262916-link-rows-for-edit/#findComment-1347869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.