-6
 <div class="row" id="related_campaigns">
    <div class="span6">
            <div class="control-group">
    <label class="control-label" for="inputgaveabonnement">
    Campaign<b>*</b>
    </label>
    <div class="controls">
      <div class="fieldrow_horz1">
        <div class="fieldgroup">
          <label>
           Name <b>*</b>
          </label>
        </div>
        <div class="fieldgroup">
          <label>
            Image <b>*</b>
          </label>
        </div>
         <div class="fieldgroup">
          <label>
            Url <b>*</b>
          </label>
        </div>
      </div>
    </div>
      <?php

    // Save to array so that we can loop it out later =)

            $result = db2_getrelcamp( array('campaigns_id' => $this_id) );

            if (!is_null($result))
            {
      $numsub1 = 0;
                while ( $row = $result->fetch_object() )


                {
        $numsub1 = $numsub1 +1;
        array_push($arrcampaignname, $row->campaignname);
        array_push($arrcampaignimage, $row->campaignimage);
        array_push($arrcampaignurl, $row->campaignurl);
                }
      $formcountfld1=$numsub1;
            }
    else
    {
    $numsub1=1;
    $formcountfld1=1;
    }

    $i = 1;

    if (1==1) {

        for ($i = 1; $i <= $numsub1; $i++) {
    ?>
      <div class="fieldrow_horz1">

        <div class="fieldgroup">
          <input type="text" id="campaignname_<?= $i ?>" name="campaignname_<?= $i ?>" value="<?= isset($arrcampaignname[$i-1]) ? $arrcampaignname[$i-1] : '' ?>" />
        </div>

        <div class="fieldgroup">

            <select  id="campaignimage_<?= $i ?>" name="campaignimage_<?= $i ?>" alue="<?= isset($arrcampaignimage[$i-1]) ? $arrcampaignimage[$i-1] : '' ?>" />
                <?php
                    // * Hæmta alla filer i mappen
                    $dir = "../images/campaigns/";
                    $files = scandir($dir);
                    $strSelected = "";
                    $somethingChecked = false;

                    foreach($files as $key => $value)
                    {
                        if ($value != '.' && $value != '..')
                        {
                            if ( $formImage === $value ) {
                                $strSelected = ' selected="selected"';
                                $somethingChecked = true;
                            } else
                                $strSelected = '';

                            echo '<option value="' . $value . '"' . $strSelected . '>' . $value . '</option>';
                        }
                    }
                ?>
                <?php
                    if ($somethingChecked) {
                        $strSelected = '';
                    } else {
                        $strSelected = ' selected="selected"';
                    }
                    echo "<option disabled='disabled'></option>";
                    echo '<option value=""' . $strSelected .'>- Ikke bruk bilde -</option>';
                ?>
                </select>

                <p class="help-block">A Related image for this campaign from your image archive (<a href="image.php" target="_blank">upload</a>).</p> 
        </div>

          <div class="fieldgroup">

  <input type="text" id="campaignurl_<?= $i ?>" name="campaignurl_<?= $i ?>" value="<?= isset($arrcampaignurl[$i-1]) ? $arrcampaignurl[$i-1] : '' ?>" />

        </div>
 <img src="../images/remove.png" alt="Delete"  class="link" id="remove_<?= $i ?>"  />

      </div>

<?php /*?>value="<?= isset($arrEtternavn[$i-1]) ? $arrEtternavn[$i-1] : '' ?>"
<?php value="<?= $arrEtternavn[$i-1] ?>" */?>          <?php

                }

        } else {

    ?>

      <div class="fieldrow_horz1" >

        <div class="fieldgroup">
          <input type="text" id="campaignname_<?= $i ?>" name="campaignname_<?= $i ?>" value="" />
        </div>

        <div class="fieldgroup">

            <select  id="campaignimage_<?= $i ?>" name="campaignimage_<?= $i ?>" class="span3" >
                <?php
                    // * Hæmta alla filer i mappen
                    $dir = "../images/campaigns/";
                    $files = scandir($dir);
                    $strSelected = "";
                    $somethingChecked = false;

                    foreach($files as $key => $value)
                    {
                        if ($value != '.' && $value != '..')
                        {
                            if ( $formImage === $value ) {
                                $strSelected = ' selected="selected"';
                                $somethingChecked = true;
                            } else
                                $strSelected = '';

                            echo '<option value="' . $value . '"' . $strSelected . '>' . $value . '</option>';
                        }
                    }
                ?>
                <?php
                    if ($somethingChecked) {
                        $strSelected = '';
                    } else {
                        $strSelected = ' selected="selected"';
                    }
                    echo "<option disabled='disabled'></option>";
                    echo '<option value=""' . $strSelected .'>- Ikke bruk bilde -</option>';
                ?>
                </select>

                <p class="help-block">A Realated image for this campaign from your image archive (<a href="image.php" target="_blank">upload</a>).</p>
        </div>






        <div class="fieldgroup">
          <input type="text" id="campaignurl_<?= $i ?>" name="campaignurl_<?= $i ?>" value="" />
        </div>

      </div>

      <?php

        }

    ?>



      <?php
                $thisId = "countfld1";
                $thisVar = $formcountfld1; ?>

      <input type="hidden" name="<?= strtolower($thisId) ?>" class="input-medium" id="input<?= $thisId ?>" value="<?= htmlspecialchars($thisVar, ENT_QUOTES) ?>" />

      <p class="leggtil1">

        <a href="#"  id="linkAdd1">+ Legg til flere</a>

      </p> 

    </div>
    </div>
    </div>

我想在数据库中存储多个 aticle 值,如标题、图像和 url,但它只在 db 中存储一个值任何建议。提前谢谢

4

1 回答 1

0

查看文档

serialize();
unserialize();

它们基本上将数组或对象编码和解码为基于特定文本的编码字符串,有点像JSON,但不是 JSON。

它们到处都在使用,例如看一个 wordpress 数据库。

连载()

反序列化()

于 2013-07-18T10:59:12.783 回答