1
Beginners - Learning PHP / Re: Is Precedural Enough?
« on: July 22, 2012, 08:49:14 PM »
Thank you so much for the very insightful response, Andrew.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
<html>
<head>
<title>Factorial Test</title>
</head>
<body>
<?php
$var = rand % 10;
$counter = $var;
$echo_var = $var;
while ($counter > 1) {
$var = $var * ($counter - 1);
$counter--;
}
echo "The Factorial of $echo_var is: $var";
?>
</body>
</html>$_SESSION['cart'] = array();
$_SESSION['cart'][1] = 10;
$_SESSION['cart'][6] = 5;$query = "SELECT count(commentid) from comments where jokeid = $jokeid";
$result = mysql_query($query);
$row=mysql_fetch_array($result);
if ($row[0] == 0)
{
echo "No comments posted yet. \n";
} else
{
echo $row[0] . "\n";
echo " comments posted. \n";$query = "Select count(prodid) from products where catid = $catid";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if ($row[0] == 0)
{
echo "<h2><br>Sorry, there are no products in this category</h2>\n";
}
else
{
$totrecords = $row[0]; //create thumbnail
$width = imageSX($SourceImage);
$height = imageSY($SourceImage);
$newThumb = imagecreatetruecolor(80, 60);
//resize image to 80 x 60
$result = imagecopyresampled($newThumb, $SourceImage,
0, 0, 0, 0,
80, 60, $width, $height);
//move image to variable
ob_start();
imageJPEG($newThumb);
$thumbnail = ob_get_contents();
ob_end_clean();<html>
<body>
<form action="hello-web.php" method="GET">
<label>Name:</label>
<input type="text" name="yourName" size="24">
<input type="submit">
</form>
</body>
</html>?php
$fname = $_GET["yourName"];
echo "Hello $fname!";
?>echo "<a href=\"index.php?content=register\">Try again</a><br>;
echo "<a href=\"index.php\">Return to Home</a>;echo "<input name=\"goButton\" type=\"submit\" value=\"browse\" />;
echo "<input name=\"content\" type=\"hidden\" value=\"edit\" />;echo "<input name="goButton" type="submit" value="browse"