Click to See Complete Forum and Search --> : very new to mySql next and last recordeds


lomokev
11-12-2004, 03:39 AM
i know that my Sql query will only return one result so is there a better way to to print one row that doing the while way?

also what would be the essayist way of finding the 'id' of the recored before and after this one where section = 'gagsandstrips' with out doing some kind of loop?

<?php
require_once('inc/db_connect_inc.php');

$sql = "SELECT * FROM work WHERE section = 'gagsandstrips' AND id = 23;";
$rs = mysql_query($sql);

while($row = mysql_fetch_assoc($rs)){
echo $row['id'] . " " . $row['tittle'] ;
}

?>

96turnerri
11-12-2004, 09:48 AM
there are other ways of getting a row but thats the way i doit with one alteration, i use $rs = mysql_query($sql) or die(mysql_error()); instead of just $rs = mysql_query($sql) this will tell you if you have an error

the next what do you mean next, where id=24? what would be the SQL query you would run to get the next one manually i done mean automatic i should be able to get something auto from the manual query you give