traxy Posted May 1, 2009 Share Posted May 1, 2009 Hey Guys, Im currently working on project, its basically an online store to sell CD's. When the site administrator searches for a CD to update a list of CD's will appear that match the search criteria entered. When the list appears they are able to click on which CD they want to update (eg. update the price) but im unsure of how to actually pass the information of what CD has been selected to the next php page. Here is an example of my code: This is my bit of my search.php $Row = mysqli_fetch_row($QueryResult); do { echo "<table width='100%' border='1'>"; echo "<tr><th>CD Type</th><th>CD Name</th><th>Price</th><th>Artist</th></tr>"; echo "<tr><td>{$Row[0]}</td>"; echo "<td>{$Row[1]}</td>"; echo "<td>{$Row[2]}</td>"; echo "<td>{$Row[3]}</td></tr>"; echo '<a href="update.php">Update </a>'; echo '<a href="index.html"> Delete</a>'; $Row = mysqli_fetch_row($QueryResult); } while($Row); The above code returns all CD's that matched the search criteria with a link to update.php above each CD. But whenever I click on the update.php it always returns the values of the first row, I need to somehow let update.php know which CD I want to update. Create a handle (is that the correct terminology) to each row so update.php knows which record we want to update. Hope that makes sense, please let me know if you need more information. Quote Link to comment https://forums.phpfreaks.com/topic/156369-update-records-mysql/ Share on other sites More sharing options...
harristweed Posted May 1, 2009 Share Posted May 1, 2009 I'd do it like this, make the cd list the link and have the relevant cd in query string: <?php $Row = mysqli_fetch_row($QueryResult); do { echo "<table width='100%' border='1'>"; echo "<tr><th>CD Type</th><th>CD Name</th><th>Price</th><th>Artist</th></tr>"; echo "<tr><td>{$Row[0]}</td>"; echo "<td><a href=\"update.php?cd=$Row[1]\">{$Row[1]}</a></td>"; echo "<td>{$Row[2]}</td>"; echo "<td>{$Row[3]}</td></tr>"; echo '<a href="index.html"> Delete</a>'; $Row = mysqli_fetch_row($QueryResult); } while($Row); ?> Quote Link to comment https://forums.phpfreaks.com/topic/156369-update-records-mysql/#findComment-823306 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.