![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
RussellReal
-
Posts
1,773 -
Joined
-
Last visited
Posts posted by RussellReal
-
-
its always a good idea to nest your conditionals.. if you think about it..
if you had a neatly organized file cabinet you'd be able to find the paper you need faster.. than if you had all the papers in a pile and you have to use extra power to look through all of the papers..
being neat is always looked @ by employers as well..
-
you need
==
((value == value) && (value == value))
is called if nesting, or thats what I call it..
its used to GROUP conditionals together
for example
if (((value4 == value1) && (value1 == value3)) || (value2 == value4)) {
}
&& = and
|| = or
-
well.. in the script I altered for you.. I expect a GET variable called 'page'
so you'd just do
whatever.php?page=2
3
4
etc
-
when you stream a video, that video is actually being sent to the clients as they're watching it.. so either way you're sending the video file for the world to have access to..
-
change
$increasegold = mysql_query("UPDATE resources SET gold = gold + '$amount'")
to
$increasegold = mysql_query("UPDATE `resources` SET `gold` = `gold` + '$amount' WHERE `playerid` = '{$playerid}'")
-
#1
$SQL = "SELECT * FROM users WHERE username = '{$username}' ";
$result = mysql_query($SQL) or die(mysql_error());
$row = mysql_fetch_array($result);
$pin = $row["pin"];
$user = $row["username"];
$level = $row["level"];
$active = $row["active"];
is not needed.. get all that data from the second query
#2
do the checks for if user is invalid or w\e BEFORE you do queries..
#3
on your localhost you probably have the database set up..
on the server your database probably has errors.. like wrong types.. no table at all, misspelled table name.. etc etc
-
you should include a WHERE clause in yoru UPDATE
-
for str replace you don't need to match the number of TO-REPLACE strings with WITH-REPLACE
for example
echo str_replace(array("abc","def"),"","abcdefghi"); // ghi
-
also bro, not to contradict you.. but globals are very much unneeded.. there is a much better way with referencing the variable in the function call
$omg = "lmao"; whatever($omg); function whatever(&$geeze) { // $geeze will be a variable accessing $omg, instead of just handling teh VALUE of $omg.. meaning any change you do to $geeze in here, affects $omg.. }
-
what?
pagination is really easy, particularly if you are paginating sql results.. LIMIT works wonders
-
hes trying to round to .5 intervals..
....
thats why I wrote the function, everybody knows about round()
EDIT::
oo I see what sasa did
*** RussellReal extracts foot from mouth ***
*** And then inserts directly up the rectum of mjdamato ***
-
ok for example:
you have a table
`menu_table`
now.. the construct on this table is:
int `id` auto_increment
text `page`
text `options`
a fake entry of this table:
`id` = 1 `page` = index.php `options` = a:3:{i:0;a:2:{i:0;s:4:"HOME";i:1;s:9:"index.php";}i:1;a:2:{i:0;s:8:"SERVICES";i:1;s:12:"servives.php";}i:2;a:2:{i:0;s:9:"DOWNLOADS";i:1;s:13:"downloads.php";}}
how we arrived at the options to look that way is rather simple to manage:
<?php $arr = array(); $arr[] = array("HOME","index.php"); $arr[] = array("SERVICES","services.php"); $arr[] = array("DOWNLOADS","downloads.php"); $options = serialize($arr); ?>
to undo the serialization is simple..
<?php //do your mysql stuff here and read from the table for the current page $arr = unserialize($row['options']); $arr[] = array("PAGE TO ADD","PATH/TO/PAGE.php"); $options = serialize($arr);
I'm sure you could bridge something off of this to simplify the means of building menues for each of your pages
-
page=1
page=2
page=3
-
hes trying to round to .5 intervals..
not like
1.5 to 2.0
1.5 would be 1.5
1.6 would be 1.5
1.4 would be 1.5
1.2 would be 1.0
thats why I wrote the function, everybody knows about round()
EDIT::
oo I see what sasa did
-
the MSN add is always on the table incase you need any help in the future that way you don't need to rip your hair out for 10 hours
-
oh sorry bro it should be greater than instead of less than for the second if..
<?php $page = $_GET['page']; $rpp = 4; $c = 0; $handle = opendir('comments/'); if($handle) { while(false !== ($file = readdir($handle))) { if(preg_match("/\w+(.gif)/",$file)) { $c++; if ($c > (($page * $rpp) + $rpp)) break; if ($c >= ($page * $rpp)) { echo "<div class='update_pics_frame'>"; echo "<div class='update_pics'>"; echo "<a href='comments/$file'><img src='comments/$file' width='200'border='0'></a>"; echo "</div>"; echo "</div>"; } } ?>
-
if you disabled auto increment your rows will require you to send an ID along with the INSERT, now, you could do without the ID row all together, however, that will lead to optimisation problems as you will have more than likely many results for 1 SELECT query, where as with an `id` you have unique rows throughout the table,,
If you'd like you could add me to MSN RussellonMSN[at]hotmail.com
-
<?php $page = $_GET['page']; $rpp = 4; $c = 0; $handle = opendir('comments/'); if($handle) { while(false !== ($file = readdir($handle))) { if(preg_match("/\w+(.gif)/",$file)) { $c++; if ($c > (($page * $rpp) + $rpp)) break; if ($c <= ($page * $rpp)) { echo "<div class='update_pics_frame'>"; echo "<div class='update_pics'>"; echo "<a href='comments/$file'><img src='comments/$file' width='200'border='0'></a>"; echo "</div>"; echo "</div>"; } }
-
I was tryna help her figure it out on her own
-
and id is probably auto increment so you probably wouldn't want to.. what you should do...
is ORDER BY and order it by PID
-
make a menu table
use serialize to group values together.. in pairs OPTION -> VALUE
$opt = serialize(array("option","value"));
then store that into a db with all the other option serialisations seperated by \x01 or something unconventional
then when you're going to place the next level in call that menu from the db and unserialize all the options and then place the options where they belong.. then you just need a menu table instead of a hundred text files for each menu..
and its easier to work with in terms of coding the admin panel
-
<?php print_r($propExterior); ?>
you will get something like..
Array (
[KEY] => VALUE
[KEY] => VALUE
[KEY] => VALUE
)
-
You're probably looking for
ALTER TABLE
-
add me to MSN I actively help most of the people on my friends list with PHP and MySQL so you would fit in nicely..
I also have done few tutor jobs for money but I prefer to help for free.
My name is Russell and my MSN is RussellonMSN [AT] hotmail.com
also: try <?php print_r($_POST); ?> to see if your values r being sent, and the construct of the print_r will tell you how you should reference the values
Create and Query XML document in Cache?
in PHP Coding Help
Posted