troubleshooting Question

PHP Implode - Multiple List database entry

Avatar of mnewm
mnewm asked on
PHPAdobe DreamweaverMySQL Server
3 Comments2 Solutions2615 ViewsLast Modified:
Problem:
Multiple list inserted into database field as one entry.

Question:
I can insert the last choice selected from the multiple list, and have had no success with PHP implode. What am I missing?

Code:
<?php require_once('Connections/conn_SushiSUshi.php'); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("WA_DigitalFilePro/HelperPHP.php"); ?>
<?php $array_stores = array('store');
$comma_sep = implode(",", $array_stores);

mysql_select_db($database_conn_SushiSUshi, $conn_SushiSUshi);
$query_rs_StorefinderInclude = "SELECT ID, name FROM storefinder ORDER BY name ASC";
$rs_StorefinderInclude = mysql_query($query_rs_StorefinderInclude, $conn_SushiSUshi) or die(mysql_error());
$row_rs_StorefinderInclude = mysql_fetch_assoc($rs_StorefinderInclude);
$totalRows_rs_StorefinderInclude = mysql_num_rows($rs_StorefinderInclude);

mysql_select_db($database_conn_SushiSUshi, $conn_SushiSUshi);
$query_rs_storefinderSelect = "SELECT * FROM storefinder ORDER BY name ASC";
$rs_storefinderSelect = mysql_query($query_rs_storefinderSelect, $conn_SushiSUshi) or die(mysql_error());
$row_rs_storefinderSelect = mysql_fetch_assoc($rs_storefinderSelect);
$totalRows_rs_storefinderSelect = mysql_num_rows($rs_storefinderSelect);?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
      WA_DFP_UploadFile("WA_UploadResult1", "cv", "", "../admin/sushisushi/staff/cv/", "".((isset($_POST["fName"]))?$_POST["fName"]:"")  ."".((isset($_POST["lName"]))?$_POST["lName"]:"")  ."", "2", "[FileName]_[Increment]", "0", "false", "0", "0");
}
?><?php
// WA Application Builder Insert
if (isset($_POST["Submit"])) // Trigger
{
  $WA_connection = $conn_SushiSUshi;
  $WA_table = "messageCentre";
  $WA_sessionName = "messageCentre_ID";
  $WA_redirectURL = "sushi-contact-thanks.php";
  $WA_keepQueryString = false;
  $WA_indexField = "ID";
  $WA_fieldNamesStr = "dateSubmitted|store|comment|contactMethod|fName|lName|email|sushiNewsletter|cv|add1|add2|suburb|state|townCity|county|telDay|telEve|postcode";
  $WA_fieldValuesStr = "".((isset($_POST["dateSubmit"]))?$_POST["dateSubmit"]:"")  ."" . "|" . "".((isset($_POST[$comma_sep]))?$_POST[$comma_sep]:"")  ."" . "|" . "".((isset($_POST["message"]))?$_POST["message"]:"")  ."" . "|" . "".((isset($_POST["preferredContact"]))?$_POST["preferredContact"]:"")  ."" . "|" . "".((isset($_POST["fName"]))?$_POST["fName"]:"")  ."" . "|" . "".((isset($_POST["lName"]))?$_POST["lName"]:"")  ."" . "|" . "".((isset($_POST["email"]))?$_POST["email"]:"")  ."" . "|" . "".((isset($_POST["receiveNews"]))?$_POST["receiveNews"]:"")  ."" . "|" . "http://www.sushisushi.com.au/admin/sushisushi/staff/cv/".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" . "|" . "".((isset($_POST["add1"]))?$_POST["add1"]:"")  ."" . "|" . "".((isset($_POST["add2"]))?$_POST["add2"]:"")  ."" . "|" . "".((isset($_POST["suburb"]))?$_POST["suburb"]:"")  ."" . "|" . "".((isset($_POST["state"]))?$_POST["state"]:"")  ."" . "|" . "".((isset($_POST["townCity"]))?$_POST["townCity"]:"")  ."" . "|" . "".((isset($_POST["county"]))?$_POST["county"]:"")  ."" . "|" . "".((isset($_POST["telDay"]))?$_POST["telDay"]:"")  ."" . "|" . "".((isset($_POST["telEve"]))?$_POST["telEve"]:"")  ."" . "|" . "".((isset($_POST["postcode"]))?$_POST["postcode"]:"")  ."";
  $WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
  $WA_fieldNames = explode("|", $WA_fieldNamesStr);
  $WA_fieldValues = explode("|", $WA_fieldValuesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  $WA_connectionDB = $database_conn_SushiSUshi;
  mysql_select_db($WA_connectionDB, $WA_connection);
  if (!session_id()) session_start();
  $insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
  $WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
  $MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
  $_SESSION[$WA_sessionName] = mysql_insert_id();
  if ($WA_redirectURL != "")  {
    if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
      $WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
    }
    header("Location: ".$WA_redirectURL);
  }
}
?>
<?php $relroot = "" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Contact SUSHI SUSHI&trade;</title>
<meta name="description" content="Ask us a question - tell us a bout your visit - talk to the SUSHI SUSHIT Chef">
<meta name="keywords" content="Sushi Sushi Chef Platter Victoria Australia Quality Nigiri boxes packs inari plate heroes Broadmeadows Camberwell Centro Box Hill Hawthorn Chadstone Broadmeadows Forest Frankston Highpoint Knox Melbourne Central Northland Prahan The Glen Pines Victoria Gardens Waverly Whitehorse ">
<meta name="robots" content="index,follow">
<script language="javascript" type="text/javascript" src="Scripts/formvalidate_general.js"></script>
<link href="2col_rightNav.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #0081AB}
#shareCare {position:absolute;
      width:621px;
      height:auto;
      z-index:101;
      left: 154px;
      top: 560px;
      background-color: #FFF;
      background-image:url(images/layerBg.jpg);
      background-position:bottom center;
      background-repeat:no-repeat;
      visibility: hidden;
      border: 1px solid #999999;
}
-->
</style>
<style type="text/css">
<!--
.style4 {
      color: #FFCC66;
      font-weight: bold;
}
-->
</style><?php include("includes/top.inc.php");?>
<div id="main">
<div id="content">
  <div>
    <h3> Work at <strong><img src="image/logo.gif" width="200" height="32" alt="Sushi Sushi Chef"></strong></h3>
    <p align="left"><strong><img src="image/chef1.jpg" alt="sushi sushi Chef" width="114" height="133" class="floatleft">Interested in working for  <a href="contact-sushi-sushi-form.php"><strong><img src="image/logoBody.gif" alt="sushi sushi" width="114" height="12" border="0"></strong></a>?</strong><strong> Fill out the form below and someone will get back to you! </strong></p>
    <p>Thank You very much!</p>
    <p><strong><a href="sushi-storefinder.php"><img src="image/logoBody.gif" alt="sushi sushi" width="114" height="12" border="0"></a></strong> Chef
      <hr>
            <form action="<? $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="general" id="rateweb" onSubmit="return checkform();">
    <TABLE width="625" cellPadding="1" cellSpacing="1" id="Table1">
      <TR>
        <TD valign="top" style="WIDTH: 239px"><TABLE width="100%" cellPadding="1" cellSpacing="0" class="copydark" id="Table2">
           
            <TR>
              <TD valign="top" noWrap><P align="right"><font color="#ff0000">
                <input name="dateSubmit" type="hidden" value="<? echo date("D, j/m/y");?>">
              </font>First Name<FONT color="#ff0000">*</FONT></P></TD>
              <TD valign="middle"><input name="fName" type="text" maxlength="50" id="fName" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><P align="right">Surname<FONT color="#ff0000">*</FONT></P></TD>
              <TD vAlign="middle"><input name="lName" type="text" maxlength="50" id="lName" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><P align="right" >Email Address<FONT color="#ff0000">*</FONT></P></TD>
              <TD vAlign="middle"><input name="email" type="text" maxlength="150" id="email" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><P align="right">Address</P></TD>
              <TD vAlign="middle"><input name="add1" type="text" maxlength="50" id="add1" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><p align="right">&nbsp;</p></TD>
              <TD vAlign="middle"><input name="add2" type="text" maxlength="50" id="add2" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><p align="right">Suburb</p></TD>
              <TD vAlign="middle"><input name="suburb" type="text" maxlength="50" id="suburb" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><p align="right">State</p></TD>
              <TD vAlign="middle"><input name="state" type="text" maxlength="50" id="state" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><P align="right">Town / City</P></TD>
              <TD vAlign="middle"><input name="townCity" type="text" maxlength="50" id="townCity" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><P align="right">County</P></TD>
              <TD vAlign="middle"><input name="county" type="text" maxlength="50" id="county" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="top" noWrap><P align="right">Post Code</P></TD>
              <TD vAlign="middle"><input name="postcode" type="text" maxlength="10" id="postcode" class="CopyDark" /></TD>
            </TR>
        </TABLE>
          <p>Please provide us with your CV here:          
          <label><br>
          </label>
          <input name="cv" type="file" size="28">
          </p></TD>
        <TD vAlign="top"><TABLE width="100%" cellPadding="3" cellSpacing="1" class="copydark" id="Table3">
            <TR>
              <TD valign="middle" noWrap><P align="right">Telephone DAY<FONT color="#ff0000">*</FONT>&nbsp; </P></TD>
              <TD vAlign="middle"><input name="telDay" type="text" maxlength="20" id="txtPhone" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD valign="middle" noWrap><P align="right">Telephone EVE<FONT color="#ff0000">*</FONT>&nbsp; </P></TD>
              <TD vAlign="middle"><input name="telEve" type="text" maxlength="20" id="txtPhone" class="CopyDark" /></TD>
            </TR>
            <TR>
              <TD colSpan="2" noWrap><P align="center">&nbsp;</P>
                </TD>
              </TR>
            <TR>
              <TD noWrap align="right" colSpan="2">Brief outline of your enquiry<font color="#ff0000">*</font>
                <textarea name="message" cols="25" rows="4" class="CopyDark" id="message"></textarea></TD></TR>
            <TR>
              <TD noWrap colSpan="2"><P align="right"><strong>How would you like us to contact you?</strong></P>
                  <P align="right"><span class="style4">Telephone day
                      <input name="preferredContact" type="radio" value="Tel Day">
                      <br>
                    Telephone evening
                    <input name="preferredContact" type="radio" value="Tel Eve">
                    <br>
                    Email</span>
                    <input name="preferredContact" type="radio" value="email" checked>
                </P></TD>
            </TR>
        </TABLE></TD>
      </TR>
      <TR class="copydark">
        <TD colSpan="2"><div align="right"> <br>
          <table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td><div align="center">Please select which restaurant(s) you would<br>
                  be interested in working at: </div></td>
              </tr>
              <tr>
                <td align="center" valign="middle"><label>
                <select name="store" size="10" multiple id="store" style="width:250px">
                  <option value="">Please Select</option>
                  <?php
