Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Can one really put the method and action clauses into a table tag?
  2. From what I can see I doubt that the answer[password] value will ever be equal to an encrypted password. I"m assuming that the answer array is coming from the user's input?
  3. Yes it was that simple. To keep your function cleaner I'd add the id value as an argument of the function as well function ($id, &$mail, &$rank)
  4. Return the vars as arguments of the function with the & on each. "function xyz(&$a, &$b)" Call the function with "function ($a, $b)" and then use $a & $b in your following code. And - how does using an array of your two values cause duplication of code? Anyway - your question is either how do I return the values or how do I echo the values? Which do you want to do?
  5. You need to step back and speak in English about what you are trying to do. No code.
  6. Well you hope to grab the rows. And THEN you want to read the results? How about telling us what you want to accomplish instead of how you want to code it?
  7. You title makes no sense and your code is nothing at all. What are you trying to learn??? Are you simply asking how to read an entire table? Very simple to do. But do you really need all of the columns in all of the rows? As for getting the data "in to an array", well, that is basically how a query result is returned. One can simply do a fetchall to grab all the results in one swoop but most of the time one processes the query results by using a fetch and a loop to process each row. As for your create - you might want to use the varchar type instead of the text type. And do you really want to use the 'latin1' charset over the more usual 'utf8' one? As for your last question - you haven't shown us your query so kinda hard to help you with that. Although it sounds like you just need to use the order by clause. I have given you a lot to answer so I patiently await your thoughtful response.
  8. And for those that don't need to use Classes, here is my dinosaur procedural code: function PDOConnect($l_dbname=NULL, $l_msg=null, $l_options=null) { if ($l_options == null) { // set my default options $l_options = array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_FOUND_ROWS => true, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); } if ($l_dbname == null) $host="mysql:host=localhost;charset=utf8"; else $host="mysql:host=localhost;dbname=$l_dbname;charset=utf8"; $uid = "user"; $pswd = "pswd"; try { $pdo = new PDO($host, $uid, $pswd, $l_options); } catch (PDOException $e) { if (strtoupper($l_msg) == "SHOWMSG") echo "Fatal Error<br>Failed to connect to database server. PDO Error msg is:<br>".$e->getMessage(); else echo "Fatal Error<br>Possible bad dbname?<br>Failed to connect to database server. Sensitive error msg may be viewed with additional parm to call to PDOConnect(dbname,'showmsg')"; return false; } if (!$pdo) return false; else // all worked - return handle to pdo connection. return $pdo; }
  9. Sorry. we are not communicating well and I am wasting my time.
  10. Huh? Can we stop wandering and get back to your original script that was not working for the menu? Just That?
  11. You are trying to create a menu that will not use the user's choice to go to another page? Makes no sense. Why, after the pick, would the user want to return to the same page? And why is JS coming up in our current conversation since you are not using it? Perhaps you need to focus on just one thing now. I suggest looking at the anchor tags you are creating and getting them correctly formed. Run your script (with my changes?) and then view it in your browser's display mode where you can view the actual html code and see what you've built.
  12. What is the ajax going to do for you? What is the code you did show us supposed to do? I was picturing some kind of menu to allow your user to make a selection of branch and go to a page associated with that branch. The colorful thing you are displaying here is not part of that in my mind. Have you used ajax before?
  13. Please ignore the code in the first post - it needed some corrections but I took too long to get them in. Here are my corrections. echo "<div class='BNavcontainer'> <div id='branchnav' class='SideBNav'>"; /* To display Branch Name from djams_db */ $brnch = $conn->query("SELECT * FROM branches") or die($conn->error); while($row = $brnch->fetch_assoc()) { echo "<a data-id='{$row['brnch_id']}' href='djams_rmc.php?{$row['brnch_name']}' id='b(" . $row['brnch_id'] +1 . ")'>({$row['brnch_name']})</a>"; } echo "</div></div>";
  14. Had a difficult time reading your code so did this re-write to make it clear. Not sure if I left something out but there was a "?>" part that didn't make sense. echo "<div class='BNavcontainer'> <div id='branchnav' class='SideBNav'>"; /* To display Branch Name from djams_db */ $brnch = $conn->query("SELECT * FROM branches") or die($conn->error); while($row = $brnch->fetch_assoc()) { echo "<a data-id='" . $row['brnch_id'] . "' href='djams_rmc.php?" . $row['brnch_name'] . "' id='b(" . $row['brnch_id'])+1 . ")'>" . $row['brnch_name'] . "</a>"; } echo "</div></div>"; So - yes you are displaying a set of anchor tags for each row of query results. These will send control to another script. Don't see why you use the word AJAX, especially since you are a noob. What do your want your screen to do for the user?
  15. Wherever did you find this antiquated piece of html? It is such a mess of out-dated things as well as a hugely complex mass of div tags and class values. Aren't you simply trying to produce an html table? Anyway - you started a loop after your query. Fine. Then you output a whole set to html. But nowhere did you output the values from your query. Read up on how to use css to stylize your html. Stop using p tags inside of a tags. Get rid of the strong tag. Set your font choice in the css body tag. Once. And perhaps read up on using the stand-by html table method. Sorry - but you have spent a lot of time either searching for this mess of code or writing this mess of code. And it is a mess.
  16. They are local to the function. Pass them or make them global
  17. Let's start over. Ok - you are not configuring your db in this script. Your db server and you have done that already and that's it. Or your host provider has given you the screen to do that config and setup your db and create your tables. So - the only 'db' thing in your scripts from now on is to make a connection. Call that 'db_connect' to avoid confusion. And add a dbname to that function so that you can call it with the desired name and make the connection flexible. Now your script should begin with a session_start call. Then you should have a couple lines to enable error checking so that during your development your script can let you know what is wrong error_reporting(E_ALL); ini_set('display_errors', '1'); Put that into a small script and store it. Then require it in all of your scripts. What I do is add a line to check for that status of a '$in_devl' variable so that once I'm done developing I set that var to false, otherwise it is true so that the error checking can be on/off as needed very easily. Now as Barand showed you, check if you received a post which means you should have inputs to look for and process. If no post, then send out your login form and exit(as I said earlier). So why don't you start with just this part and see how far you get? Personally I use a php function to do the html send so that I can easily get it done from anywhere in my script which saves you from having to figure out where to put it. Add some global vars to it so that you can pass your received inputs back to the form when you have errors and want to re-show them. Can do? Having fun? Just do the 2 things I recommended and work on just starting up, not finding any post, and sending out the form by calling your 'DisplayPage()' function (tha'ts what I call it).
  18. From your first post I am guessing that you are seeing the form. Are you then asking why you don't see that form again when there is a failure? You need to modify your processing code to start with PHP only and see if you have received any inputs from a POST. If not, THEN send out the html and exit. Once you do receive the POST input from that form, process it with PHP only and decide what happens next. If you have a user problem, send out the form again along with a message and exit. If no problem, then send the script to the next script to begin using the app. Do Not Mix up the php code with the HTML code. Makes for a terrible time to do maintenance down the road and to simple read thru the script. Structure your scripts to do the startup things first, then to check what inputs you have or don't have and then do the processing and finally send out the html. Structure is key. Proper html structure would suggest using the label tag to preface all of your input tags. If you are just beginning, I and many others here would advise that you stop and read up on using PDO instead of mysqlI. Much easier to grasp, to use and to work with than mysqli.
  19. So what is the point of having the </i> tag now?
  20. I didn't correct the italic tags. You can. As I said - you needed quotes to avoid that error message. And the solution to the minus 10 is to do what I did. Skip the sprintf. Too much work. Look where it got you!
  21. As for your Next button. You will need to either know the amount of data prior to starting this or you will have to check how many results you obtained responding to the last button you pressed. If it is not ten then you have to modify your from/to values to accomodate that. I assume that you are doing a query with a limit/offset clause so that should not be hard to implement.
  22. Do you have error checking enabled to see any possible messages? I"m guessing that you last two string parms are not valid since they are not simply variable names but real strings. Quote them. And why the use of sprintf? A simple statement is all you need without the extra headache of organizing your arguments with your string contents. Don't know what it buys you. $from = $from - 10; $to = $to - 10; $html = "<a href='/qcic/newsnet/pages/$actor.php?act_id=$id&act_title=$actor&from=$from&to=$to' class='$state'> <i class='fa fa-angle-left'></i> previous</a>"; BTW - your outdated <i> tag is incorrectly formed.
  23. But - do not save it in a table. Have a folder for these and save the filename in the customer's records but save the pdf as its own file.
  24. One shouldn't store/save sensitive values. Once the input values are used to authorize a user, you should use a generated token to recognize the authenticity of the user from that point on. As for a pdf I don't believe you have to worry about that.
×
×
  • 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.