Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button in a list

Status
Not open for further replies.

patrickstrijdonck

Programmer
Jan 18, 2009
97
NL
Hi all,

I have a form with a list, in that lists PHP code will show all records from a table, now i want to have a button for each record, when that button is pressed, that record from wich the button is selected must update something,

What i have now is this under, but that seems to show 1 button for all records.... and it doesnt update right.

Code:
<?php
include 'dbc.php';

session_start();
$id=$_REQUEST['id'];
$rechte = $_SESSION['recht'];
$ac = $_GET["action"];


///dan bijv. onderaan je script zet je wat er allemaal moet staan op de gotolink page//
if ($ac == "52154"){
//dus is de url: [URL unfurl="true"]www.domeinnaam.nl/bestandsnaam.php?gotolink[/URL] dan///
	header("Location: personeelwijzigen.php");
//dit staat dus allemaal op de gotolink page//
//nu nog even de if afsluiten///
}



if ( $rechte == "louwe" ) {
$rayon = "1: Marcel Louwe";
} elseif( $rechte == "boers" ) {
$rayon = "3: Peter Boers";
} elseif( $rechte == "bosters" ) {
$rayon = "2: Ron Bosters";
} elseif( $rechte == "klaassens" ) {
$rayon = "4: Fred Klaassens";
} else {
$rayon = "Algemeen"; 
}



if (!isset($_SESSION['user']))
{
 die ("Access Denied");
}

$useremail = $_SESSION['user'];

$result = mysql_query("SELECT * FROM users WHERE user_email = '$useremail'");
while($row = mysql_fetch_array($result))
{
	$fullname = $row['full_name'];
	
			
			}
if ($_POST['toevoegen'] == 'Toevoegen')
{
$linknumer = $_SESSION['cursusnr'];
$query1="UPDATE personeel SET cursus = '$linknumer' WHERE Personeelsnummer = '$linknummer'";
mysql_query($query1) or die(mysql_error());
echo "Personeel in planning voor cursus gezet!";
echo $nieuwevoornaam;

	
}

