Jump to content

Archived

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

christo

UPDATE a row in a DB !

Recommended Posts

What i would like to do here is to retrieve the infos of a row in a DB and display it in a form (the same i entered the data) correct them and save .
Here's what i've done [code]<?
session_start();

if(!isset($HTTP_SESSION_VARS['valid_user'])) {
    echo "blablah";
}
    else{
        echo "Welcome $HTTP_SESSION_VARS[valid_user]
<html>
        <title>* Blah *</title>
    <body>
        
$objid = $HTTP_POST_VARS['objid'];

echo"objid=$objid";

$host = "";
$user = "";
$pass = "";
$base = "";

$db_conx = mysql_connect($host,$user,$pass) or print("error de connection mysql");
mysql_select_db($base, $db_conx) or print("error connection base");

$query ="UPDATE object SET region state city='$city'
district='$_POST[district]'accomodation transaction nb_rooms
floor price='$_POST[price]' garage cellar garden pool
descr='$_POST[descr]'age_par pic WHERE
username='".$HTTP_SESSION_VARS['valid_user']."'AND objid='$objid'";

$result = mysql_query($query) or die(mysql_error());

    if ($resultat) {
        echo"updated !";
    }
        else {
            echo" problem !";
        }
}
?>[/code]
But honestly i haven't understood the concept...Do i need to write 2 requests? (display,update)How can get the infos from the DB and show the values appearing in the form (another php that i enter infosin the DB from, tx radio, checkbox) ?? What do you think of the above script, am i in the right way ???

Any info on this subject is welcome, Thanks

Christos

Share this post


Link to post
Share on other sites

×

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.