Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. If you are going to post code at LEAST make it readable. Nobody but NOBODY writes code like a paragraph of text. They write it line by line.
  2. Manipulating a text file? How is that related to a website? You're going to let them upload their data in a file?
  3. Have no idea what you are doing. Have you ever designed a project before? Answered all the questions that can come up and design alternatives for them? Designed a db? As for the db - think about the data items you want. Organize them. Design a record layout that collects the unique attributes of a "thing" and creates a logical "set" of data for it. Any attribute that can occur multiple times for a single thing should not be in this record, but be part of a related table that will hold multiple records for each "thing" in the primary table. For instance if a phone has multiple buttons that you want to keep info on, the primary record should point ot a 'button' table that will contain at least two fields/columns - one being the name/id of the button and the second being the attribute of that button. You may have multiple attributes but each of these button records will be connected to the primary record by something you define as the 'phone id', with that value stored in the primary record and in each of the secondary recs. This is how you design a db. Coming up with your db design is the first course of action. Once you have that picture of things it can then be easier to see how you want to manipulate and that is where the coding exercise begins. Are you an experienced IT person? Learning proper db design is a good thing - do seme reading on proper normalization of databases. Are you a programmer? If not you definitely need to do some reading up on php and how it works. Will save you an immense amount of time if you start by learning and not by coding.
  4. Where is there a question in the above?. Again - your lack of understanding of PHP and programming is showing. If you are saying (not asking) that you want those 3 lines of code to be stored in a variable then you are way off the mark. Those 3 lines of code simply iterate through an array and output (to the client) a single value from each retrieved array's contents. If that is NOT what you are saying (not asking), then I have no idea what you are doing.
  5. I won't argue with you. Anybody who knows anything about PHP and programming would not be demonstrating such lack of skills on this forum. Sorry - but you have a lot to learn about programming. Writing an HTML-only page is NOT in any way a form of programming. It is simply a paint-by-number project.
  6. This looks like a block of code that the OP copied from somewhere. He has never programmed before. Certainly not in PHP. He is going about this thing completely backwards and thinks it's going to be a piece of cake. OP - do some reading. Learn about programming and PHP. Try to understand the concepts before you start borrowing code from somewhere and then want us to solve it for you. Anyone showing your lack of knowledge definitely did NOT compile the complex OOP statement you are using. Try learning how to make a query, how to execute it, how to test the results of it and then how to retrieve and use it. You are showing no knowledge of any of this. Go away until you have a working/reading knowledge of PHP and programming in general. This is not rocket science but it is still a science. Either that or go back to the video game console.
  7. Yes! As I said earlier and as Barand says again - USE THE MANUAL. It's online and readily available. And it is correct unlike perhaps some sites or tutorials.
  8. You cannot simply change the function names by adding an 'i' to them. You must read the manual and see how to use those functions and what their syntaxes are. Personally - I think PDO is much better. As for you input/type question - you will have to explain yourself.
  9. An array inside of an array doesn't have any 'name'. An array is one variable name. If you have an array inside an array it is simply an element/index of that array. $array1 = array('A'=>'valuea','B'=>'valueb','C'=>array('x','y','z'),'D'=>'valued'); You have a php var called $array1 here. In that var you have 4 elements - index 'A', index 'B', index 'C' & index 'D'. Within one of those elements you have an array buried containing 3 elements with numeric keys and the values of 'x', 'y', & 'z'. You reference the array as $array1['A'] $array1['B'] $array1['C'] $array1['D'] You can also reference the C element this way $array1['C'][0], $array1['C'][1] & $array1['C'][2] Referencing the A, B & D elements will give you the values you expect. Referencing $array1['C'] will give you an array. You will have to handle it differently by checking if the type of the element is in fact an Array and then loop thru that array's elements. A complete dump of the above: foreach($array1 as $k=>$v) { if (is_array($v)) { echo 'element $k contains '; foreach ($v as $k2=>$v2) echo "$k2 = $v2 "; } else echo "element $k is $v "; } Hope this gets you seeing it.
  10. 1 & 2 - Yes. 3 - ? 4 - Uh, yes? Still don't know what you are talking about as to "type or input". Are you talking about how to use an input form to get data from the user to do your search with?
  11. Post the Relevant code - not every line you have ever written please.
  12. 1 - stop using the MySQL_* functions. They are deprecated. You will be sorry if you continue to use this when you finally have to deal with a php version that has actually removed them. 2 - If you use something like pdo instead of MySQL_* you could simply return an object and avoid a lot of rather verbose code in your get function. 3 - What do you mean by "how to include in my php the type and input"? I see that you use a $type var in your query but I don't know what you want us to tell you. I do not see any mention of anything like 'input', so what is that? 4 - Your table defines the 'type' field as being rather large. Is that really necessary, especially since you will be doing searches on it? Something like that invites a lot of variations on what perhaps s/b a structured field having specific values that may be coded instead of being literal. PS - if doing a like query perhaps you want to say "select ... where type='" . $type . '%'. "'"; Or with PDO, use a prepared query in place of that. Check the manual please.
  13. The op was using $row which is the Array and not any contents of the array.
  14. No - I think my example is correct. $field IS the field name
  15. My point exactly. The OP has not given us a clue as to why he so urgently seeks this knowledge.
  16. It makes no sense to use a time that nobody else is using, unless this is for Indiana, Arizona, Saskatchewan(?) or parts of the Caribbean.
  17. You could do this instead: echo "<td>$field</td>";
  18. flood? anti clock? Whatever are you trying to say?
  19. Flying blind here, but ... I'd have to say there is something unique to this particular file. Look at it closely.
  20. If you are happy that you have solved this topic, you should mark it closed.
  21. I am far from a master. At least not at PHP. It was simply a matter of continuing to search for the problem. Actually I wanted to see if your required input was a function or some other code that could not be executed by simply being included. Or if you had php tags in it.
  22. Can we see the actual file being brought in?
  23. YOu have copied a lot of very old code here. Have you done any reading on how to program in PHP? Or how to setup an html table? Or how variables work? Some things I see YOu are doing a nice job of replacing newline chars with an html newline char. But why would you expect your date field ot have newlines in it? A true date field is just that a date field. Not a text field. You needlessly move your data items out of the query result "row" and edit those new vars but then when you output your html table row you use the original query result values. Why? Your while loop has a double set of braces around the code. Why? For each record in your loop you do the edits and then begin an html form and row and output the td elements and end the form. Why? You don't have any submit button so what's the point of having a form and hidden inputs? Are you going to do something with this hidden data? Not with this code. You are using a lot of styling in each and every element of your table. A lot of it is outdated and deprecated. Stop. Worry about the output, then worry about the presentation once you have done some reading on how css works. I know you copied it and have no idea what is happening, but it is not good. You need to learn the basics so write your own code and make it work and then learn some stuff and apply it to improve it. And one last piece of advice. Stop using MySQL and use only mysqlI or PDO to access your database. Read the manual to find out why.
  24. Well, I'll be. Now from my experience - if I ever hear or see that word used it tells me (and has told me) that I'm dealing with someone who doesn't speak or write very good English. In fact I think my English teachers would be shocked if I ever used it. Now from what you say I have to change 50+ years of behavior.
  25. Well, he didn't "learnt" it very well. In fact I'll bet he is still "learnt-ing" it. As for updating the script - I wouldn't waste my time. Learn and re-write. As for course/sites - there are a few but since I have never used any of them, I'll let the rest of the forum refer you to their faves. Here's a tip that will eliminate about 50 lines of code from this debacle: http://php.net/manual/en/function.list.php The list function is a great tool. Also - keep this url bookmarked so that you can reference the php manually readily. You're going to need it: http://www.php.net/manual/en/funcref.php
×
×
  • 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.