?>
<style type="text/css">
<!--
body {
	background-color: #E5E5E5;
}
.style5 {color: #FFFFFF}
.style6 {
	font-size: x-large;
	font-weight: bold;
}
.style2 {color: #000000; }
.style3 {color: #990000}
.style4 {color: #006600}
.style10 {color: #009900}
.style7 {color: #CC0000}
.style9 {color: #FF6600}
-->
</style>
 
 <?php
$rayonlogin = $_SESSION['rayonlogin']; 
if ( $rayonlogin == "1" ) {
 ?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
  <p align="center">Logged in als: <?php echo $_SESSION['user']; ?> -- Rayonleider | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a> 
  | <a href="personeeltoevoegen.php">Voeg personeel toe</a>  | <a href="planning.php">Cursus Planning</a> | <a href="Informatie.php">Informatie</a> | <a href="logout.php">Loguit</a> |</p>
  <div align="center">
    <?php } ?>
</div>
<? } 
$bedrijflogin = $_SESSION['bedrijflogin'];

if( $bedrijflogin == "1" ) {
?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
<p align="center">Logged in als: <?php echo $_SESSION['user']; ?> -- Bedrijfsleider | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a> 
  | <a href="personeeltoevoegen.php">Voeg personeel toe</a> | <a href="planning.php">Cursus Planning</a> | <a href="Informatie.php">Informatie</a> | <a href="logout.php">Loguit</a> |</p>
  <div align="center">
    <?php } ?>
</div>
<? } 
$cursuslogin = $_SESSION['cursuslogin'];
if( $cursuslogin == "1" ) {
?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
<p align="center">Logged in als: <?php echo $_SESSION['user']; ?> -- Cursusleider | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a> 
  | <a href="planning.php">Cursus Planning</a> | <a href="Informatie.php">Informatie</a> | <a href="logout.php">Loguit</a> |</p>
  <div align="center">
    <?php } ?>
</div>
<? } 
$personeellogin = $_SESSION['personeellogin']; 
if ( $personeellogin == "1" ) {
 ?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
<p align="center">Logged in als: <?php echo $_SESSION['user']; ?>-- Personeel | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a>| <a href="Informatie.php">Informatie</a> | <a href="logout.php">Loguit</a> |</p>
  <div align="center">
    <?php } ?>
</div>
<? } 
$docentlogin = $_SESSION['docentlogin']; 
if ( $docentlogin == "1" ) {
 ?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
<p align="center">Logged in als: <?php echo $_SESSION['user']; ?>-- Docent | <a href="checkstatus.php">Hoofdscherm</a> | <a href="nieuwecursus.php">Maak Cursus Aan</a> | <a href="settings.php">Account instellingen </a>| <a href="Informatie.php">Informatie</a> | <a href="logout.php">Loguit</a> |</p>
  <div align="center">

    <?php } ?>
</div>
  <p align="center">
    <? } else {
;
}
?>
<table border="2" cellspacing=1 cellpadding=2 class="tgrid" align="center">
        <tr bgcolor="#666666">
	        <th width="154" nowrap bgcolor="#006666"><form name="form1" method="post" action="">
                <a href="personeelwijzigen.php?sort=ID&order=<?=$negorder?><?=$qstr?>" title="Sort By Ticket ID <?=$negorder?>" class="style2">Personeel #</a></th>
          <th width="118" bgcolor="#006666"><span class="style2">Voornaam</span></th>
          <th width="146" bgcolor="#006666"><span class="style2">Achternaam</span></th>
          <th width="55" bgcolor="#006666"><span class="style2">Filliaal</span></th>
          <th width="132" bgcolor="#006666"><span class="style2">Geboortedatum</span></th>
          <th width="126" bgcolor="#006666"><span class="style2">Laatste Cursus</span></th>
          <th width="138" bgcolor="#006666"><span class="style2">Telefoonnummer</span></th>
          <th width="138" bgcolor="#006666"><span class="style2"></span></th>
  </tr>
        <?
        $class = "row1";
        $total=0;

                ?>
  <tr bordercolor="0" bgcolor="#FFFFFF" class="<?=$class?> " id="<?=$row['Personeelsnummer']?>">
      <td align="center" bordercolor="1" title="Wijzig personeelslid" table border="1">
        
        <div align="center">
          <p>
            <? $recht = $_SESSION['recht'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ 
//dan op de plaats waar de link staat om naar gotolink te gaan zet je:
//
$linknummer = $row['Personeelsnummer'];
 $_SESSION['personeelsnummer']= $linknummer;
echo "<a href=\"personeelwijzigen.php?id=$linknummer\">$linknummer</a><br>";


} 
//einde bestand//
?>
            </p>
    </div></td>
<td> 
                
        <div align="center">
            <? $recht = $_SESSION['recht'];
				  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['voornaam']} <br>";
 } ?>
      </div></td>
<td> 
                
        <div align="center">
            <? $recht = $_SESSION['recht'];
				  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['achternaam']} <br>";
 } ?>
      </div></td>
<td><div align="center">
  <? $recht = $_SESSION['recht'];
$query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['fillnr']} <br>";
 } ?>
    </div></td>
<td>
                  
                    <div align="center">
                                    <? $recht = $_SESSION['recht'];
                                       $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr, gebdatum FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['gebdatum']} <br>";
 } ?>
                  </div></td>
<td> 
                                    
        <div align="center">
            <? $recht = $_SESSION['recht'];
									  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr, telnr, lcursus FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['lcursus']} <br>";
 } ?>
      </div></td>
<td>
                                    
        <div align="center">
            <? $recht = $_SESSION['recht'];
									  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr, telnr FROM personeel WHERE planning = '1'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['telnr']} <br>";
 } ?>
      </div></td>
      <td>
                                    
        <div align="center">
          <label>
            <input type="submit" name="toevoegen" id="toevoegen" value="Toevoegen">
          </label>
        </div></td>
  </tr>
            <?
            $class = ($class =='row2') ?'row1':'row2';
             //end of while.
 //not tickets found!! ?> 
<tr class="<?=$class?>">
              <td colspan=12><b>Alle personeelsleden uit Rayon <?php echo $rayon; ?>.</b></td>
          </tr>
        <?
?>
     </table>



</p>
 
Sorry, I'm not going to try to parse all that spaghetti.

You have two options:
[ul]
[li] If the captions are different, you can use buttons with the same name and check the submitted caption. I would suggest you use <input type="submit"> elements, as IE does not adhere to the HTML standard and submits the caption instead of the value for <button> elements (maybe recent IE versions will behave better).[/li]
[li] If the captions are the same, you will have to use different button names and check which name is submitted.[/li]
[/ul]

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
isnt it possible to check all those records Or some of those records and update them???


trough checkboxes and 1 submit button??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top