Jump to content

change the value in phpmyadmin


TheCatapult
 Share

Recommended Posts

If it's auto increment, it can't be changed unless you delete then re-add it and auto increment. If it's not auto increment changing won't be a problem.

Link to comment
Share on other sites

to change value of a row you can use "update". if it is auto increment colum and it changed to any existed ID new id will be the next id of the highest id if it does not exist it will be just updated

Link to comment
Share on other sites

Thank you for the above answers. Yes, it is auto increment. What I want to happen is to display the row 1 in my Web site. I also want to have a protected page in my Web site wherein I can change the value written in row 1. birbal, Update did not work. Please help me.

<form action="insert.php" method="post"><select>  <option value="volvo">Volvo</option>  <option value="saab">Saab</option>  <option value="mercedes">Mercedes</option>  <option value="audi">Audi</option></select> <br><input type="Submit"></form>

Here's my current code for adding new row in my data base. Unfortunately, it does only write a space and not what is written in the option value. What's my mistake here? Please help me. Thank you!

Link to comment
Share on other sites

please show us the php code of it

Link to comment
Share on other sites

Thank you birbal! Here is my Update code.

<?$ud_id=$_POST['ud_id'];$ud_first=$_POST['ud_jockey'];$username="";$password=";$database="";mysql_connect("",$username,$password);$query="UPDATE diskjockey SET first='$ud_first'";mysql_query($query);echo "Record Updated";mysql_close();?>

Please help me. I just want to have a page wherein I can select the image code of the current DJ on air.

Link to comment
Share on other sites

That won't work if first is auto increment. EDIT: Add another column that you can UPDATE.

Edited by niche
Link to comment
Share on other sites

$query="UPDATE diskjockey SET first='$ud_first'"; That will work if $ud_first contains the ID that you want to update with, and you want to store that in a column called first in the table diskjockey. That particular query is going to update all rows in that table with the same value in that column. If that's the table and column you use to figure out who is playing, then that will work to update it.

Link to comment
Share on other sites

please confirm that you can't update an auto increment column. post #4 suggests it might be ai.

Edited by niche
Link to comment
Share on other sites

I'm pretty sure you can update any column, but I don't know why you would want to update an auto increment. It sounded to me like he had one table that held all of the DJs, and another table that listed which was currently on air, and he wanted to update the one with the ID from the other. I could be wrong.

Link to comment
Share on other sites

I just tried to update an auto increment field and got this error: Duplicate entry '1' for key 'PRIMARY' phpmyadmin wouldn't let me manually change it either for the same reason.

Link to comment
Share on other sites

I just tried to update an auto increment field and got this error: Duplicate entry '1' for key 'PRIMARY' phpmyadmin wouldn't let me manually change it either for the same reason.
if it is auto increment colum and it changed to any existed ID new id will be the next id of the highest id
if it is primary key or unique constrained it will not do so and will throw a error
Link to comment
Share on other sites

Yes, if you think that's the problem, but you don't need a new table. I'd just add a column that isn't ai and remember what justsomeguy said.

Link to comment
Share on other sites

I put a section in my Web site which indicates which DJ is currently on air. DJ changes time by time so I need a script wherein I can change the icon of the current DJ into an icon of the next DJ.
What exactly is the database structure like? How does it know which DJ is on air, does it look that up in the database? If so, what does that database table look like?
  • Like 1
Link to comment
Share on other sites

per justsomeguy (JSG), please post the table's structure so you can get the help you need.

Link to comment
Share on other sites

Here is the form for putting the image code of current DJ.

<form action="insert.php" method="post"> Web: <input type="text" name="jockey"><br><input type="Submit"></form>

This is the insert.php file.

<?$username="";$password="";$database=""; $jockey=$_POST['jockey'];  mysql_connect("",$username,$password);@mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO diskjockey1 VALUES ('','$jockey')";mysql_query($query); mysql_close();?>

This is what my table look like. structurem.jpgThanks and I hope for help!

Edited by MisterCatapult
Link to comment
Share on other sites

Please help me. I just want to have a page wherein I can select the image code of the current DJ on air.
To do this you'll need to use WHERE in your sql. Have you used WHERE before?
Link to comment
Share on other sites

Thank! Here's the code.

<?$username="username";$password="password";$database="your_database";mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");$query="SELECT * FROM contacts";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close(); $i=0;while ($i < $num) { $jockey=mysql_result($result,$i,"jockey");echo "<b>$jockey";$i++;}?>

niche, no. What is that?

Edited by MisterCatapult
Link to comment
Share on other sites

So you've got your diskjockey1 table which holds IDs and jockeys, and the contacts table which you get all of the records from and display each one. How do the 2 tables relate to each other? Is there an ID in the contacts table that is the same as the one in the other table?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...