[SOLVED] printf

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

[SOLVED] printf

Post 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>"); 
    }

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the format string you sent to printf has 4 strings it'll look for, you are only sending 2..
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Ah Thanks.
Post Reply