Jump to content

Archived

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

tecdesign

trouble with max() in sql

Recommended Posts

[code]
while ($i < $l){
$query = mysql_query("SELECT max( topicid ) as topicmax
FROM topics");

$max_check = mysql_num_rows($query);

if($max_check > 0){
    while($row = mysql_fetch_array($query)){
    foreach( $row AS $key => $val ){
        $$key = stripslashes( $val );
}
session_register('topicmax');
$_SESSION['topicmax'] = $max;
}
}


$maxit = $max - $i;
[/code]

Ok what I am having trouble with is I want to take max (topicid) from the sql statement and pretty much make $max = max(topicid). Does anyone know how to do this?

Share this post


Link to post
Share on other sites

[code]$query = mysql_query("SELECT max( topicid ) FROM topics");
$max = mysql_result ($query, 0);[/code]

Share this post


Link to post
Share on other sites

×

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.