Jump to content

iblood

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

iblood's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. iblood

    Better method

    here's what I will do in this kinds of situation <?php $q1 = "select ItemID, sum(Rating) as mr from dd_rating group by ItemID order by mr desc limit 0,4"; $r1 = mysql_query($q1) or die(mysql_error()); $q2parts = array(); while($a1 = mysql_fetch_array($r1)) { $q2parts[] = "ItemID = '$a1[0]'"; } $q2results = array(); if (!empty($q2parts)) { $q2 = "select ItemTitle from dd_items where ".implode(' OR ', $q2parts); $r2 = mysql_query($q2) or die(mysql_error()); while($a2 = mysql_fetch_array($r2)){ $q2results = $a2; } } ?> I'm pretty sure there's some workaround using SQL joins, but I'm just not a fan of JOINS.
  2. It happens, because, when you got back to page 1, the page generated a random results again. I'm not sure what would be the disadvantages of this, but maybe you could try to cache your db results, then do the paging via PHP. <?php if (!isset($_SESSION['results'])) { $_SESSION['results'] = $all_of_your_rendomized_records; } else { $all_of_your_rendomized_records = $_SESSION['results']; } // then handle your $all_of_your_rendomized_records's pagination here using php ?> Im not sure though the disadvantages of this, if this will cosume much memory or something. But I think it can handle with just 600 records.
  3. I don't think you're using the function correct. I checked the php manual:http://php.net/manual/en/control-structures.foreach.php, however, I can't find an example like your implementation. Maybe it could help if you would post what you are trying to achieve here, and what your array variable contains.
  4. I believe you're gonna need to use FQL for this. This might help. http://developers.facebook.com/docs/reference/fql/link_stat/
  5. I think all you need is like this:?? $queryVars = array(); foreach ($row as $k => $v) { $queryVars[] = $k . '=' . urlencode($v); } $row['postcode_link'] = "<p class=link><a href='/gmap.php?" . implode('&', $queryVars) . "'>Map</a></p><br>"; you just replace this code: if( !empty($row['postcode']) ) { $row['postcode_link'] = "<p class=link><a href='/gmap.php?postcode=" . urlencode($row['postcode']) . "'>Map</a></p><br>"; }
  6. $sqlcond = ''; foreach ($checkbox as $checkboxes) { $sqlcond .= 'SID=' . $checkbox . ' OR '; } if ($sqlcond !== '') { // Get all teachers with SIDs $sql = "SELECT `TID` FROM `TEACHERS_SUBJECTS` WHERE " . rtrim($sqlcond, ' OR '); $res = mysql_query($sql); // Create a buffer of teachers $teachers = array(); while ($row = mysql_fetch_assoc($res)){ $teachers[$row['TID']][] = 1; } $tnameSqlExt = ''; foreach ($teachers as $tid => $t) { // check if teacher has all the SID from checkbox if (count($t) == count($checkbox)){ // at this point we are sure that the teacher has all the SID requested $tnameSqlExt .= 'TID=' . $tid . ' OR '; } } // display teachers names if ($tnameSqlExt !== '') { $tSql = "SELECT `NAME` FROM `TEACHERS` WHERE " . $tnameSqlExt; $res = mysql_query($tSql); while ($row = mysql_fetch_assoc($res)){ echo $row['NAME'] . '<br />'; } } } Hope this workd
  7. I think you missed Nodral's point here At the end of this script, $_SESSION will always have the value of the last record.. Regarding your implementation, I would recommend to just use $_GET instead of $_SESSION. something like: //if ("{$row['passState']}" == 0) {echo "<a href='check.php'>Check your answers.</a><br />\n";} if ("{$row['passState']}" == 0) {echo "<a href='check.php?quiztitle=". urlencode($quizTitle) ."'>Check your answers.</a><br />\n";} and in your check.php: //$quizTitle = $_SESSION['quizTitle']; $quizTitle = mysql_real_escape_string($_GET['quizTitle']);
  8. your script must have fallen on the last else statement.. have you tied to echo sumthing on that last else statement?
  9. That's just because you're not disciplined enough then. If you skip straight to the answer then it's your own fault if you don't learn from exercises. You can still learn if you skip directly to the answer- it depends to your way of thinking... unless ofcourse if your the spoon fed type.. so it really falls to DICIPLINE
  10. I agree.. So can you post some ideas for a startup project then??? I want to do a website for myself, but have too many ideas, and none was put into development.. :'( any tips??????
  11. hint u will create a page and inside that: header() ->the one used for downloading //get data to be inserted to csv echo data; // your data will then be downloaded once the page is opened then on your main page <a href="the page u created above.php">export</a> lol there's your hint
  12. iblood

    Password

    I would counter, not a great question. There are so many variables involved and you have supplied zero information on your current environment, setup, etc. LOL 1 point!!!..hahaha.. You like something like this? <head> <script type="text/javascript"> <!-- function prompter() { var reply = prompt("Hey there, good looking stranger! What's your name?", "") alert ( "Nice to see you around these parts " + reply + "!") } //--> </script> </head> <body> <input type="button" onclick="prompter()" value="Say my name!"> </body> http://www.tizag.com/javascriptT/javascriptprompt.php
  13. hmmm.. I haven't check you class yet.. but in your example, I guess it would be bette if you have it like this instead. Example $html = new Class(); $attrib['class'] = 'classname'; $attrib['id'] = 'idname'; $attrib['style'] = 'color:#000'; $html->ul->li('xxxx',$attrib); $html->ul->li('yyyy'); /* OUtPUT: <ul> <li id="idname" class="classname" style="color#000">xxx</li> <li>yyyy</li> </ul> */ it's much more cleaner and we might end up using it instead of the one you did and using arrays..ins unconventional... we'd rather echo ' <ul> <li>One</li> <li>Two</li> <li>Three</li> </ul> '; much cleaner and much understandable.. the sample I posted is just a sample idea for implementation,.If you want to use it, then do the coding/processes LOL, And to think of it, That gave me an idea LOL,hmmmmmmmmmmmmm
  14. yeah!! put this-> echo $statusCount['Status 1']; out of the loop
  15. on your query on view.php you used ( 'SELECT * FROM news WHERE ID = "$ID"' ) <- single quote..So I guess the script searches for the value '$ID' literally, and not the value of $ID, Have you tried using double quotes? "SELECT * FROM news WHERE ID = '$ID'"
×
×
  • 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.