Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. What do you mean by 'outside'? Your code sure looks like the nav tag is issued after the html tag so I'm thinking that visually your page doesn't look good. Have you examined your web page use the browser tools to allow you to see what is behind what you see onscreen?
  2. That is why one edits the input data before using it.
  3. My suggestion is to STOP using multiple-case variable names. It is going to Bite You In The youknowhere. You are creating such long names with multiple caps in them that when you get to writing longer scripts you are going to be looking all over for stupid errors to see where you mis-typed a name. No reason to do it, so don't do it. That's my (strong) opinion.
  4. Where is the code that produces this?
  5. Why not change the query you have to include all columns and specify one of the ids that produces multiple records? Output all of the data and see what's there that might be an indicator of why there are multiples?
  6. Duplicate truck ids? Perhaps a number gets re-used when a vehicle ages out of use. Maybe you need a 'status' code in the table to recognize old trucks that are only there for reference of old inventory and not for current reporting? Or perhaps there already exists some kind of code on the table that you are not using.
  7. If the answer is clear to you in the code - Why are we still on this topic? I have no idea what you have written that makes you happy since you are not sharing anything here. So why don't you just mark this as solved and end this topic?
  8. "When you can't do something, don't go to extremes)))) I'm not a programmer yet." What is this supposed to mean? We have been trying to help you but you aren't listening or doing anything that makes sense. Even your comments don't make sense. I have never written such detailed simplistic code for anyone before but I did in this topic because I could see that you needed help. And then you ignored what I said and continued to write bad code. You said you write shorter code in the beginning. Well, if you want to accomplish what you set out to do you have to write a BIT MORE CODE than what you thought you could get away with. READ WHAT WE HAVE GIVEN YOU AND AT LEAST TRY IT OUT. Otherwise I will not try and work with you any longer.
  9. I"m re-posting my version of your code again with some new comments. function page_require_level($require_level) { global $session; $current_user = current_user(); $login_level = find_by_groupLevel($current_user['user_level']); // SHOW THE RESULT OF ABOVE CALL //if user not login // SHOW THE VALUE OF $SESSION BEFORE USING IT // EX: ECHO "session is </pre>",print_r($session,true),"</pre>"; if (!$session->isUserLoggedIn(true)) { $session->msg('d','Please Sign in'); redirect('index.php', false); } //if Group status Deactive elseif($login_level['group_status'] === '0') // is login_level a string??? { $session->msg('d','User Banned'); redirect('home.php',false); } elseif($current_user['user_level'] <= (int)$require_level) // or is it an integer???? return true; else { $session->msg("d", "Error"); redirect('home.php', false); } } is your use of redirect() the same as using the php header() command? If so you should be doing an exit() right after running it. Try doing my suggestions to debug your process and see what the vars you are using actually contain.
  10. I think your tests are giving you incorrect results. See the comments I've added to your code below. function page_require_level($require_level) { global $session; $current_user = current_user(); $login_level = find_by_groupLevel($current_user['user_level']); //if user not login if (!$session->isUserLoggedIn(true)) { $session->msg('d','Please Sign in'); redirect('index.php', false); } //if Group status Deactive elseif($login_level['group_status'] === '0') // is login_level a string??? { $session->msg('d','User Banned'); redirect('home.php',false); } elseif($current_user['user_level'] <= (int)$require_level) // or is it an integer???? return true; else { $session->msg("d", "Error"); redirect('home.php', false); } }
  11. You seem to be using two different languages here.
  12. Psycho - I would support your decision if you locked this topic. The OP just doesn't make sense even in his writing and certainly isn't showing any programmer's intelligence. Never knew of people who played games like you are describing on these forums.
  13. You didn't follow what I wrote then. I specifically told you to use quotes on the array elements which you are not doing. And NO - you did not output all the values ... into columns. There is no html formatting there at all. How can you even think that you have put anything into a column??? I think you have more than a php problem. I made my post as simple as one can write this exercise in order to help you to follow my explanation as to what you have to do here. If you can't read it and follow it then I think my work here is wasted.
  14. Did you Read what I already posted before (or after) you wrote the recent post? It is not correct. And once again I don't understand what you are writing in that last line.
  15. Huh? Not sure what you are trying to say. But - did my last post help at all to make it clearer what and why the code should look like that? FYI - If you think that this little exercise is a lot of code you should realize that most php programmers write this kind of code all of the time, surrounded by a lot of other code that creates the data thru manipulation, calculation or concatenation with other data. This is programming. And wait until you get to the point that you want to write really fancy looking output and have to learn CSS. And then add some JS or JQ to add some client-based interactions with the user. That is what you have to look forward to.
  16. Here is a slight reworking of the previous code that might make it easier to follow: $sql = "SELECT * FROM msg"; // write a query $results = $db->query($sql); // run the query using a database connection // already made somewhere previously // Start an HTML table to display the results echo "<table>"; echo "<tr> <th>ID</th> <th>Message</th> <th>Sender</th> </tr>"; // output the table headings row // Loop through the rows of data and add them to the table while ($row = $results->fetch(PDO::FETCH_ASSOC)) { // begin the loop code // process the currently fetched row of query results echo "<tr>"; // start an html table row echo "<td>" . $row["id"] . "</td>"; // put an element into the row echo "<td>" . $row["message"] . "</td>"; // another element echo "<td>" . $row["sender"] . "</td>"; // another element echo "</tr>"; // end the current row } // end of the while loop // Close the HTML table echo "</table>"; exit(); Note the use of semicolons at the end of each php line except the while line which relies on the {} to end the line. Note also the use of periods to concatenate elements of the echo statements. Note the user of the brackets and quotes to access each element of the $row array (which fetch provides you). Don't know what else I can do to make this easier to comprehend other than a strong recommendation to RTFM. Programmers have to do that.
  17. Actually this last post of the possible code for you is SO simple. It is using very little PHP and more of HTML. 1 - Query - the command that runs a query statement to produce the results you want to see 2 - echo - a statement that sends output to the client 3 - while - a loop starting statement which allows one to repeatedly process a given set of data. In this case that data is a result row from the query. The code included in this loop is wrapped, aka, contained, by a set of braces, ie, {}. 4 - Fetch - the command that returns one row of the query results to you for processing Look up these commands in the manual. If you don't know how yet, here is the link to the Functions chapter of the manual: https://www.php.net/manual/en/funcref.php There is a search box/field in the upper right of the page. Have at it. So simple - just three php commands being used. Now how long can that possible take to learn. Basically this little block of code runs a query to : - collect some data; - begin an html table - start loop on the query results that gives the script one row to read at a time - the loop code outputs a line of an html table The table elements (HTML) are <table>, <tr>, <th> and <td>. - at the end of the loop the html table is closed. The rest of the code is using more echo statements to send the necessary HTML table elements to the client to present the output in a readable format. I am going out on a limb and stopping here since I hope you understand html.
  18. Where are you 'entering' things? I see nothing that updates your database nor collects user input. Nor do I see anything that does output to an iframe.
  19. Have no idea what the point of this code is BUT if you get exactly 10 rows it sends you to another script and if you don't you get a message (using outdated html) on screen. Looks great. So what's wrong?
  20. I have to ask. What is a "container"? And does 'VM' refer to something I haven't heard of in years when I was working with mainframes? And have you heard that PHP Version 5.x is out of date and could be part of your supposed problem? I may be stupid in asking this but why don't you just let the session be created where your installation wants to put it and not try and 'manage' it? You start it, you save stuff and when your client session is done, PHP will delete it for you.
  21. 1 - your data is stored in a database table but that doesn't mean it can simply be displayed with something that just "writes it down". Only records that contain some data values/fields that don't have labels on the pieces that you want to view and which need some code to help make that presentation. 2 - working with data that has been properly stored in a database table is fairly simple when you know how to use a language to collect it and display it. It may be called 'complicated' but that is only because it is new to you. PHP is a fairly easy language to learn and use but it does take some time to read up on and some practice writing it and debugging it until you get the hang of it. 3 - what is this group of 100 students you are referring to? I (we?) feel that we are communicating with just one person who may be considered a student who needs to learn a bit about how PHP produces the desired output format, aka, an HTML table. If one wants to read data from a source and display it in a nice fashion one has to learn how to write the proper commands that will do that. 4 - complex record? Records are basically not complex to those who work with them. You can learn that, although I don't think it is handled by simply writing it down. Hope this helps you and your 100 students a bit.
  22. Tables consist of records, or rows. Each record of a table has a set of fields or data items, also called columns. A properly designed table makes it easy to search for data based on a properly written query statement. Once you have created that query and run the query function, you can then write a loop that usually uses a Fetch call to retrieve a single row, outputs or analyzes the data on that row and continues on until there are no rows left to be fetched. Do not think of this as any kind of spreadsheet. Tables are part of a Database. Spreadsheets are not. One table can be related to another table and allow you to write queries that gather data from several tables into one result set that gives you pieces of data from that database in a fashion that allows you to do what you need to do with that data.
  23. Have you done any reading of how to write php and how to do querying and how to display the results? There's some nice examples in the official PHP manual that would have answered your question immediately, if you read it. (Tip: You cannot echo an array nor a resource result from a query. You have to break it down to the contents which Barand did with a function but it could have been done with more detail which might have been clearer to you.)
  24. Definitely switch to PDO and NOT MysqlI The PDO interface is much easier to use . The latter may seem to be the simple choice but there would be much more to learning to use it than simply adding the "I" character to it.
×
×
  • 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.