PHP - Php Beginer
hello guys im beginer with php
sory for my simple and first step questions i have create a page that reads some data from an sql table and displays them, this works but i have some questions 1st the mysql_select_db($db)or die(mysql_error()); means if some error ocoure the connection will close or the entire web pages closes?? 2st is some way to create for each record a dynamic submit button with button text the name of the record? eg id name 1 george 2 nick 3 liana so to create 3 submit buttons with names george nick liana and when i press any button to make an acion thanks Similar TutorialsHello people I'm having some trouble, and I kind think I know what it is, but for some reason I just can't figure it out. I think I need an isset function, but I'm not sure where to put it? Here is my code followed by my errors. <?php echo"<?xml version=\1.0\"encoding=\UFT-8\"\x3f>"; echo"\n"; ?> <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"lang="en"> <head> <title>My Second PHP Generated Document</title> </head> <body> <?php if (isset($_POST['submit'])) { if ($_POST['submit'] == "Clear") { $workValue = ""; $workType = ""; } elseif ($_POST['submit'] == "Calculate") { $workValue = $_POST['vfld']; $workType = $_POST['tfld']; $calcValue = (float) $workValue; if (empty($_POST['vfld'])) { echo "<h3>Error</h3>"; echo "<p>You must enter a value!</p>\n"; } elseif ($calcValue == 0) { echo "<h3>Error</h3>"; echo "<p>You must enter a number!</p>\n"; } elseif ($calcValue < 0) { echo "<h3>Error</h3>"; echo "<p>You must enter a positive number!</p>\n"; } elseif (empty($_POST['tfld'])) { echo "<h3>Error</h3>"; echo "<p>You must select a calculation type!</p>\n"; }} else { switch ($workType) { case "circle": $areaValue = $calcValue * $calcValue * pi(); break; case "square": $areaValue = $calcValue * $calcValue; // echo "The area of a square whose sides are" break; case "triangle": $halfSide = $calcValue/2; $otherSide = sqrt(($calcValue * calcValue) - ($halfSide * halfSide)); $areaValue = $otherSide * $halfSide; echo "The area of an equilateral triangle whose sides are $calcValue} is {areaValue}."; break; }} } ?> <form method="post" action="hw04.php" id="form1" name="form1"> <p> Enter a number here : <input type="text" id="vfld" name="vfld" value="<?php echo $workValue; ?>"/> </p> <p> This number is a: <br /> <input type="radio" name="tfld" value="circle" <?php if ($workType == "circle") { echo 'checked="checked"'; } ?> /> : the radius of a circle <br /> <input type="radio" name="tfld" value="square" <?php if ($workType == "square") { echo 'checked="checked"'; } ?> /> : the length of one side of a square <br /> <input type="radio" name="tfld" value="triangle" <?php if ($workType == "triangle") { echo 'checked="checked"'; } ?> /> : the length of one side of an equilateral triangle </p> <p> <input type="submit" name="submit" value="Calculate" /> <input type="submit" name="submit" value="Clear" /> </p> </form> <div id="footer"> <pre>This page written by: <cite>James Cozzy</cite> ©2011 and beyond</pre> </div> </body> </html> And my errors Enter a number here : This number is a: Notice: Undefined variable: workType in /studfs1/j-cozzy/homepage/CISS-225/hw04.php on line 69 /> : the radius of a circle Notice: Undefined variable: workType in /studfs1/j-cozzy/homepage/CISS-225/hw04.php on line 74 /> : the length of one side of a square Notice: Undefined variable: workType in /studfs1/j-cozzy/homepage/CISS-225/hw04.php on line 79 /> : the length of one side of an equilateral triangle any help would be much appreciated? |