do {  
?>
                  <option value="<?php echo $row_rs_storefinderSelect['name']?>"><?php echo $row_rs_storefinderSelect['name']?></option>
                  <?php
} while ($row_rs_storefinderSelect = mysql_fetch_assoc($rs_storefinderSelect));
  $rows = mysql_num_rows($rs_storefinderSelect);
  if($rows > 0) {
      mysql_data_seek($rs_storefinderSelect, 0);
        $row_rs_storefinderSelect = mysql_fetch_assoc($rs_storefinderSelect);
  }
?>
                </select>
                </label></td>
              </tr>
            </table>

            <hr> <p align="center">Would you like to receive occasional email updates from <strong><a href="sushi-storefinder.php"><img src="image/logoBody.gif" alt="sushi sushi" width="114" height="12" border="0"></a></strong> detailing new dishes, special offers and what else is happening at <strong><a href="sushi-storefinder.php"><img src="image/logoBody.gif" alt="sushi sushi" width="114" height="12" border="0"></a></strong>? </p>
        </div></TD>
      </TR>
      <TR class="copydark">
        <TD colSpan="2"><p align="center" class="style4">Yes please
              <input name="receiveNews" type="radio" value="yes">
                <br>
          No thank you
          <input name="receiveNews" type="radio" value="no">
        </p>
          <p align="center" class="style4">&nbsp;</p></TD>
      </TR>
      <TR class="copydark">
        <TD colSpan="2"><div align="center">
          <input name="Submit" type="submit" class="buttonAsLink_hover" value="Submit">
        </div></TD>
      </TR>
    </TABLE>
      </form>
    <p align="left">&nbsp;</p>
    <div align="left"></div>
  </div>
  </div>
