Jump to content

Mass update into db


Leones

Recommended Posts

Hiya,

 

I'm working on a translation script, but I'm kinda stuck. The basic idea is to generate a form where the to be translated language is not inserted yet, and after adding a translation, you send the form and it gets updated into the database.

 

The code I currently use to generate the form:

<form action="translationupdate.php" method="post">
<?php

$con = mysql_connect("");  //Connection info hidden, ofc
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("westgadgets", $con);

$result = mysql_query("SELECT * FROM translations
WHERE nl=''"); // Select empty language stuff, nl in this case

while($row = mysql_fetch_array($result))
  {
  echo $row['info']; 
  echo "<input style='display:none;' type='tekst' name ='id' value='" . $row['id'] . "'/>"; // The id is unique, which will be used to update the strings.
  echo "<input type='tekst' name ='en' value='" . $row['en'] . "'/>";
  echo "<input type='tekst' name ='nl' value='" . $row['nl'] . "'/>";
  echo "<br />";
  }
?>
<input type="submit" />
</form>

 

After clicking on the send button, you will be directed to the translationupdate.php page, where the database should be updated, though I have no idea about how to do that with this many variable things.

 

My first question would be, is this the correct method of doing this, or should I be using another method to generate the form and submitting it?

The second one would be how to insert the stuff on the next page, doesn't have to be code as I can code it myself if I just know what to do.

 

Thanks in advance :)

Link to comment
https://forums.phpfreaks.com/topic/238775-mass-update-into-db/
Share on other sites

Archived

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

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