|
saigopal - 2006-01-06 05:52:24
hi
i have a doubt, i want to know how to use mysql_fetch_row() is this following one is correct? correct my code
$qry=sprintf("select field2 from table where field1=1");
$res=mysql_query($qry);
$row=mysql_fetch_row($res);
$field2=$row['field2'];
and my second doubt is i want to edit records in the web page i want to get the values from previous page when i press edit in the source page the values in the source page (which are coming from database) to be displayed in the destination page in text boxes and so that i can edit them and press update to save those records
how to use sessions in the above case.
can anybody send me the code
sai gopal
Er. Rochak Chauhan - 2006-01-06 09:26:08 - In reply to message 1 from saigopal
In edit.php, instead of writing/saving to text file, use the following query to enter the text in the database. Similarly, rather than reading from the text file, You can read from the database.
// READ FROM DATABASE
$queryToReadFromDatabase = "Select fieldname FROM tablename";
$result = mysql($queryToReadFromDatabase);
$row = mysql_fetch_assoc($result);
echo $row['fieldname'];
// WRITE TO DATABASE
$queryToWriteToDatabase = "UPDATE tablename SET fieldname = '".$value."';
mysql_query($queryToWriteToDatabase);
Good Luck,
Rochak
Vladas - 2006-05-04 08:46:19 - In reply to message 2 from Er. Rochak Chauhan
Hello,
I have managed to add the database read/write w/o problems, but!
I'm defining row names staticly,
like
$codeToBeEdited = myfunction_to_get_data('field1');
$codeToBeEdited2 = myfunction_to_get_data('field2');
$codeToBeEdited3 = myfunction_to_get_data('field3');
...
and so on
then I need to edit editinplace.js to contain the same values :/
my idea is to get like 5 rows from db that contains 5 fields each.
make a html table 5x5 and all fields editable.
How can I change the code to do it dynamicaly?
Thanks in advance,
Fallen
Gilberto Albino - 2008-04-27 19:07:19 - In reply to message 2 from Er. Rochak Chauhan
I am not sure this is a very useful concept having ajax edit in place
for text files.
I am wondering to find a real class that make the job directly against the database.
These 'edit in place' around the net are just a demonstration of ajax skill
and unhappily something unnecessary!
Also, the most aplications will store the changes in databases,
and adapt the script for dealing with database is not a very easy
thing for some programmers,
so the most edit in place, a useless!
Try to fix it to deal with databases,
and this will be a very good class!
mcalons - 2008-04-28 14:19:35 - In reply to message 2 from Er. Rochak Chauhan
Thats ok ,but... if in my update there are a Where clause ? As example: .."where id = $varvalue" .
How can I transfer the $varvalue from example.php ( the file show the values of files or in this case, the database) ??
Thanks
Er. Rochak Chauhan - 2008-04-28 15:32:36 - In reply to message 5 from mcalons
The value is passed from the JS to the PHP via GET.
eg
var url="backend.php?variable="+variableName;
and php, what ever you echo or print, goes back to Javascript as string.
Govind Saini - 2010-11-16 14:07:52 - In reply to message 6 from Er. Rochak Chauhan
unable to fetch record from database...
Manabjyoti Sarma - 2016-05-15 05:21:47 - In reply to message 7 from Govind Saini
Not able to fetch data either.
|