-2

Recently i have been working over a contact module.There are 3 columns ie. name, email, phone and a +1 button which includes anew row to add one more contact filed using ajax. And here the problem arise. When i update my structure, the data in old contact field vanishes.

Eg:

I entered 2 rows and filled the data as name1, email1, and so on..

name1 email1 phone1
name2 email2 phone2

Now in order to add one more contact filed i use +1 botton. and as soon i click it i get:

blank_1 blank_1 blank_1
blank_2 blank_2 blank_2
blank_3 blank_3 blank_3   //here blank_1, blank_2, blank_3 are just expressing blank columns

My jquery code is :

$(document).ready(function(e) { num = 0; $('#plus_contact').click(function(e) { num = num +1 ; $.ajax({ url : 'contact/contact_form.php', method : 'POST', data : "number="+num, success : function(data) { $('#contact_form_div').html(data); }, }); }); });

contact_form.php

<?php
if(isset($_POST['number']) && is_numeric($_POST['number']))
{

    echo $list =$_POST['number'];
    if($list == 1)
    {
        for($i=0; $i<$list;$i++)
        {
        ?>
        <div class="form-group">
            <label class="sr-only" for="exampleInputEmail2">Full Name</label>
            <input type="text" name="c_name[]" class="form-control" id="c_full_name" placeholder="Full  Name">
        </div>
        <div class="form-group">
            <label class="sr-only" for="exampleInputEmail2">Email address</label>
            <input type="email" name="c_email[]" class="form-control" id="c_email_id"  placeholder="Email">
        </div>
        <div class="form-group">
            <label class="sr-only" for="exampleInputEmail2">Phone</label>
            <input type="tel" name="c_phone[]" class="form-control" id="c_phone_number" placeholder="Phone">
        </div>
        <?php
        }
    } } ?>

How can i add a row without altering the old row data ??

Rahul
  • 1,181
  • 1
  • 11
  • 20
  • No. You can't. If you are thinking about doing this, learn an actual programming language, not PHP. – Cole Tobin Aug 11 '13 at 17:15
  • 5
    Possible duplicate of http://stackoverflow.com/questions/9046675/convert-a-php-script-into-a-stand-alone-windows-executable – Taj Morton Aug 11 '13 at 17:15
  • 1
    How cool . If u have no answer then just gift the other with negative. – Rahul Aug 11 '13 at 17:16
  • @TajMorton I had a genuine question that jumped into 'my mind'. I hope i could get a solution here. but... – Rahul Aug 11 '13 at 17:24
  • 1
    @Rahul Yes, it is. And, in general, unless you have good reason, why something is not possible, it should be counted as possible. Does it worth to write desktop application with php? It's another question and the answer is definitely _no_. – Leri Aug 11 '13 at 17:26
  • That's not what SO is for. If something "jumps into your mind" then research it, and if it proves to be an interesting / hard to solve problem, ask here. – Janis F Aug 11 '13 at 17:27
  • @Cole"Cole9"Johnson yeah, you can create windows desktop apps only with MASM. – Leri Aug 11 '13 at 17:30
  • Well, there is php-gtk... which I presume dead or at least on its deathbed. – Wrikken Aug 11 '13 at 17:31
  • @PLB MASM is assembly. Assembly is programming. I don't view PHP as programming. – Cole Tobin Aug 11 '13 at 17:31
  • 3
    @Cole"Cole9"Johnson lol, ok. You can have your own views. – Leri Aug 11 '13 at 17:34
  • @TajMorton That question is talking about a cli application, which in my oppinion is not equal to a desktop application as the OP stated. Although I'm quite sure this question was asked before, that question is not the duplicate imho. – Damien Overeem Aug 11 '13 at 18:02

1 Answers1

3

Since nobody cares to even point Rahul in the right direction, I will provide atleast something.

There have been several projects to allow PHP to be used for desktop application development.

  1. http://gtk.php.net/
  2. http://wxphp.org/

So natively, no PHP can't be used for desktop application development, but that doesn't mean there is no way to do it.

Zend actually posted an article about it: http://devzone.zend.com/1129/developing-desktop-applications-in-php-for-beginners/

Hope this helps..

Damien Overeem
  • 4,487
  • 4
  • 36
  • 55
  • In fact, @TajMorton posted [dupe](http://stackoverflow.com/questions/18174528/can-application-run-without-server-as-exe-file-does#comment26627584_18174528) – Leri Aug 11 '13 at 17:52
  • Possible dupe for now. And since the OP talked about "Desktop application", its not the same thing. The other post talks about a CLI application he wants as an .exe. – Damien Overeem Aug 11 '13 at 17:55