PHP - Gernerate Multiple columns in PHP

Asked By sathish on 25-Jun-12 03:16 AM
Earn up to 30 extra points for answering this tough question.
Dear Team..

I Don't know how to generate multiple columns in php.
What I need is
I have a Mysql table in which two fields are there one is auto_increment and next is name which is in varchar.
By using PHP I want to insert the more than one name at a time
Now I can able insert one by one but I want to insert more than one.
I want to create more textboxes with the same at backend I want to get that names in array and then I want to insert.

Pls help me how to generate multiple columns in php..

Thanks in Advance.
Your response will  help me more............
Jitendra Faye replied to sathish on 26-Jun-12 12:50 AM
As you told that you want to add column to table using php code, then use this sample code-

@mysql_query("ALTER TABLE `tablename` ADD `$colname` VARCHAR( 100 )") or die(mysql_error()); 


If you want to add more column then create one array of columns and using loop peform ALETR
command on table,


Hope this will help you.
sathish replied to Jitendra Faye on 26-Jun-12 02:13 AM
Thanks for your response...

But I dont want the back end mysql code, What I need is I want to create more textbox dynamically in php before submitting I want to enter the fields in textbox.
Anil Kumar replied to sathish on 18-Aug-12 05:57 AM
Hi Sathish,

I am writing the code below to insert values for textboxes using only one simple query. It will allow you to take the values from textboxes in the array named "values" in my code. Go through the code and connect back for anything you need.

CODE:
you store values in array "values" from text boxes:
foreach($value as $key => $values){
@mysql_query("insert into `tablename` (name) values('"$value"')") or die(mysql_error()); 
}

Thanks and Regards
Anil K.
help
here i will show how you can read text file in PHP <?php $myFile = "mytext.txt"; $f = fopen($myFile, 'r'); $theData = fread($f, 5); fclose($fh); echo $theData; ?> Read text file in PHP ( 465 Views ) keywords: fread, fopen, fclose description: here i will show how you can read text file in PHP
A php server script block can be written in shorter format without using php name Usually a php server side script block is written between <?php and ? > This could be written inside the shorter format as <? and ?> However , as to use supporting shorter format and for maximum compatibility it is recommended to use first specified one <?php and ?> short format of server script tag in php ( 754 Views ) keywords: php, server, script block, compatibility, shirter format description: A php server script
How you can make your own captcha code Image in php. Here we have three Files : 1) Image.php , which is used to create Captcha code image. 2) form.php, which is used to shown captcha code image and take input from user. 3) Result php, is used to check whether the Code in image and the user entered both are same or not. Image .php = = = = = = = = = = = = = = = = = = = = = = = = = <?php header("Content-type: image / png"); $string = "abcdefghijklmnopqrstuvwxyz0123456789"; for($i = 0;$i<6;$i++){ $pos = rand
Hi. . i need to send emails using PHP with linux environment. pls help me. . . Try this <?php require_once "Mail.php"; $from = "Sandra Sender <sender@example.com> "; $to = "Ramona Recipient <recipient@example.com> "; $subject = "Hi!"; $body p> " . $mail-> getMessage() . "< / p> "); } else { echo("<p> Message successfully sent!< / p> "); } ?> Refer -> Sending Mail from PHP Using SMTP Authentication - Example http: / / email.about.com / od / emailprogrammingtips / qt / PHP_Email_SMTP_Authentication.htm Thanks for already tried that code. . windows envirnment is work . . .but its not work with linux envirenment . PHP send email using PHP SMTP mail Pear functions. Following code is well commented, you need to make necessary changes
This explains how to connect to MySql from PHP mysql_connect is the method used to connect to the mysql from php and it takes three parameters namely host, username and password of the mysql instance. <?php $mshost = 'localhost'; $msuid = 'user'; $mspwd = 'password'; $mscon = mysql_connect($mshost, $msuid, $mspwd); if( $mscon ) { echo 'Connected with the introduction of support of stored procedures short format of server script tag in php A php server script block can be written in shorter format without using php name Connect to MySql from PHP ( 497 Views ) keywords: mysql_connect, php, mysql, echo, <?php, localhost
Hai friend's i am new to the PHP field , i just know some concept about the PHP so i preferred this forum . . . my friend's sadi this forum is really good and they got quick reply . . . Now i need the PDF PHP book to learn form the basic' s Thank YOu http: / / php.org / http: / / www.ebookpdf.net / php_13_ _ebook_.html above site is one of my favourite. It will provide collection of 53 php ebooks for free download. And contains all the ebooks for every languages keywords PHP Hai, PHP book, PDF BOOK description: PDF BOOK for PHP Hai friend's i am
please send me the code sending email using php hi, Send Email from a PHP Script Using SMTP Authentication To connect to an outgoing SMTP server from a PHP script using SMTP authentication and send an email: • Make sure the PEAR Mail package is installed. • Typically, in particular with PHP 4 or later, this will have already been done for you. Just give it a user name used to retrieve mail). • password : the password for SMTP authentication. Sending Mail from PHP Using SMTP Authentication - Example <?php require_once "Mail.php" ; $from = "Sandra Sender <sender@example.com> " ; $to = "Ramona Recipient <recipient@example.com
I want to develop calculator in PHP.It is possible when we click a button(e.g 1) then waht may be value of button displayed in textbox in php?I want to create 9 button label 1, 2, 3, 4, 5, 6, 7, 8 9.thank you for simple calculater refer this http: / / www.webdesign.org / web-programming / php / php-calculator.10025.html http: / / blog.codebeach.com / 2008 / 01 / create-calculator-in-php.html Hi This is a complete code in PHP, Javascript, and HTML to create Calculator <HTML> <HEAD> <TITLE> HTML Calculator< / TITLE> <SCRIPT language = "JavaScript
Hi. . i need a grid view to display data using php. . . pls help me to find a source code of best grid view Use PHP Datagrid The basic PHP datagrid requires only as little as five lines of code. Foremostly, always create phpGrid object set_sql ("SELECT * FROM Employees"); $dg -> set_sql_table ("Employees"); $dg -> set_sql_key ("EmployeeId"); $dg -> display(); Regards For the PHP you can do the Gridview data display by using the Table and using TD and display the data and for pagination you can use some scripting for that because in PHP TABLE or DIV is the best to display the data You have to add the But it is not based on Ajax, it loads entire data in one shot. Actual PHP Grid you can find it here http: / / www.phpgrid.com / grid / examples / example1.php • echo