Jump to content

diocyria

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

diocyria's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $limit=10; $page=0; $numrows = mysql_num_rows($result); $pages = intval($numrows/$limit); if ($numrows % $limit) { $pages++;} $current = ($page/$limit) + 1; // all this will ever do is return the result of (0/$limit) + 1=1 // this following section is almost a waste, just use the value stored in $pages instead of making a whole new $total variable if (($pages < 1) || ($pages == 0)) { // $pages < 1 covers both scenarios, no need for the second $pages == 0 check $total = 1;} else { $total = $pages;} $result = mysql_query("SELECT * FROM $tbl_name ORDER BY id DESC LIMIT $page,$limit"); Now the query at the bottom of the quoted example above, this isn't really needed since your already pulling the records using a query above. You can probably continue from the first query and create an array of records sized of $limit, storing each row appropriate to the current page. As an example: $startPgRow = $page * $limit; // may not be the exact calculation depending on your table setups (may also need to add 1 to $page value) $curRow = 0; // could use a 1 starting value as well, which might be easier depending on above calculation/table setup // both of the following may need to use a <= comparison instead, again depending on current value/table setups while ($curRow < $startPgRow) { mysql_fetch_row($result); $curRow++; } // could do additional error checking while ($curRow < ($startPgRow + $limit)) { $myPgResults[] = mysql_fetch_row($result); $curRow++; } // could do additional error checking and/or use mysql_fetch_assoc($result) depending on what/how you want to deal with it // output row data, which you could also do directly using the last while() above, again depending on your preferences I'm not totally sure if you can use the LIMIT clause of a MySQL query the way you are, I've only used it in terms of LIMIT <rowcount>. Hope this helps!
  2. ooops the above example should be (sorry I typed it up really quick the first time): class Something { function aFunc() { // this always returns true whether I had set the value or not if (isset($_SESSION['somedata'])) { return false; } return true; } function bFunc() { global $_SESSION; // figured this would already be in a global accessible scope if (isset($_SESSION['somedata'])) { return false; } // now this will return false only when the value is set return true; } } There, hopefully that makes a little more sense.
  3. Unless I am mistaken on what you are trying to do, simply surround all of your SQL output (in other words the HTML table element) with a form element. Then the first column of the table for each row pulled (since each one is in the "not-yet-purchased" list), add a first column to the output that states something like <input type="checkbox" name="id" value="<?php echo $returnedRow['id']; ?>" /> Then when the user clicks the button at the bottom of the "form", all values supplied as 'id' in the form submission query should simply be grabbed and moved to the new table. If you need a more detailed example, just let me know.
  4. Honestly if you are very new to this sort of thing I would more so recommend simply creating a work-around for this process, your own registration script can simply add multiple user records (one for each service's user table -- mind you the WordPress login you may want to be careful with considering giving everyone access to your CMS may not be a good thing), then create a user table for your own login purposes that simply reference the appropriate records from each of the other user tables. This way when you login, you identify the user based on one user table by pulling the appropriate records associated with the current login from the other user tables. The only tricky portion of this process would be in the actual login process, this is where you would need to identify the appropriate function that processes a login request on behalf of those services, or you can attempt to simply do more of an HTTP request on the login scripts already supplied for each of the services. Either method would take a little bit of research, but its far less than making an attempt to alter the code altogether to work differently than it was originally intended. This isn't a process I would recommend for someone who doesn't have the experience. Your bound to end up with a million-and-one headaches throughout the process, and most likely will cause breaks in the original scripts your using since making one change will most likely affect other areas of the system, and so on and so forth throughout the entire services script. Hopefully I'm not being too direct with this one, but it would be my suggestion. Did notice that someone is offering assistance to help you alter the scripts in an effort to integrate, but I still don't recommend obtaining his/her help (simply because what will happen when that nice individual is no longer there and you are faced with the need to make changes to your own scripts, which inadvertently require further changes inside of the pre-mades? it wont be pretty). Good luck, if you want my further advice on such a research process I'm more than willing to offer any further advice. Just let me know.
  5. Now I'm not anywhere close to a PHP guru, but a side note to this topic would have to be just to make sure you have appropriate security in place so then only the authorized accounts can access such a page... you don't want Sally Sue logging in as a basic user and suddenly upping her account status, while removing your entire account altogether (locking you out of your own site, even if only temporary). Could be slightly annoying. This is of course assuming that your page will bring them back to a form where they are displayed yet again with User#8's information that they could simply edit it and submit such a reply. This is getting a little more in depth in to possible ways of getting around your security, but it is something to be considered during a process such as this. Other than that though, I agree your use of the GET request method is perfectly fine.
  6. Hello All, I am fairly new to PHP class development, and I was wondering if it is normal behaviour to see classes not being able to access global variables related to PHP-based requests ($_GET, $_SESSION, etc.)? I seem to either have to use "global <var>" inside of the class to access the data, or I am forced to change the methods so then such required data is passed in as parameters. Perhaps I am just doing something wrong? Here is an example of what I mean: class Something { function aFunc() { if (isset($_SESSION['somedata'])) { return false; } // this always returns false whether I had set the value or not } function bFunc() { global $_SESSION; // figured this would already be in a global accessible scope if (isset($_SESSION['somedata'])) { return false; } // now this will return false only when the value is set } } Now the above example is commented to demonstrate what I was meaning above, and I was wondering if this was the 'norm' when developing classes for PHP (and thus such values should be passed as parameters)? Thanks!
×
×
  • 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.