Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP newbie help needed

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP newbie help needed

Postby flashybee » Tue May 20, 2014 10:10 am

I just follow one php tutorials wherein there is a html form and when the "ok" button will be pressed the insert query will be printed. 'Though I follow the tutorials it will not do the same as expected. Do anybody have some time to look into the code where I am gong wrong. I am new in PHP.

Code: Select all
<?php

include("mySqlConnect.php");

mysql_select_db($dbname,$testConnect)  or die (mysql_error());
// creating table

/*$sql= "CREATE TABLE `user`.`example`
             (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
         `firstname` VARCHAR(64) NOT NULL,
         
         `lastname` VARCHAR(64) NOT NULL,
          `region_name` INT ,
         `ssnumber` INT ,
         `age` INT)
          ENGINE = MyISAM;";
         mysql_query($sql) or die (mysql_error());
         print "Table Created  Successfully";
         */
         
         // inserting values in the table
         
         
         
   if(isset($function)&&$function=="add"){   
   print("This is the value");
      
         
$sqlInsert = "INSERT INTO  'user' . `example`(
                  firstName,
                  lastName,
                  region_name,
                  ssnumber,
                  age)
                  VALUES ('Tarun', 'Ghosh', 1, 44,54)";

                     
               print("$sqlInsert<br>");
                     
            

//mysql_query($sqlInsert) or die (mysql_error());
}

$sqlReg = "SELECT regionName,regionNumber FROM  regions";
$Result = mysql_query($sqlReg,$testConnect) or die (mysql_error());

    /*$row_nameCheck =mysql_fetch_assoc($Result);

   $firstNameValue = $row_nameCheck['regionName'];
   $middleNameValue = $row_nameCheck['regionNumber'];
   

    echo "This is the First Name:- $firstNameValue <br>";
    echo "This is the MIddle Name :- $middleNameValue <br>";*/
//$myrow = mysql_fetch_array($Result);
//print_r("$Result");

//echo $myrow['regionNumber'];

//print_r("$Result");


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<form id="enterForm" name="dateEnter" method="post" action="index.php?function=add">
Enter First Name: <input type="text" name="name" id="name"/><br />
Enter Last Name : <input type="text" name="lastname" id="lastname"/><br />
Select Region Number:
<select name="regionNumber"id="regionNumber">
 
 
     <option>
   <?php while ($myRow = mysql_fetch_array($Result)){ ?>
   <option value="<?php echo $myRow['regionNumber'];?>"><?php echo $myRow['regionNumber']. "-" .$myRow['regionName']; ?></option>
   
   <?php } ?>
   
   
   </option>

</select>
<br/>
Please Enter SS Number No Dashes:
<input type="text" name="ssnumber" id="ssnumber"/><br/>
Enter your age : <input type="text" name="age" id="age"/><br />
<input type="submit" name="addData" id="addData" value="Ok" />

</form>
</body>
</html>


If the question is not clear, Please ask and I will elaborate it.

Thanks.

flashybee
flashybee
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue May 20, 2014 10:04 am

Re: PHP newbie help needed

Postby flashybee » Wed May 21, 2014 5:56 am

No body here to respond?
flashybee
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue May 20, 2014 10:04 am


Return to PHP coding => General

Who is online

Users browsing this forum: mweingand and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron