Jump to content

Recommended Posts

Hi all,

 

So I have this script.

Basically its form that connects to the database insterts rows in the databse onto the form. The user can change the values in the form and update the relevant row on the databse. BUT its not working...heres the code:

 

UPDATE $tbl SET name='$name', lastname='$lastname', grade='$overall' WHERE id='$id'

 

what is happening there!??

all the names correspond to the form correctly....

I am guessing something is worng with "UPDATE $tbl"??

 

Any help will be apprecieated....been driving me crazy!!

 

thanks,

Link to comment
https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/
Share on other sites

Heres the full code:

 

<?php

$name=$_POST['name'];
$lastname=$_POST['lastname'];
$overall=$_POST['overall'];
$tbl="term12008";

$host="localhost"; // Host name 
$username="innovati_grade1"; // Mysql username 
$password="merrigrade1"; // Mysql password 
$db_name="innovati_grade1"; // Database name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// update data in mysql database 
$sql="UPDATE $tbl SET name='$name', lastname='$lastname', grade='$overall' WHERE id='$id'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}

else {
echo "ERROR";
}

?>

just a question...

 

how do you enter in multiple values into an address bar?

 

I want to retrieve data in the following php file by using the GET function...

However i want to retrieve different values

 

eg.

 

<td align="center"><a href="updatestudent.php?id=<? echo $rows['id']; ?>,tbl=<? echo $rows['term']; ?>">update</a></td>

 

in there i want to retrieve the ID value and the TERM value

 

thanks thanks,

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.