Jump to content

php, mysql and update table


marvist

Recommended Posts

Hi,

I have one mysql table and I need to update it by form. But what is the best way.

I think First I need atleast following php-files:

 

list.php --> list all data rows from my table included link to select certain row and ...

update.php --> ...when selected you will get form view where you can update field

updated.php --> update your database table.

 

Where I can find example so that I can do that...

 

Kind regards

Marko

Link to comment
Share on other sites

ok,

here is starting page. Only thing is that I need to upadate selected records....

This html - php page list all customers with url link. After click I can get more details but what if I want to update one? What is best solution?...

 

 

<html>

<head><title>DATABASE</title></head>

 

<body>

<h1>customers</h1>

 

<?php

  // otetaan yhteys tietokantaan

mysql_connect("localhost", "?????", "??????") or die(mysql_error());

  mysql_select_db("??????");

 

  // jos haetaan yhden henkilön tietoja

  if ($_GET["ID"]) {

    $kysely =

      "SELECT DATE_FORMAT(jatetty,'%e.%c.%Y %T'), SUKUNIMI, ETUNIMI, OSOITE, RAPPU, HUONE, POSTINUMERO, POSTIPAIKKA, ORGANISAATIO, EMAIL, PUHELIN, MATKAPUHELIN, AJOOHJE, KAYTTOJ, OPERAATTORI, VIRUSTORJUNTA, HAITTAOHJELMATK, MUUTTK, HUOM".

      "  FROM tbl_itcustomers".

      "  WHERE ID='$_GET[iD]'";

    if ($tulos = mysql_query($kysely)) {

      list($jat, $SUKUNIMI, $ETUNIMI, $OSOITE, $RAPPU, $HUONE, $POSTINUMERO, $POSTIPAIKKA, $ORGANISAATIO, $EMAIL, $PUHELIN, $MATKAPUHELIN, $AJOOHJE, $KAYTTOJ, $OPERAATTORI, $VIRUSTORJUNTA, $HAITTAOHJELMATK, $MUUTTK, $HUOM) = mysql_fetch_row($tulos);

?>

 

<p>

  Nro: <?= $_GET["ID"] ?><br>

  Päivitetty viimeksi: <?= $jat ?><br>

  Nimi: <?= $SUKUNIMI ?> <?= $ETUNIMI ?> <br>

  Osoite:<?= $OSOITE ?> <?= $RAPPU ?> <?= $HUONE ?><br>

  Organisaatio:<?= $ORGANISAATIO ?><br>

  Postitoimipaikka: <?= $POSTINUMERO ?> <?= $POSTIPAIKKA ?><br>

  Sähköposti: <?= $EMAIL ?><br>

  Puhelin: <?= $PUHELIN ?><br> 

  Matkapuhelin: <?= $MATKAPUHELIN ?><br>

  Ajo-ohje: <?= $AJOOHJE ?><br>

  Käyttöjärjestelmä: <?= $KAYTTOJ ?><br>

  Internet operaattori: <?= $OPERAATTORI ?><br>

  Virustorjunta: <?= $VIRUSTORJUNTA ?><br>

  Haittaohjelmatyökalut: <?= $HAITTAOHJELMATK ?><br>

  Muut thank youökaluohjelmat: <?= $MUUTTK ?><br>

  Lisätietoja: <?= $HUOM ?><br>

 

  <br>

  <br>

 

</p>

<?php

    } else {

      echo "<p>Rekisteritietoja ei löydy!</p>";

    }

    echo "<p><a href=\"itcustomers_list.php\">List all data</a></p>";

    echo "<p><a href=\"itcustomers_add.php\">Add new customer</a></p>";

  }

  else {

    // muussa tapauksessa haetaan lista

    echo "<p>\n";

    $kysely =

      "SELECT ID, SUKUNIMI, ETUNIMI, ORGANISAATIO, OSOITE, MATKAPUHELIN, EMAIL FROM tbl_itcustomers".

      "  ORDER BY SUKUNIMI";

    if ($tulos = mysql_query($kysely)) {

      while (list($IN, $SUKUNIMI, $ETUNIMI, $ORGANISAATIO, $OSOITE, $MATKAPUHELIN, $EMAIL) = mysql_fetch_row($tulos)) {

        echo "<a href=\"itcustomers_list.php?ID=$IN\">$SUKUNIMI | $ETUNIMI | $ORGANISAATIO| $OSOITE | $MATKAPUHELIN | $EMAIL</a><br>\n";

      }

    } else {

      echo "Listan haku ei onnistunut!";

    }

    echo " <p><a href=\"itcustomers_add.php\">Add new customer</a></p>\n";

  }

?>

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.