loftusp Posted May 11, 2011 Share Posted May 11, 2011 My code reads: <a href="index.php?action=delete&id=" >Delete</a> How do i change it so the id=1,2,3 etc with each link?? Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/ Share on other sites More sharing options...
fugix Posted May 11, 2011 Share Posted May 11, 2011 how are the links being generated? Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214139 Share on other sites More sharing options...
loftusp Posted May 11, 2011 Author Share Posted May 11, 2011 Manually entering data into a form which is transferred into a database. These are then given an id, so I need to pass an id into my php (at least i think i do ) http://homepages.cs.ncl.ac.uk/p.a.loftus/csc2511/ I'm don't know a great amount so here is the site ^^ Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214140 Share on other sites More sharing options...
spiderwell Posted May 11, 2011 Share Posted May 11, 2011 so you want to pull the id(s) from the database and turn into delete link(s)? Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214142 Share on other sites More sharing options...
loftusp Posted May 11, 2011 Author Share Posted May 11, 2011 so you want to pull the id(s) from the database and turn into delete link(s)? Yes I think so. I have the code written to delete the database entries but I don't know how to make the links! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214147 Share on other sites More sharing options...
xyph Posted May 11, 2011 Share Posted May 11, 2011 Someone wants us to do their homework for them Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214150 Share on other sites More sharing options...
loftusp Posted May 11, 2011 Author Share Posted May 11, 2011 Someone wants us to do their homework for them Maybe.... Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214152 Share on other sites More sharing options...
spiderwell Posted May 11, 2011 Share Posted May 11, 2011 a little shove never helps get a record set of users (or whatever it is) and loop through it. use the data to create links a bit like this: <?php echo "<a href='deleteuser.php?id=" . $row['id'] . "'>delete " . $row['username'] . "</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214156 Share on other sites More sharing options...
loftusp Posted May 11, 2011 Author Share Posted May 11, 2011 a little shove never helps get a record set of users (or whatever it is) and loop through it. use the data to create links a bit like this: <?php echo "<a href='deleteuser.php?id=" . $row['id'] . "'>delete " . $row['username'] . "</a>"; ?> Sorry I'm really not good at this. Basically my table is called locations into which a user adds their location and activity. This is then linked to a user in a person_location table. This is the delete code I have created. Not sure how good it is. case 'delete' : $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; if (!$id) { echo 'No Location identified!'; } else { $currentLocation = R::findOne('location', 'id=?', array($id)); $pps = R::findOne('person', 'name=?', array($_SESSION['name'])); // Why is this not deleting it from the database??? R::unassociate($_SESSION['name'], $currentLocation); R::trash($currentLocation); } $tpl = 'loggedin.twig'; break; Using that detail what would the . $row['id'] . be?? Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214159 Share on other sites More sharing options...
loftusp Posted May 11, 2011 Author Share Posted May 11, 2011 Also this is how the data is stored: case 'location' : if ($_POST['location'] && $_POST['activity']) { $pld = R::dispense('locations'); $pld->location = $_REQUEST['location']; $pld->activity = $_REQUEST['activity']; $id=R::store($pld); R::associate($_SESSION['name'], $pld); $vals['location'] = R::related ($_SESSION['name'], 'locations'); $tpl='loggedin.twig'; }else { echo "no user!"; $tpl='loggedin.twig'; } break; Quote Link to comment https://forums.phpfreaks.com/topic/236147-increase-id-by-1-with-each-link/#findComment-1214162 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.