Jump to content

akphidelt2007

Members
  • Posts

    174
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by akphidelt2007

  1. What does you loadjscssfile() look like and what do you mean "read php"?
  2. You need to recreate the hashed password and check against it in the database. Right now you are checking a plain-text password against your hashed password.
  3. The "&" is a separator for GET values. So you have to use urlencode when creating the url string. The other thing you should do is clean the GET value before you submit it to the database. Just type in Google "PHP How to prevent SQL Injections". You willl see a million sites detailing how to make data safe for inserting in to your database.
  4. So you have the content from the database... now set a variable that triggers either an inline style or a class. Something like this //this says if your checkbox is 1 then $boldMe has the style, if it is 0 it has an empty string $boldMe = $db_data['yourcheckboxfield'] ? " style='font-weight:bold;'" : ''; //then in your td tag '<td'.$boldMe.'> Of course this is just a simple example but hopefully you get the idea. You just need to use a variable that checks what the value of the checkbox is and then inserts either a class, a style, or the full style string to bold the text.
  5. Everything is frowned upon by someone in the programming world. I would very much suggest using a static db class.
  6. The way I handle larger fields is to create an array of the fields and an array of the values and implode them out at the end... for instance... $requiredFields = Array('reqfld1'=>'str','reqfld2'=>'int'); $fields = $values = Array(); $error = false; foreach($_POST as $field => $value) { //check to see if it's empty if(!$value) { //check to see if it's required and note that there is an error. There is a lot more that you should do to track this error, but this is just for an example if(isset($requiredFields[$field])) { $error = true; } } else { //record the fields and values here. For fields you usually have to create an array or a table of fields and their requirements like if they are ints or dates, etc //but for simplicity sake $fields[] = $field; $values[] = is_int($value) ? $value : "'$value'"; } } $qry = "INSERT INTO mytable (".implode(',',$fields).") VALUES (".implode(',',$values).")";
  7. Oh yea, just from personal experience. You will never forgive yourself for not using a static database class. It makes life 1 million times easier. Instead of making it global or instantiating a new db class every single time you want to do a query you simply do DB::runMyQuery("insert query here").
  8. The code you gave would not trigger an undefined variable error... so the error is coming from somewhere else in your script. And the value should be '{$_POST[$fieldname]}' instead of '$fieldname' unless you want every value just to equal the field name. Also you say you have 100 variables yet you are creating a new row for every single field that has a value? I don't think that's what you are trying to do?
  9. Is the live server's directory set up the same as your local server? ../folder might not be the same on the live server.
  10. You should be getting an undefined variable for this line... $result = $secureConnection->query($query); as you have not defined $secureConnection in method addPost
  11. Try something like this... $caption = isset($_GET['caption']) ? $_GET['caption'] : 1; $options = array('2' => '2', '3' => '3', '4' => '4'); foreach($options as $value => $text) { $selected = $caption==$text ? ' selected' : ''; echo "<option value='$value'$selected>$text</option>"; } This is basically a shorthand method to simply create the $caption variable with out having to manipulate it so much through your foreach statement.
  12. There's probably no reason to do this for a form class unless you want to extend input types which isn't really necessary. And I have no clue what you mean by this "And although the validation will be created secondly, it must be displayed first on the page, i.e. before the header info." You can create, validate, and submit a form to the DB all in one class. But we'd have to know more about how you have stuff set up in order to give you better advice.
  13. Gonna need a little bit more information than this. But just some inconsistencies I see from the little bit of code you submitted. In the submit field you have the name as '$this->submit' but in the text function you check to see if $this->submit is set. What you want to do is check to see if $_POST[$this->submit] is set. I'm willing to take a guess that $this->submit is not being set, so therefore when you check to see if it isset, you are getting a false return and getting no value for the input.
  14. Ok, let me get this straight. You have a table of items. Next to each item is a price that a user can set, correct? And a user can update the price of multiple items and click "Update Price" and you want it to go through and update the prices for each item?
  15. You want to update prices for multiple items, correct? $_POST['price'] is now an Array of prices... as in $_POST['price'] = Array('price1','price2') So in order to update multiple line items you will have to verify the form has been submitted than loop through the line items again to update the prices.
  16. Whenever I have to do crosstabs like this I break it up in to three arrays. One for columns, one for rows, and one for data. For example... $customerArray = Array('Internal','Other','CDR','TPI'); //you can create this array from a query also $rangeArray = Array('lessthan1','1year','2year'); //then query your data and loop through it storing the data in to a data array with the customer and ranges as the keys $data[$row[1]]['1year'] = 16; //so this would basically be $data['Internal']['1year'] //then loop through the rows and columns and place the data in to the cells foreach($customerArray as $customer) { foreach($rangeArray as $range) { //this is where you check to see if the data exists and you place it in, otherwise show 0 or "" $value = isset($data[$customer][$range]) ? $data[$customer][$range] : ""; //then place this value within the <td> } } This is just a basic explanation with out all the typing of creating the table and everything else. Hope it gives you some ideas.
  17. First thing you need to do is wrap your inputs within the form tag. Next if you want to deal with multiple form inputs with the same name you have to create an array. So basically <input type="text" name="price[]" value="<?php echo "$eeprice"; ?>"> Than once you mess with that if you have any more questions, come back here.
  18. array_key_exists
  19. $_SESSION['enquiry][ ] = $id;
  20. Just a recommendation, use some code tags so it's easier to read... but you can not output any html before you redirect a user using header(). Put that php code above the DOCTYPE (beginning of html) and it will work.
  21. This would be a perfect case and task for a normalized database. If you created an ingredients table and related it to the recipe table, you can do this with a simple SELECT DISTINCT(ingredient) FROM ingredients Otherwise what you are doing is not properly looping through a mysql result. This is completely untested but I would try something like this. $ingredients = Array(); $result= mysqli_query ($dbcnx, "SELECT key_ingredient FROM recipes"); if(mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { //explode the ingridents $ing = explode(',',$row[0]); if(is_array($ing)) { foreach($ing as $ingredient) { $trim = trim($ingredient); if(!in_array($trim,$ingredients)) { $ingredients[] = $ingredient; } } } } }
  22. Definitely a good read.
  23. Oh wait, I see you only said 10 in a subdirectory. In that case just adjust the increments to whatever you want. For example... if you want no more than 10 directs in a subdirectory and expect a million customers, the increments would be $increments = Array(1000000,100000,10000,1000,100,10); So customer id #35005 would be customer_files/0_999999/0_99999/30000_39999/35000_35999/35000_35099/35000_35009/customer_35005/ I honestly don't think you need to go to that level but it's just showing the possibilities by simply adjusting your increments.
  24. I've never done anything past 10,000 items stored... so there might be some other experts here that can provide solutions for handling that much data. But say you wanted only 100 files in a single subdirectory. Then you just expand your increments... for example //10000 is layer 1, 1000 is layer 2, 100 is layer 3 $increments = Array(10000,1000,100); $customerID = 1035; //store path $path = 'customer_files/'; //get the path foreach($increments as $inc) { $int = intval($customerID/$inc); $dir = $int*$inc."_".(($int+1)*$inc-1); $path .= $dir.'/'; } //add on the customer $path .= 'customer_'.$customerID.'/'; So for customer 1035 the path would be... customer_files/0_9999/1000_1999/1000_1099/customer_1035/ So you would never have more than 100 customers in any subdirectory and it would be layered appropriately.
  25. Your logic is a little wrong there. $last_date = false; $date = ''; foreach($all_status as $status){ ?> <?php $date = substr($status['dr'], 0, -6); if($last_date != $date){ //no reason for this line here //$date = substr($status['dr'], 0, -6); echo '<tr><th colspan="6" style="text-align:center; background-color:#CBF09E">' . $date . ''; if($date == date('F d, Y')){ echo ' - Today'; } echo '</th></tr>'; $last_date = $date; }
×
×
  • 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.