i searched the web and found what i needed but never could apply it to my script.
I am looking for a way to update some database information i have with a script. The thing is that i have a script that adds info to the database (works nice) i have a script which displays the info to the database (works nice) and now i need a script that updates/modify info from the database.
I don't really mind how to modify the info / either by having a button next to each of the 'users' saying Update Info ? or a page where it asks which user 'id' i want to update, i don't mind, i just need to update info via my website without going to phpmyadmin.
This is what i have setup (don't laugh.. its pretty simple, nothing to fancy... coming from w3school php section
Insert.php which inserts data from the form.
CODE
<?php
include 'connect.php';
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql="INSERT INTO clientinsert (nom, prenom, email, datedn, ville, codepostal, rue, plan, achat, fin, extras)
VALUES
('$_POST[nom]','$_POST[prenom]','$_POST[email]','$_POST[datedn]','$_POST[ville]','$_POST[codepostal]','$_POST[rue]','$_POST[plan]','$_POST[achat]','$_POST[fin]','$_POST[extras]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Client Added";
mysql_close($con)
?>
include 'connect.php';
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql="INSERT INTO clientinsert (nom, prenom, email, datedn, ville, codepostal, rue, plan, achat, fin, extras)
VALUES
('$_POST[nom]','$_POST[prenom]','$_POST[email]','$_POST[datedn]','$_POST[ville]','$_POST[codepostal]','$_POST[rue]','$_POST[plan]','$_POST[achat]','$_POST[fin]','$_POST[extras]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Client Added";
mysql_close($con)
?>
clients.php which shows the different users / clients infos that i inserted with the form :
CODE
<?php
include 'connect.php';
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$result = mysql_query("SELECT * FROM clientinsert");
echo "This is a list of all our clients.";
while($row = mysql_fetch_array($result))
{
echo "
<table width=\"520\" border=\"0\">
<tr>
<td valign=\"top\" width\=260\">
<table border=\"0\">
<tr>
<td valign=\"top\" width=\"105\"><b>Nom :</b></td><td width=\"140\">" . $row['nom'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Prénom :</b></td> <td width=\"140\">" . $row['prenom'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Email :</b></td><td width=\"140\">" . $row['email'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>ID :</b></td> <td width=\"140\">" . $row['id'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Date dn :</b></td><td width=\"140\">" . $row['datedn'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Code postal :</b></td> <td width=\"140\">" . $row['codepostal'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Ville :</b></td><td width=\"140\">" . $row['ville'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Rue :</b></td> <td width=\"140\">" . $row['rue'] . "</td>
</tr>
</table>
</td>
<td valign=\"top\">
<table border=\"0\" width\=260\">
<tr>
<td valign=\"top\" width=\"105\"><b>Plan :</b></td><td width=\"140\">" . $row['plan'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Achat :</b></td> <td width=\"140\">" . $row['achat'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Fin :</b></td><td width=\"140\">" . $row['fin'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Extras :</b></td> <td width=\"140\">" . $row['extras'] . "</td>
</tr>
</table>
</td>
</tr>
</table>
<hr>";
}
echo "";
mysql_close($con);
?>
include 'connect.php';
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$result = mysql_query("SELECT * FROM clientinsert");
echo "This is a list of all our clients.";
while($row = mysql_fetch_array($result))
{
echo "
<table width=\"520\" border=\"0\">
<tr>
<td valign=\"top\" width\=260\">
<table border=\"0\">
<tr>
<td valign=\"top\" width=\"105\"><b>Nom :</b></td><td width=\"140\">" . $row['nom'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Prénom :</b></td> <td width=\"140\">" . $row['prenom'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Email :</b></td><td width=\"140\">" . $row['email'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>ID :</b></td> <td width=\"140\">" . $row['id'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Date dn :</b></td><td width=\"140\">" . $row['datedn'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Code postal :</b></td> <td width=\"140\">" . $row['codepostal'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Ville :</b></td><td width=\"140\">" . $row['ville'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Rue :</b></td> <td width=\"140\">" . $row['rue'] . "</td>
</tr>
</table>
</td>
<td valign=\"top\">
<table border=\"0\" width\=260\">
<tr>
<td valign=\"top\" width=\"105\"><b>Plan :</b></td><td width=\"140\">" . $row['plan'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Achat :</b></td> <td width=\"140\">" . $row['achat'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Fin :</b></td><td width=\"140\">" . $row['fin'] . "</td>
</tr>
<tr>
<td valign=\"top\" width=\"105\"><b>Extras :</b></td> <td width=\"140\">" . $row['extras'] . "</td>
</tr>
</table>
</td>
</tr>
</table>
<hr>";
}
echo "";
mysql_close($con);
?>
Any info would be awsome, please while you provide info if you could give an example... i really am a noob at this :/