Jump to content

RussellReal

Members
  • Posts

    1,773
  • Joined

  • Last visited

Everything posted by RussellReal

  1. u c.. thats where you'd use regex or strpos && substr preg_match strpos && substr
  2. make the session expire after like 30 minutes
  3. <?php $page = $_GET['page']; $rpp = 4; $dirArr = scandir('comments/'); function rem_invalid($arr) { foreach ($arr as $k => $v) { if (stristr($v,'.gif') === false) unset($arr[$k]); } } $dirArr = preg_grep("/^.*\.gif$/i",$dirArr); if ($c = count($dirArr)) { $dirArr = array_combine(range(0,count($dirArr) - 1),$dirArr); $numOfPages = ceil($c / $rpp); for ($i = (($page - 1) * $rpp); $i < min($c,($page * $rpp)); $i++) { echo $dirArr[$i]."<br/>"; } } echo "<br /><br />"; print_r(range(1,$numOfPages)); ?> tested and working example: http://lovinglori.com/omglol/?page=1 http://lovinglori.com/omglol/?page=2
  4. *** RussellReal extracts foot from mouth *** *** And then inserts directly up the rectum of mjdamato *** Grow up, it was just some good natured ribbing. Didn't mean to offend yeahhh... lol
  5. well then, add all the used ids to a session variable like $_SESSION['used'][] = $_SESSION['current_id']; then when you select a random one do "... WHERE `id` NOT IN (".implode(",",$_SESSION['used']).") ..."
  6. Anytime bro Feel free to add me to MSN to ask questions
  7. sorry for double post.. it won't <?php $a = 0; while ($row = mysql_fetch_assoc($query)) { $a++; // do your thing with the results if ($a == 3) { echo "<div class='clear'></div>"; $a = 0; } } ?> now it should..
  8. it should =\ however i haven't tested it.. but its simple enough for me to say that it should lol
  9. $sql = "SELECT Title,Content,Date, image_url FROM Posts ORDER BY id DESC"; you are not selecting it try: $sql = "SELECT Title, Content, Date, image_url, image_url2 FROM Posts ORDER BY id DESC";
  10. $a = 0; while ($row = mysql_fetch_assoc($query)) { $a++; if ($a == 3) { echo "<div class='clear'></div>"; $a = 0; } // do your thing with the results }
  11. also good to note that I set it up so that the script waits for ?act=next or ?act=back so your next and back arrows just make them point to whatever.php?act=next and whatever.php?act=back respectively and uses the current_id from the session $_SESSION['current_id']; basically what the query does is orders the results by `id` (if it isn't already), and then finds the next greatest (>) or the next lowest (<) although now thinking about it the context of the statement WHERE `id` > CURRENT_ID would probably look for the next lowest.. so you might need to change the $op declaration around so '>' is '<' and '<' is '>' but idk hope I'm helping
  12. theForm.submit() will submit the form..
  13. ok I've heard about PDO but haven't used it.. all I know is if $data holds the retrieved data, you should use $data everywhere like $data['id'] $data['title'] $data['whatever else'] then if the query went thru, and retrieved data, than you could never get anything mixed up because $data should also have the correct data in relation to the id
  14. <?php $op = (($_GET['act'] == 'next')? '>'($_GET['act'] == 'back')? '<':false)); if ($op) { $qry = mysql_query("SELECT * FROM `theTable` WHERE `id` $op '{$_SESSION['current_id']}' ORDER BY `id` ASC LIMIT 1"); if ($row = mysql_fetch_assoc($qry)) { // show data; } else { // no data to show; } } ?> added in $row = into the if statement so you could use $row to reference the data you will still need to connect to the mysql server, select a mysql database, and this code will ofcourse work, if you fill in the correct data or use the data the right way, I don't write full scripts for people, I only guide people in the right direction.. unless ofcourse its a simple function which sounds fun enough to do, but this kinda pagination/database work is very common and simple enough for u to take my guidelines presented above and use it with your script..
  15. your allow_url_fopen in your php.ini might be 'Off' try doing ini_set('allow_url_fopen','On'); above your script.
  16. ok since you've quoted me.. the second quote of me, you misunderstood you're pushing the data received by the script, instead of pushing the data you retrieve from the database.. You're going to want to QUERY your DATABASE with the `id` for example.. $id = (int) $_GET['id']; SELECT * FROM `movieTable` WHERE `id` = '{$id}' and then use the data returned by the query to fill the fields
  17. ok according to your last post you're expecting to have a couple entries if you're on entry 3 you want a previous and a next button which lead to 2 and 4 respectively. and judging by your lingo ('row','table') you're using mysql.. so basically you could just do <?php $op = (($_GET['act'] == 'next')? '>'($_GET['act'] == 'back')? '<':false)); if ($op) { $qry = mysql_query("SELECT * FROM `theTable` WHERE `id` $op '{$_SESSION['current_id']}' ORDER BY `id` ASC LIMIT 1"); if (mysql_fetch_assoc($qry)) { // show data; } else { // no data to show; } } ?>
  18. could you show the script? I follow your question, although the answers you're getting are kinda leading FROM a request, not TO a request, basically the responses here are telling you how to manage the query string in the script file itself, not to prevent the %26 in the first place.. replacing %26 could potentially cause errors as far as url encoding is concerned.. if you did str_replace('%26','&',$query); an there is a & in the request which SHOULD be url encoded, you will have a malformed request when you try to explode it by & and you will find yourself bald with plenty scratch-induced cuts in your beard.. so the best method to solve this problem is to correct the issue instead of working around the issue, and I'm more than certain there is something in your code which is causing the issue
  19. just do $_SESSION['current_id'] = $current_id; that way you don't need to loop through anything
  20. but if you mean when you "submit" just loop through the db values and echo in the results.. if there is no result it will still be a blank text box.. if there is a result, it will fill it with the value <input type="text" name="name" value="<?php echo $name; ?>" /> as with my first post ^^ thats IF there isn't a refresh... in the onchange event don't do top.location or whatever.. do theFormWithFields.submit()
  21. even in a drop down menu, you have two fields value and content you set the value of the <option> element to the ID of the title you set as the innerHTML of the option for example [id] => 1 [title] => A.I. Artificial Intelligence <option value="1">A.I. Artificial Intelligence</option> and just use the value of the $_POST or $_GET for the <select>'s name.. $_POST['select_box_name']; would hold the ID of the selected movie.. then form your query off of that..
  22. well.. on REFRESH as in f5 it would most likely be impossible to save the old values of the form.. but if you mean when you "submit" just loop through the db values and echo in the results.. if there is no result it will still be a blank text box.. if there is a result, it will fill it with the value <input type="text" name="name" value="<?php echo $name; ?>" />
×
×
  • 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.