Page 1 of 1

[SOLVED] printf

Posted: Sun Aug 08, 2004 11:12 pm
by ol4pr0
Warning: printf() [function.printf]: Too few arguments in line 17

I am trying to get an output in columns, dont know if i am on right track there. but i am trying it like this

1234 1234 1234 1234
1234 1234 1234 1234
1234 1234 1234 1234
ect..

Code: Select all

$columns = 3;
$counter = 0;
echo "<table><tr>";
$query = "SELECT * FROM <table>";
$result = mysql_query($query);
$COLUMNS = (int) 2; 
    $i = (int) 0;
    while ($row = mysql_fetch_array($result)) {
        if($i++ == 0) { 
            printf("<tr>"); 
        }
#line 17 below
        printf("<td align=center><a href="%s?id=%s">%s<br>%s</a></td> ", $_SERVER['PHP_SELF'], $row["species"]);
        if($i == $COLUMNS) { 
            printf("</tr>"); 
            $i = 0; 
        }
    }

    if($i > 0) { 
        while($i++ != $COLUMNS) { 
            printf("<td>&nbsp;</td>"); 
        }
        printf("</tr>"); 
    }

?>

Posted: Sun Aug 08, 2004 11:57 pm
by feyd
the format string you sent to printf has 4 strings it'll look for, you are only sending 2..

Posted: Mon Aug 09, 2004 12:07 am
by ol4pr0
Ah Thanks.