Vecteevs Posted April 28, 2010 Report Share Posted April 28, 2010 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 Quote Link to comment Share on other sites More sharing options...
briedis Posted April 28, 2010 Report Share Posted April 28, 2010 Nesaprotu. Tu gribi, lai lietotājs uzreiz var mainīt čupu ar valūtas kursiem vienlaicīgi, nevis katru atsevišķi? Quote Link to comment Share on other sites More sharing options...
Vecteevs Posted April 28, 2010 Author Report Share Posted April 28, 2010 (edited) 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 April 28, 2010 by Vecteevs Quote Link to comment Share on other sites More sharing options...
briedis Posted April 28, 2010 Report Share Posted April 28, 2010 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 :) Quote Link to comment Share on other sites More sharing options...
Vecteevs Posted April 28, 2010 Author Report Share Posted April 28, 2010 oki paldies! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.