<div id="navBar">
<div align="center"><strong><br>
      Select your<br>
      <img src="<?php echo $relroot?>image/logoBody.gif" width="114" height="12" alt="sushi sushi"></strong> <strong>Store</strong>:    </div>
          <div align="left" style="font-size:80%"><p><?php do { ?>
           <a href="sushi-storefinder-results.php?S_ID=<? echo $row_rs_StorefinderInclude['ID']; ?>"><?php echo $row_rs_StorefinderInclude['name']; ?></a><br>
            <?php } while ($row_rs_StorefinderInclude = mysql_fetch_assoc($rs_StorefinderInclude)); ?></div>
          <? echo $comma_sep ;?>
</div>
<br clear="all">
</div>
</div><br clear="all">
<?php include("includes/footer.inc.php");?>
  <?php
mysql_free_result($rs_StorefinderInclude);

mysql_free_result($rs_storefinderSelect);
?>

Downloaded a Dreamweaver extension which puts multiple lists into an array, but no way of referencing it. The extension puts the following code in the header:
if (isset($_POST["store"]) && is_array($_POST["store"])) {
  $_POST["store"] = implode(",", $_POST["store"]);
  $HTTP_POST_VARS["store"] = $_POST["store"];
}

Could I reference this code to enter into the database? The 'store' field wants to go into a database 'cell' for the row as a list (preferably comma separated) and will need exploding again.

Any help appreciated.
Thanks,
MNEWM
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros