Jump to content

UPDATE a row in a DB !


christo

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