p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: what is the function of "%s"


Message #1 by "Barney Chastain" <barney@v...> on Tue, 30 Jan 2001 11:31:58 -0600
Greetings,

I can seem to find this documented, but I've now seen it in a couple of

scripts. What does the %s do? Is it acting as some sort of wildcard, or is

it shorthand for "insert string here"? Are there other "%" expressions?



Thank you,



Barney Chastain



[Code follows]



$query = "SELECT * FROM members ORDER BY primary_key ";

$result = mysql_query ($query)

	or die ("Cannot execute query\n");



print ("<table>\n");

# read results of query, then clean up

while ($row = mysql_fetch_row ($result))

{

	print ("<tr>\n");

	for ($i = 0; $i < mysql_num_fields ($result); $i++)

	{

		# escape any special characters and print

		printf ("<td>%s</td>\n", htmlspecialchars ($row[$i]));

	}

	print ("</tr>\n");

}

mysql_free_result ($result);

print ("</table>\n");




  Return to Index