Jump to content

HadesMOD

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

HadesMOD's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, This worked perfectly and I've found my issues out from the revised code. Thanks, and sorry I was confused as to what information you lacked, otherwise I would've provided for sure.
  2. I'm looking to have a 3D array, starting with the Make. In the screenshot, Brother is the make for each of these. In the 2nd dimension, the Model is used. Each model, becomes an associative array with each value listed on the right side. See screenshot: http://prntscr.com/3aqhyn So for example, the DCP-9040CN, 9045CDN, etc.. in the model box (2nd column from right) would be assigned these values in their array. TN115BK, TN115C, TN115M, TN115Y, DR110CL The current problem is that it seems that only the last value (9830CDW) is getting the values listed above assigned, while the rest do not. I want every model to get these values in their array.
  3. I'm confused by what you are referring to. The CSV data matches the screenshot. The screenshot is an .xlsx file, which was deliminited with an '@' symbol. The first few lines of this were what I included in the sample. I did not see any location where attachments were available, but I have a whole CSV to reference. Regarding the detection of the nth field, I am unsure where you are referring to using this. The issue with the excel sheets and how they are formatted, is a bunch of models (where my original screenshot arrow is pointing to) each contain multiple fields. I am unsure of where this is going wrong in my code, but I understand the logic. I am fairly new to PHP, so a little guidance would help here.
  4. I am trying to read a large number of products, from a CSV file. I am attempting to parse each line and produce item lists, each with a Make, Model and set of OEM numbers. Multiple models use the same set of OEM values. Here is a sample screenshot of my product spreadsheet. - http://prntscr.com/3aorwh Here is my code below. Underneath will be my CSV contents (only a sample) error_reporting(0); $file = fopen("new.csv","r"); $makeArray = array(); $make = ''; $model = 0; $specificModel = ''; while(! feof($file)) { $lineVal = fgetcsv($file, 0, '@'); // Adds in 'Make' to initial makeArray array if ( isset($lineVal[0]) && empty( $lineVal[1] ) && empty( $lineVal[2] ) ) { $make = $lineVal[0]; $makeArray[$make] = array(); } // Gets Model lists if ($lineVal[1] !== '') { $model++; $makeArray[$make][$model] = array(); $specificModel = explode(",", $lineVal[1]); foreach($specificModel as $t) { $makeArray[$make][$model][$t] = array(); } } $OEMs = explode(',', $lineVal[2]); foreach($makeArray[$make][$model] as $specific) { if ($specific !== '') { // This loop adds in the variables foreach($OEMs as $oem){ $makeArray[$make][$model][$t][$oem] = array(); } } } } // Echo results echo '<pre>'; var_dump($makeArray) . '<br />'; echo '</pre>'; fclose($file); Here is the CSV content: Brother@@ Brother TN12K Compatible Black Toner Cartridge@HL-4200 Series@TN12BK Brother TN12C Compatible Cyan Toner Cartridge@@TN12C Brother TN12M Compatible Magenta Toner Cartridge@@TN12M Brother TN12Y Compatible Yellow Toner Cartridge@@TN12Y Brother TN04K Compatible Black Toner Cartridge, For HL-2700,@HL-2700CN,MFC-9420CN@TN04BK Brother TN04C Compatible Cyan Toner Cartridge, For HL-2700,@@TN04C Brother TN04M Compatible Magenta Toner Cartridge@@TN04M Brother TN04Y Compatible Yellow Toner Cartridge@@TN04Y When I output my code, the following structure occurs. Please note at this point, the OEM values are grouped, and each model within the dark borders on the left, has to have ALL of the values on the right side within these borders. Output array(1) { ["Brother"]=> array(2) { [1]=> array(1) { ["HL-4200 Series"]=> array(4) { ["TN12BK"]=> array(0) { } ["TN12C"]=> array(0) { } ["TN12M"]=> array(0) { } ["TN12Y"]=> array(0) { } } } [2]=> array(2) { ["HL-2700CN"]=> array(0) { } [" MFC-9420CN"]=> array(4) { ["TN04BK"]=> array(0) { } ["TN04C"]=> array(0) { } ["TN04M"]=> array(0) { } ["TN04Y "]=> array(0) { } } } } } Any takers as to why HL-2700CN and MFC-9420CN (or any sections like this) do not ALL get assigned the respective grouped OEMs? Additional information: The format of the end result needs to look like: Brother HL-4200 Series TN12BK TN12C TN12M TN12Y HL-2700CN TN04BK TN04C TN04M TN04Y MFC-9420CN TN04BK TN04C TN04M TN04Y Thanks
  5. Hello, I am new to this forum, but need to learn a thing or two about PHP... Now my request may be difficult or need a lot of planning to accomplish but here is what I am trying to do: I have a form connected to the database I am working with and It pulls queries from existing table data, and on change (submit) it replaces existing data. I now want to move forward, and do something different. I want to essentially have checkboxes (8 total) and if any one is checked, it will add to a value (making HTML) For example, if Checkbox 1 is selected, display - Which could be anything I needed it to beIf checkbox 2 is selected, the value will add to the bottom of the last field, and this repeats for each checkbox. The output (which I want to push into the Database) will be similar to as follows: [html Checkbox1] [html Checkbox2] [html Checkbox3] [4,5,6,7,8...] Again, this needs to go into the database to replace the existing field Any takers? Can anyone point me in the right direction?
  6. I am a novice lol. I will change that, I understand what you're saying. I want every column to show. But I cannot figure out why it won't insert.. is there anything wrong with my query? It does seem to be entering the query somewhat, because my default text in the comment box says "Enter Comment Here" now I need to tweak it to show right. Now when I changed that part, it queries fine to get the details out. I have to take the post_id column out though. 3 84 ns 4 Enter Comment Here ns 5 Enter Comment Here ns
  7. I got some of this done, now I can see the name of the users but the form will not post the information into it. I don't get the connect to mysql error, just the error posting comment, so the query isnt written right. What im trying to do is add the user name and details into the comment table. Here are the changes I made. <?php include_once("../functions.php"); include_once("../".$installed_config_file); include_once("constants.inc.php"); $dbhost = 'localhost'; $dbuser = 'u7200607_1733'; $dbpass = 'japple12'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'u7200607_1733'; mysql_select_db($dbname); $name =$member_details_array['email']; $dtl = $_POST['post_dtl']; // also it is good practice to enclose associative array indexes in quotes to avoid notice errors. $query="INSERT INTO cmt (post_dtl, ) VALUES ('.$dtl', '.$name')"; mysql_query($query) or die ('Error posting comment') ?> Here is my Basically I want it to display like: Justin posted on xx-xx-xxxx at xx:xx This is my comment.....
  8. I am working on making a standalone script for comments I can include into my main page. The script I worked with is PHP Auto Members. I can pull details out of the DB by using an array that is below. But I cannot get this to input any information into my database nor display the information I put into the database. It does connect to the database though, through using the functions.php file. Names from PHP automembers come out of this script <?php echo $member_details_array['name']; ?> Other items in the array are below: id name companyname email address county postcode tel fax heardaboutusfrom their_username their_password comments activated activated_date duration expire_date For my comment script I have a table called cmt with sublevels of "post_id" , "post_dt", and "post_dtl" "post_dtl" is the variable and db table for the context. "post_id” is the variable and db table for the post id I can use to index them better. “post_dt” is the variable and db table for the date/time. Here are my scripts below: There are 4 files. Comment.php <?php include_once("../functions.php"); include_once("../".$installed_config_file); include_once("constants.inc.php"); if(!session_id()) session_start(); if (isset($_SESSION['md5_pass'])) { pama_authenticate($_SESSION['username'],$_SESSION['md5_pass'],"members",0); include ("comment.html"); } else { ?> <a href="#">Please Login to Post a Comment</a> <?php } ?> <?php include 'cmt-display.php' ?> Comment.html <form action="cmt-form.php" id="comment" method="post" enctype="multipart/form-data" name="commPost" target="_self"> <input type="hidden" name="todo" value="post_comment"> <textarea name="post_dtl" cols="45" onclick="this.value=''" rows="8" value="post_comment">Enter Comment Here</textarea> <input name="submit" type="submit" value="Submit" onclick="document.location = 'comment.php'"/> </form> cmt-form.php <?php include_once("../functions.php"); include_once("../".$installed_config_file); include_once("constants.inc.php"); $dtl = $_POST[post_dtl]; $query="INSERT INTO cmt (post_dtl) VALUES ('null', '".$dtl."')"; mysql_query($query) or die ('Error posting comment') ?> cmt-display.php <?php echo $member_details_array['email']; $dtl = mysql_query("SELECT post_dtl, * FROM cmt"); echo $dtl ?>
  9. I am trying to add a script to my site for a membership system. The system works fine on the host I have, but when I include the login link onto one of my pages using the <? include("phpautomembersarea/members/join.php"); ?> they gave me, it shows just a copy of my header in the root folder, instead of the header in the members folder and nothing else, not even an error. But the link work's perfectly fine just not the include. I even tried typing the include as <? php include("phpautomembersarea/members/join.php"); ?> That did not work either. So one more thing I tried, since it showed my header.html twice, I figured it was a location problem. I went into the members/join.php and adding a value called $location and set the directory for the header in that folder, to "phpautomembersarea/members/" but it still did not work. What would cause this? Lack of recent PHP version on the host? I think it is up to date.. It is the last thing I need, to be able to include my files on the webpage and then I can mess with the layout. Once I know the script works. Don't ask about the websites purpose.. Friend who got married is pretty much letting her wife become what she wants to be..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.