Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. You just have to code the user function to do it. I have never seen it done. But I am sure it is possible to do, perhaps post your sort function code and maybe a before and end example of the data/sorted you want returned.
  2. Why not just use foreach to iterate through the $_POST array. As far as what you are trying to get it, I cannot see. But your for statement is not valid. I would look up at the manual for proper usage of that. Since it seems as though you have multiple check boxes here is an example: foreach ($_POST['checkboxesname'] as $key => $val) { echo "Checkbox: {$key} contains a value of {$val}<br />"; }
  3. You would have to use the second parameter of date with maybe strtotime if the format is not in a timestamp, if it is just put the timestamp in as the second parameter. date take a look at the manual on date for more information.
  4. Funny, just posted this else where. But it works for here too:
  5. I would use a case/switch. <?php $cmd = isset($_GET['cmd'])?$_GET['cmd']:0; switch($cmd) { default: case "0": //show default table break; case "1": //show table 1 break; case "2": //show table 2 break; } ?>
  6. Yep. Reading through the simple_xml functions/manual should help you on your way there. Alternatively, you could use preg_match_all and grab all the images, if they are within a certain specific tag instead of fussing with the xml functions.
  7. Found this little snippet function search($session_time) { //$session_time ="1151348975"; echo"You Entered: $session_time <BR>"; echo"The Current Time is = ".time()."<BR>"; $time_difference = time() - $session_time ; echo"time_difference = ".$time_difference."<HR>"; $seconds = $time_difference ; $minutes = round($time_difference / 60 ); $hours = round($time_difference / 3600 ); $days = round($time_difference / 86400 ); $weeks = round($time_difference / 604800 ); $months = round($time_difference / 2419200 ); $years = round($time_difference / 29030400 ); echo"seconds: $seconds<br>"; echo"minutes: $minutes<br>"; echo"hours: $hours<br>"; echo"days: $days<br>"; echo"weeks: $weeks<br>"; echo"months: $months<br>"; echo"years: $years<br>"; } From: http://www.wallpaperama.com/forums/learn-php-time-function-to-display-time-hours-days-weeks-months-years-t1033.html Hopefully that helps ya out.
  8. Your logic is flawed. How are you pulling the data out of the database? Really what you are looking for or need is to test if there is a tab character in the field you are trying to find. If there is then display that tabs. stristr can help on the php side of things. On the MySQL side, I am unsure, but the problem does not lie within the code you have posted here.
  9. mysql_real_escape_string $title = isset($_GET["title"])?mysql_real_escape_string($_GET["title"]):null; Should solve that issue. You should escape any string/text data going into the database with that function to prevent sql injection and errors with characters that cause mysql errors.
  10. You would probably of gotten a better response by putting this in the proper forum (Javascript Help). For future reference I would check where you are posting stuff as you will get better information from that forum and better help, as they know Javascript. Especially since you state it is "urgent". Just because you need it done as soon as you can get it done, does not mean you should just post it where ever you please.
  11. if (mysql_num_rows($results) > 0) { You want to see if there are 1 or more results. If there are then do the tabs, if not then no tabs were returned. 0 being returned by mysql_num_rows is a valid return value.
  12. Post your code around line 56. It sounds like you are in an infinite loop.
  13. It depends on how complicated you want to make it and how your database is setup. Look through here Plenty of examples there.
  14. if(mysql_num_rows($result) < 1) //remove the semi-colon here
  15. Not sure if this is just a typo. On the page receiving: <?php // you were missing the ? here $id = $_GET["i"]; $f = $_GET["f"]; echo $id; echo $f; ?> See if that gets you better results.
  16. It is optional. This would be a valid call: db_query("Some Query", "Some Message"); It would not throw an error. Thus the $auto is optional, as you do not have to pass it in for the function to work.
  17. You sure about that? Check out the Functions in the manual. function db_query($query,$msg,$auto=null) That way you can just pass in the first 2. Then you can use is_null or isset if you want to know if $auto was passed in or not.
  18. $result = mysql_query($query,$con) or die("SQL RAN: {$query}<br />Error: " . mysql_error()); That will tell you that there is an undefined column that will be the email address passed in via post. You need ' around string data. $query = "select email FROM phpaudit_clients WHERE email = '{$_POST['email']}' and forumacc = 0"; I would also use mysql_real_escape_string on string data being passed in from a form to be used in the DB as that code is prone to SQL Injection.
  19. It uploads the file to your server once they push submit before the form is processed. It is simply stored in a "temp" directory until you move the file. So doing that test on the name is fine, you could even just do this: if (isset($_FILES['myfile'])) If that is set then they attempted to upload a file via that form/field. But yea, the file is already on the server. After the script is ran it is deleted, hence if you did not move the file before then it is wiped from the server.
  20. In the OOP context, it should be: <?php $result = mysql_query("SELECT * FROM example_table"); while ($rows = mysql_fetch_object($result)){ foreach ($rows as $filedName => $row){ echo "Field: {$fieldName} returned {$row}"; } } ?> A foreach on an object will iterate through the viewable properties and return its name as the index, in this case the MySQL column name and the value of the field as a value. This is not used very much because generally you know how you want to display the data, like you wanted to display the date. Instead most people skip the foreach portion and just do something like this: <?php $result = mysql_query("SELECT * FROM example_table"); while ($rows = mysql_fetch_object($result)){ echo "Date: " . $rows->date . "<br />"; echo "Name: " . $rows->name . "<br />"; // assuming you have name column in the table of the db. } ?> What, I believe you are assuming is that the fetch_object returns the full array of objects. This is not true, that is why you have to while loop it. Here is an example, of what I think you are thinking it should produce: <?php $result = mysql_query("SELECT * FROM example_table"); $rows = array(); while ($row = mysql_fetch_object($result)){ $rows[] = $row; } foreach ($rows as $row) { echo "Date: " . $row->date . "<br />"; echo "Name: " . $row->name . "<br />"; // assuming you have name column in the table of the db. } ?> Notice the assignment to the array $rows, that loops through all the rows and assigns each one to the $rows array, then we foreach loop through that doing the displaying. Hopefully that clears this up for you.
  21. Sounds weird to me, but the count man has a way to count recursive elements. Not sure if this is what you are looking for So you "could" do this: <?php $count = (count($SearchCventResults['SearchResult'], 1) - count($SearchCventResults['SearchResult'])); ?> But that is really a hodged podged way of doing it. This would probably be preferred. <?php $temp = $SearchCventResults['SearchResult']['Id']; $cntIds = count($temp); $temp = null; echo $cntIds . " is how many elements are in SearchResult."; ?> But I am interested in why it does not work. I will probably do some more testing on my machine and let you know what I find out if anything. EDIT: I decided to do this: <?php $array = array("SearchResult" => array("Id" => array("bob", "you", "me"))); $cnt = count($array['SearchResult']['Id']); echo "\$cnt should be 3, it is: {$cnt} for array \$array."; die(); ?> And it returns three. There is something going weird in your code, not sure what it is but yea. Edit: In reply to: That is because he did not post the array results in a code tag. The Forum takes [0] as a list element, thus does not display it.
  22. header("Location: replyTechnical.php?to={$to}"); Then on the replyTechincal.php $to = isset($_GET['to'])?$_GET['to']:null;
  23. If paragraphs and the paragraphs are distinguishable you should look into using explode and explode the data at "\n" character: <?php $paragraphs = "split this at paragraph \n this would be the second paragraph"; list($firstPara) = explode("\n", $paragraphs); echo $firstPara; ?> At the substr man page there are a bunch of user contributions. Take a look there. Try this one first if what I posted does not solve your issue.
  24. You are setting content-type twice. I doubt that is kosher. Check out the header manual and try removing the application/force header and see what happens.
  25. It just means display_errors is set to off. I had an error in the code. <?php $cols = array(); // initiate the array. foreach($entries AS $entry) $cols[] = trim(strip_tags($entry)); // remove the html tags and trim for good measure. echo "<pre>", print_r($cols), "</pre>"; ?> Just remember it does need the code to populate the entries array to fully work.
×
×
  • 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.