premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
limit a result so there is a next 10 and a previous 10 button
premiso replied to huntrguy102's topic in MySQL Help
You can read about Pagination at the Basic Pagination tutorial. -
You do not have the column team{$team} in your database design. Not sure what you want, perhaps an AND statement? $sql = "SELECT `team` FROM glossary WHERE word='{$word}' AND team = '{$team}'"; Given that you have the or die mysql_error, you should have been given an error that the column team$team does not exist (whatever $team is).
-
You will want to use preg_match. preg_match('~.com/list/tor/([0-9]{10}).html~', $match); $num = $match[1]; Untested, but should get the 10 digit number, pending any mistakes I may have made.
-
You are making little sense. Is this what you tried? if(isset($submit)) { If so, that tends to lead me to believe you are working with register_globals being on, which in itself can cause a security loop hole, especially if you do not define variables. Either of the two ways below would be preferred: if(isset($_POST['submit'])){ Or: $submit = isset($_POST['submit'])?$_POST['submit']:false; if($submit){ Note with the first method, if you are using $submit anywhere else in your code, you should define it as I have shown in the second method, as this ensures that $submit has a value which you know where it comes from.
-
I would think that to be only true of register_globals is turned on, which it should be turned off, as if it is not that can cause some security loop holes. As such, you should always define a variable before you use it blindly. This way you know what it should contain and not have to guess. As far as which way is better, imo I would prefer Jay's way as it tends to be less code. Nothing against you team, just providing some more information on the matter.
-
You can always buy www.bunk.com. Well you have to have $50,000, but yea can buy it!
-
It would tend to help if you also posted the section where you are trying to use isset (or even add the isset code in there). As I fail to see any isset being used in that code you posted.
-
Has the variable you are checking been set? From the if statement not working, I bet not. You need to provide more code to get a more exact answer.
-
Chances are your php.ini on your local server does not have short_open_tags enabled. Hence you cannot use <? when that is disabled. To fix it, either fix your code to use <?php instead of <? (which is the recommended method) or modify your php.ini file and change the short_open_tags to be enabled. (May require an Apache restart).
-
preg_replace('#([-]{2,}.*)#s', '', $input) Should work properly.
-
how select data from table and place it in html form
premiso replied to doforumda's topic in PHP Coding Help
list($year, $month, $day) = explode("-", $row['dob']); The MySQL Date format should be YYYY-MM-DD, so that should get you your variables. -
how select data from table and place it in html form
premiso replied to doforumda's topic in PHP Coding Help
[ot]Why do you have a table of it's own for dob? Do you expect people to have multiple dob's? (Just Curious)[/ot] You need to provide us with more information, such as what data type is dob, is it a UNIX Timestamp, or a MySQL Date field? As this is needed to provide you with the correct answer. -
Given that your value is "02" I take it that the extension field is a Varchar or a Char, correct? Max will not work on that as it is a textual field, they will need to be int / double / float for MAX to work on them.
-
Aro, you may be partially correct, but say he wants to pull data from column1 and column2 and he wants to display column2 whether column1 is null or not (as it may not be a required field). The query would not allow for that, however testing if it is null would. Which is why I provided both solutions.
-
PHP does not allow overriding. You have two options that I know of. 1: Re-compile PHP with your new logic. 2: Create a new function with a different name that has the logic you want (IE: create a function strtolower_utf8)
-
Check if the value is_numeric then static cast the var to int: $id = isset($_GET['id']) && is_numeric($_GET['id'])?(int) $_GET['id']:0; The ternary operator (? : ) act as a shortened if / else. So if the get id has been set and it is numeric cast the id to int, else set id to 0.
-
$query11= mysql_query("UPDATE tags SET counter=counter+1 WHERE tagName='$search' ") or die (mysql_error()); Give that a try.
-
Then use the is_null function on the variable... <?php if(!is_null($wineprice2)) { echo '<div class="price"> $' . $wineprice2 .'</div>'; } ?>
-
is_null or you can filter the SQL to not pull null data if that is an option: SELECT * FROM table WHERE col1 IS NOT NULL
-
You can use Regular Expressions to grab the data. As such I will move this request to the Regex forum. References: preg_match
-
The only ways I could think of this being possible is to A: create a table for searches which holds the id's of that particular search in order they were selected. So basically when the search is initially done a new record is inserted into that table (the searchid can be appended using GET or session) then just access that table for the next set of ID's to query. B: Store the id's in session instead of in a table. The advantage of storing them in a search table, is you can say "recently searched" and display those results for SEO stuff. The upside to the session, a lot less work as all you need is one session variable with searchedids stored in it and just access them. At least thats the theory behind them, good luck.
-
is_int would be my preference, but you could also just static cast the get data to an integer and be safe: $id = (int)$_GET['id']; Will force the get variable to be converted to an int. Either or should be fine. EDIT: Since you expect an INT, use that to check it. If you wanted any number, double int etc, then is_numeric would be the method of choice. Just an FYI, you check the exact type you are expecting, if only that type is allowed.
-
The -> is used in the context of objects. It can call a method inside of an object or an object property. You generally see it used in Object Oriented Programming. So: $object->property; Or: $object->method();
-
An example, if the values for the dropdown are not coming from a database then store them in an array: $buildings = array("School", "Commercial Building", "Industrial"); // add more. $dd = '<select name="Building" onchange="if (valDrop(this.value)) return true; else alert(\'Please Select a Building.\');">'; $dd .= '<option value="">Please Select a Building</option>'; foreach ($buildings as $build) { $dd .= '<option value="' . $build . '" ' . ($building == $build?'selected="selected"':'') . '>School</option>'; } $dd .= '</select>'; echo $dd; Should work, then you just need to add to the $buildings array to add more.
-
any way to restrict the number of new lines \r\n ?
premiso replied to Anti-Moronic's topic in Regex Help
Here is one way to do it, basically if 10 blank lines are reached nothing is appended to the string until that variable is reset (meaning non-empty data was output). <?php $string = "somtext\r\nmore text\r\n\r\n\r\n\r\nmore text\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nmoretext here\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; $strArr = explode("\r\n", $string); $string = ""; $i=1; foreach ($strArr as $str) { if (!empty($str)) { $string .= $str; // reset $i $i=1; }else { if ($i < 10) { $string .= "\r\n"; $i++; } } } echo nl2br($string) . "end"; ?>