Jump to content
php.lv forumi

MSQL UPDATE


Vecteevs

Recommended Posts

Sveiki visiem!

Problēma veicot update vairākām vienībām

<?php
if(isset($_POST['forma'])) {
$con = mysql_connect("localhost","root","xxxx");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("manadb", $con);

$_POST['forma1'] = mysql_real_escape_string($_POST['forma1']);
mysql_query("UPDATE kursi SET kurss = '{$_POST['forma1']}'
WHERE valuta_no = 'PP' AND valuta_uz = 'AP'");
mysql_close($con);
}
?>

kā lai pievienoju vēl vairākas UPDATE iespējas? Bija doma likt nākošajā php kodā, bet viņš visu laiku samainīja vietām tikai valūtas un nekas nesanāca

Link to comment
Share on other sites

nē, katru atsevišķi.

tas izskatās apmēram tā:

<tr>
<td>SWEDBANK</td>
<td>LRUSD</td>
<td><input type="text" name="forma1" /></td>
<td><input type="submit" value="Mainīt" /></td>
</tr>
<tr>
<td>LRUSD</td>
<td>SWEDBANK</td>
<td><input type="text" name="forma2" /></td>
<td><input type="submit" value="Mainīt" /></td>
</tr>
<tr>
<td>SWEDBANK</td>
<td>WMZ</td>
<td><input type="text" name="forma3" /></td>
<td><input type="submit" value="Mainīt" /></td>
</tr>

utt

un tas viss ir zem viena form taga

Edited by Vecteevs
Link to comment
Share on other sites

Kas liedz šitā?

 

mysql_query("UPDATE kursi SET kurss = '{$_POST['forma1']}' WHERE valuta_no = '{kautkada_valuta}' AND valuta_uz = 'kautkada_valuta'");
mysql_query("UPDATE kursi SET kurss = '{$_POST['forma2']}' WHERE valuta_no = '{kautkada_valuta}' AND valuta_uz = 'kautkada_valuta'");
mysql_query("UPDATE kursi SET kurss = '{$_POST['forma3']}' WHERE valuta_no = '{kautkada_valuta}' AND valuta_uz = 'kautkada_valuta'");
mysql_query("UPDATE kursi SET kurss = '{$_POST['forma4']}' WHERE valuta_no = '{kautkada_valuta}' AND valuta_uz = 'kautkada_valuta'");
mysql_query("UPDATE kursi SET kurss = '{$_POST['forma5']}' WHERE valuta_no = '{kautkada_valuta}' AND valuta_uz = 'kautkada_valuta'");
//utt

 

Ja māki for ciklu uzrakstīt, un parastu if pārbaudi, vai formas lauka vērtībā nav tukša, nevajadzētu būt problēmām izštukot labāku risinājumu :)

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...