Posted: Mon Oct 16, 2006 9:38 am
Hi, I tried what jayshields suggested but it didn't seem to work. Although I didn't receive an error message, the script didn't seem to make my mySQL table change at all. I was using the following code:volka wrote:Then it's either update-time or two querries likejayshields wrote:I would do it the long-winded way and use 2 queries, one for grabbing the ID of the row to update and one for updating it.
This isn't going to be a very good example, but this should work:Code: Select all
SELECT `ID` FROM `tbl` ORDER BY `ID` DESC LIMIT 3, 1 UPDATE `tbl` SET `whatever` = 'something' WHERE `ID` = $idfromabove
Code: Select all
<?php
mysql_connect("mysqlserver", "myusername", "mypassword") or die(mysql_error());
mysql_select_db("stpatsblog") or die(mysql_error());
$stpatsblogtext = mysql_real_escape_string($_POST['stpatsblogtext']);
$myid = mysql_query("SELECT id FROM stpatsblogtable ORDER BY id DESC LIMIT 3, 1") or die(mysql_error());
$result = mysql_query("UPDATE stpatsblogtable SET stpatsblogtext = '$stpatsblogtext' WHERE id = '$myid'") or die(mysql_error()); ?>Leo