Jump to content

Increase id by 1 with each link??


loftusp

Recommended Posts

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 :confused:)

 

http://homepages.cs.ncl.ac.uk/p.a.loftus/csc2511/

 

I'm don't know a great amount so here is the site  ^^

 

 

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??

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.