第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何將圖像值從語句中的變量傳遞到另一個(gè) PHP 文件

如何將圖像值從語句中的變量傳遞到另一個(gè) PHP 文件

PHP
絕地?zé)o雙 2022-11-04 16:45:55
嘿,所以我試圖從我的 PHP 文件中傳遞值,我將數(shù)據(jù)從數(shù)據(jù)庫中拉到另一個(gè) PHP 文件到一個(gè)標(biāo)簽,我試圖在我進(jìn)行查詢的同一個(gè)文件上顯示我的圖像,它確實(shí)有效,但我需要它在另一個(gè)文件中。謝謝    if($image!="")    {        $res = mysqli_query($link,"SELECT * FROM lug_num WHERE lug_id= $image");        $array = array();        ?><br><br><div id = img_lug><?php        while($row=mysqli_fetch_array($res))        {                        global $img;                        $img = $row["image"];            //echo $img;                        ?><img src="<?php echo $img;  ?>"  width='200' height='200' /><?php                                    }            ?></div><?php這是我獲取并可以顯示圖像的文件,我需要另一個(gè)文件中的 $img 變量更新所以我嘗試了會(huì)話它沒有工作說我有太多的會(huì)話我嘗試了功能相同的交易不想工作有什么方法可以用腳本完成嗎?謝謝
查看完整描述

2 回答

?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

ajax.php


<?php

    $link=mysqli_connect("localhost","root","123456");

    mysqli_select_db($link,"demo");

     error_reporting(0);

    $make =$_GET["make"];

    $model = $_GET["model"];

    $year = $_GET["year"];

    $oem = $_GET["oem_number"];

    $lug = $_GET["lug_number"];

    $image = $_GET["lug_number"];



if($make!="")

{


    $res = mysqli_query($link,"SELECT * FROM models WHERE make_id= $make");

    echo "<select id='modeldd' onchange='change_model()'>";

    echo "<option selected = '' disabled=''>";echo "Select Model";echo "</option>";

    while($row=mysqli_fetch_array($res))

    {

        echo "<option value = '$row[model_id]'>"; echo $row["model"]; echo "</option>";


    }

    echo "</select>";

}

if($model!="")

{

    $res = mysqli_query($link,"SELECT * FROM year WHERE model_id= $model");

    echo "<select id='yeardd' onchange='change_year()'>";

    echo "<option selected = '' disabled=''>";echo "Select Year";echo "</option>";

    while($row=mysqli_fetch_array($res))

    {


        echo "<option value = '$row[year_id]'>"; echo $row["year"]; echo "</option>";


    }

    echo "</select>";

}

if($year!="")

{

    $res = mysqli_query($link,"SELECT * FROM oem WHERE year_id= $year");

    echo "<select id='oemdd' onchange='change_oem()'>";

    echo "<option selected = '' disabled=''>";echo "Select OEM number";echo "</option>";

    while($row=mysqli_fetch_array($res))

    {


        echo "<option value = '$row[oem_id]'>"; echo $row["oem_number"]; echo "</option>";


    }

    echo "</select>";

}

if($oem!="")

{

    $res = mysqli_query($link,"SELECT * FROM lug_num WHERE oem_id= $oem");

    echo "<select id='lugdd' onchange='change_lug()'>";

    echo "<option selected = '' disabled=''>";echo "Select lug number";echo "</option>";

    while($row=mysqli_fetch_array($res))

    {


        echo "<option value = '$row[lug_id]'>"; echo $row["lug_number"]; echo "</option>";


    }

    echo "</select>";


}

if($lug!="")

{

    $res = mysqli_query($link,"SELECT * FROM fix_type WHERE lug_id= $lug");

    echo "<select>";

    echo "<option selected = '' disabled=''>";echo "Select fix type";echo "</option>";

    while($row=mysqli_fetch_array($res))

    {

        $test = $row["fix_name"];

        echo "<option value = '$row[fix_id]'>"; echo $row["fix_name"]; echo "</option>";


    }

    echo "</select>";

}

$img = ""


if($image!="")

{

    $res = mysqli_query($link,"SELECT * FROM lug_num WHERE lug_id= $image");

    $array = array();

    ?><br><br><div id = img_lug><?php

    while($row=mysqli_fetch_array($res))

    {


        $img = $row["image"];

        //echo $img;


        ?><img src="<?php echo $img;  ?>"  width='200' height='200' /><?php



    }

        ?></div>

<?php } ?>


索引.php


<?php

    $link=mysqli_connect("localhost","root","123456");

    mysqli_select_db($link,"demo");


?>


<!DOCTYPE html>

<html>

<head>

    <title></title>

</head>

<body>

    <form name="form1" action="" method="post">

        <table>

            <tr>

                <td>Select Make</td>

                <td><select id="makedd" onchange="change_make()">

                    <option>Select</option>

                    <?php

                        $res = mysqli_query($link,"SELECT * FROM `manufacturer`");

                        while($row=mysqli_fetch_array($res))

                        {

                            ?>


                            <option value="<?php echo $row["make_id"];?>"><?php echo $row["make"] ?></option>

                            <?php

                        }

                    ?>

                </select></td>

            </tr>

            <tr>

                <td>Select Model</td>

                <td>

                    <div id="model">

                        <select>

                            <<option selected="" disabled="">Select Manufacturer</option>

                        </select>

                    </div>

                </td>


            </tr>

            <tr>

                <td>Select Year</td>

                <td>

                    <div id="year">

                        <select>

                            <option>Select Year</option>


                        </select>

                    </div>

                </td>


            </tr>

            </tr>

            <tr>

                <td>Select OEM Number</td>

                <td>

                    <div id="oem">

                        <select>

                            <option>Select OEM Number</option>


                        </select>

                    </div>

                </td>


            </tr>                       

            <tr>

                <td>Select lug Number</td>

                <td>

                    <div id="lug">

                        <select>

                            <option>Select Lug Number</option>


                        </select>

                    </div>

                </td>


            </tr>

            <tr>

                <td>Select Fix type</td>

                <td>

                    <div id="fix" >

                        <select>

                            <option>Select Fix type</option>


                        </select>

                    </div>

                </td>


            </tr>

            <tr>

                <td>Image from lug</td>

                <td><div id="image">


                </div>

                </td>


            </tr>



        </table>

        <?php

        include "ajax.php";


        ?><img src="<?php include "ajax.php"; echo $img;  ?>"  width='200' height='200'  /><?php

        ?>


    </form>

<script type="text/javascript">

function change_make(){

    var xmlhttp=new XMLHttpRequest();

    xmlhttp.open("GET","ajax.php?make="+document.getElementById("makedd").value,false);

    xmlhttp.send(null);


    document.getElementById("model").innerHTML=xmlhttp.responseText;


}


function change_model() {

    var xmlhttp=new XMLHttpRequest();

    xmlhttp.open("GET","ajax.php?model="+document.getElementById("modeldd").value,false);

    xmlhttp.send(null);


    document.getElementById("year").innerHTML=xmlhttp.responseText;

}

function change_year() {

    var xmlhttp=new XMLHttpRequest();

    xmlhttp.open("GET","ajax.php?year="+document.getElementById("yeardd").value,false);

    xmlhttp.send(null);


    document.getElementById("oem").innerHTML=xmlhttp.responseText;

}

function change_oem() {

    var xmlhttp=new XMLHttpRequest();

    xmlhttp.open("GET","ajax.php?oem_number="+document.getElementById("oemdd").value,false);

    xmlhttp.send(null);


    document.getElementById("lug").innerHTML=xmlhttp.responseText;

}

function change_lug() {

    var xmlhttp=new XMLHttpRequest();

    xmlhttp.open("GET","ajax.php?lug_number="+document.getElementById("lugdd").value,false);

    xmlhttp.send(null);


    document.getElementById("fix").innerHTML=xmlhttp.responseText;

}



</script>

</body>

</html>



查看完整回答
反對 回復(fù) 2022-11-04
?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

你嘗試的方式是錯(cuò)誤的??矗愕?$image 變量可以是全局的,但你的循環(huán)不是全局的。它會(huì)給你循環(huán)的最后一個(gè)值。


1.將 $img 變量更改為本地變量。

2.然后創(chuàng)建一個(gè)新的全局變量。并給它這樣的值。


global $global_images;

$global_images.= "@".$row["image"]; // @ is just a separator.

3.現(xiàn)在在另一個(gè)頁面(你想要的地方),你必須再次創(chuàng)建基本循環(huán),像這樣


include "2.php";


$get_images=explode('@', $global_image);  //We can choose one by one the images with @ and explode function

//The loop

foreach ($get_images as $show){?>

<img src="<?php echo $show;  ?>"  width='200' height='200'>

<?php } ?>

據(jù)我了解,這正是您想要的?,F(xiàn)在您可以根據(jù)需要對其進(jìn)行自定義。


查看完整回答
反對 回復(fù) 2022-11-04
  • 2 回答
  • 0 關(guān)注
  • 122 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)