darwin rom darwin rom - 1 year ago 146
MySQL Question

How can I achieve output id and update table

I want get id from this output and Update database how i can get From This query?

$text = "<test>output: 1;outdoor: 456;<test>
<test>output: 2;outdoor: 4564;<test>
<test>output: 3;outdoor: 645;<test>
<test>output: 4;outdoor: 765;<test>";

mysql_query("UPDATE test SET outdoor = $outdoor" where id = $output);

Answer Source

please try my answer

<?php 
    $text = "<test>output: 1;outdoor: 456;<test>
    <test>output: 2;outdoor: 4564;<test>
    <test>output: 3;outdoor: 645;<test>
    <test>output: 4;outdoor: 765;<test>";
    $text_arr = explode("\n",$text);

    foreach($text_arr as $val_text_arr){
        /*echo $val_text_arr."<bR>";*/
        $output = explode(";",explode("output: ",$val_text_arr)[1])[0];
        echo "output ".$output ."\n";
        $outdoor = explode(";",explode("outdoor: ",$val_text_arr)[1])[0];
        echo "outdoor ".$outdoor ."\n";
        /*you can update here ypur query*/
        mysql_query("UPDATE test SET outdoor = $outdoor" where id = $output);
    }
     ?>

output:

output 1
outdoor 456
output 2
outdoor 4564
output 3
outdoor 645
output 4
outdoor 765

php link where i try this https://eval.in/872778

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download