Jump to content

php_dave

Members
  • Posts

    107
  • Joined

  • Last visited

    Never

Everything posted by php_dave

  1. Hi, Pull your results sorting by date order so adding a order by <date_field> DESC to your query if you dont have it already. Then you can compare the last date row against the current if its the same just print the row if its different print the header first. Example: $sql = "SELECT * from TABLE order by <date_field> DESC" $old_date = False; $result = mysql_query($sql); while ($row = dbarray($result)) { if ($old_date != $row['date_field']) { echo $row['date_field']."<BR />"; } echo $row."<BR />"; $old_date = $row['date_field']; } Not Tested but should work. Dave
  2. Hey to and from are reserved words in mysql - change to: INSERT INTO pms (`to`, `from`, `contact`, `title`, `message`) VALUES ('7', 'asdf', 'asfd', 'sdf', 'asdf') this will get the query working but I would rename those fields to something else
  3. You have an extra close bracket at the end of this line $query = "INSERT INTO newsletter_signup VALUES ('$form1','$form2','$form3','$form4','$form5','$form6','$form7','$form8','$form9','$form10','$form11','$form12')"); should be $query = "INSERT INTO newsletter_signup VALUES ('$form1','$form2','$form3','$form4','$form5','$form6','$form7','$form8','$form9','$form10','$form11','$form12'); Apart from that no.
  4. Your missing a ; on your include statement include ("connection.php");
  5. Yup you can use "Next Wednesday" as a modifier for the strtotime function. $newDate = strtotime("Next Wednesday", time()); echo date('jS F Y',$newDate); Check out this page for other valid modifiers: http://www.gnu.org/software/tar/manual/html_node/Relative-items-in-date-strings.html#SEC120
  6. I cant see why it would be 2 more but it makes sense that it is 1 more. Your for loop is checking that the value if $counter is equal or less than $num.. if it is not then break the loop - that means the final value of $counter is 1 more than $num. As your loop can only loop through to the value of $num (there is no break condition) you might as well just display Added ".$num." bowls.
  7. if ($ticket == "cool" || $ticket == "not cool" || $ticket == "wow") { $pass = "YES"; } else { $pass = "NO"; }
  8. Hello mate, I have just solved a similar problem on a project I am currently working on. I didnt put the logic in SQL however - I pulled a wide result and then pushed the results in PHP - obviously you can choose how you do it but the following captures all possibilities. IF ((ReqArr < arrival) && (reqdep > arrival) || IF (ReqArr >= arrival) && (reqdep <= departure) || IF (ReqArr > arrival) && (ReqArr < departure)) Not sure whow you would translate that logic to SQL but will hopefully push you in the right direction. Dave
  9. Hi Gazever, Have you tried the single character wildcard? like 'd_t_' Havent tested but I think that would work.
  10. Im not 100% - but cant you just put the $entrye data between the <TEXTAREA></TEXTAREA> Tags - rather than using the Value="" attribute?
  11. You were not far off $result=mysql_query("SELECT sum(total) as total FROM my_table WHERE seller_id=$seller_id"); $total = mysql_fetch_array($result); echo $total;
  12. php_dave

    SQL help

    SELECT MIN(story_historyID) from story_history Group By StoryID Not tested.. but I think the above would work - will select the smallest HistoryID for each storyID.. assuming the smallest historyID is the earliest version?
  13. Hey, You shouldnt be calling the realname function as this only returns the field "name" from cerebra.. change this $thissquadronDBID = $advisee["squadronDB"]; $squadronDBRealName = getRealName($thissquadronDBID); to this $squadronDBRealName = $advisee["squadronDB"]; And your Squad names should display as intended.
  14. Aye it appends 'QUERY_STRING' - my bad - apologies for the bum steer. As for the OPS comparison problem - I cant see any logic problems - I just replicated on my machine and the comparison returns True.
  15. Hi mate, This query $sql = "SELECT id, squadronDB FROM cerebra WHERE approved=\"true\" AND squadronDB IS NOT NULL AND squadronDB != \"\" AND type=\"student\" ORDER BY squadronDB"; what does squadronDB return? is it a number or ALPHA, BETA?
  16. $page = $_SERVER['REQUEST_URI']; $query = $_SERVER['QUERY_STRING']; $fullString = $page.$query; REQUEST_URI does not return the query string (everything including the ? onwards) - you need to pull that from QUERY_STRING and add it on. Hope this helps Dave
  17. Hi, Firstly - about your new section of code - I cant see what it is doing. You are comparing $row to $row['user_group'] but you do not pull back a user_group field in your SQL query?? As for your original question can I see the getRealName Function? $squadronDBRealName = getRealName($thissquadronDBID);
  18. Hi, Either remove the ."/" from this line define('FULL_PATH', $_SERVER['DOCUMENT_ROOT']."/"); //no ending slash. or dont put / infront of your folder names for example $full_path_to_db = FULL_PATH."/adminpanel/db.php"; should be $full_path_to_db = FULL_PATH."adminpanel/db.php"; I havent used the whole package so based on the page of code you have posted and the comment "// no ending slash" - I would plump for the first one to stop any issues in further code pages. HTH Dave
  19. Use a config.php script.. something like <?php $server = "localhost"; $username= "username"; $password = "password"; ?> and then just include config.php in your main script.
  20. Thanks for the clarification guys!
  21. Guys, I had a quick hunt around and couldnt find anything specific - and have read the documentation but couldnt find anything concrete. At what point is an instance destroyed from memory without impicitly calling unset($class) or $class = null; I ask because I am relatively new to OOP and have just implemented a class to handle some SLA logic - this logic is used across three seperate .php pages and I initiate a new instance on each page. Im a little worried that im not managing the destruction and removal from memory effeciently and will end up with slow performance or memory fill! Questions: 1. Should I be initiating a new instance of my class on every page that uses it? 2. Do I need an implicit unset($class) and a __destructor or is page end good enough to destroy from memory? Sorry if I am rehashing old ground but you guys are so helpful
  22. Sorry to hijack the thread - but for my understanding - if this is the case how do sql injections work? for example SELECT id from user_Table where id = '1'; drop table users; I haven tested but was always under the impression that mysql_query() would handle mulitple queries.
  23. Hello mate, If these are your reference tables then firstly you need to have unique identifiers in uid for each row - and then use a link table to join them togethor. Link Table: link_id: link_name: link_dept: link_task: 1 1 1 1 Then this below query will give you what you want SELECT name.name, dept.dept, task.task from link_id Inner Join name on link_name=name.uid Inner Join dept on link_dept=dept.uid Inner Join task on link_task=task.uid where <conditions here> HTH Dave
  24. you can only insert 1 row at a time but you can execute more that 1 sql statement at a time - and it looks like you are concatinating a number of insert qureries. What is the error message?
  25. Hi, mysql_fetch_assoc pulls 1 row at a time and then increments the row number - when in a while loop you constantly change the value of $commrow with the new row from your mysql_fetch_assoc statement. When outside the loop you only ever pull the first row and then loop it over and over again. http://uk2.php.net/mysql_fetch_assoc
×
×
  • 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.