0

I have 2 system, the interface I build with PHP and the machine is build with python because I use fuzzy in python.

I have to try get the specific data with PHP and that work

And i have make a function with python to recieve a variable and that work

But I have a problem

The problem is, how to throw a variabel from MySQL with PHP and process it with python ?

after that finish the process, how to throw back the result to PHP and then send to mySQL databases?

The code in php like this, the code is to grab the data from sql

function fuzzy($id = '')
    {   
        $data_sg1 = core::selectWhereCollums('area_proses','default','sg1',array('id'=>$id));
        $data_sg2 = core::selectWhereCollums('area_proses','default','sg2',array('id'=>$id));
        $data_sg3 = core::selectWhereCollums('area_proses','default','sg3',array('id'=>$id));


        $this->session->set_flashdata('success','success');
        redirect('area_proses');
    }

and the code in python like this

def hitung_fuzzy(masukan_sg1, masukan_sg2, masukan_sg3):
    sg1 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg1')
    sg2 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg2')
    sg3 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg3')

---------------------
--------------------

####################################################
#Masukan
start_time = time.time()
a = float(input("Masukan SG1: "))
b = float(input("Masukan SG2: "))
c = float(input("Masukan SG3: "))

z = hitung_fuzzy(a,b,c)

print ("--------------------------------\n")
print ("Hasil Perhitungan:\n")
print (z)
print ("--------------------------------\n")
print ("Waktu proses adalah :\n")
print("%s detik\n" % (time.time() - start_time))
print ("--------------------------------\n")
raw_input("Tekan enter untuk keluar")
5
  • please add some code and go to more details Commented Oct 28, 2017 at 8:53
  • Not an answer to the question, but Django is a good python framework for making online apps. You can pass SQL to the python script (I think) and don't have to touch PHP at all (I think). But I'm no Django expert, so I could be completely wrong. Commented Oct 28, 2017 at 8:54
  • Even though I am a PHP-guy, I would recommend using Python all the way through. No need to add extra complexity where it really isn't needed. Commented Oct 28, 2017 at 9:17
  • @shotgunner the code have done add Commented Oct 28, 2017 at 9:17
  • @alex the code has been added Commented Oct 28, 2017 at 9:18

1 Answer 1

0

The simplest solution would be to use PHP's exec function. Of course this is with assumption that the Python code accept command line arguments and gives its output in stdout (and/or stderr). If the Python itself is another standalone web service, then the solution would be different. So, if you want more specific answer you must give more specific details.

Sign up to request clarification or add additional context in comments.

1 Comment

then my answer already fits your needs, just click that exec link and read on how to use it

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.