Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. well here's my take: <?php // dummy var holding the data $content = "2855,2120,197517875 3825,99,21367817 3177,99,18912900 1529,99,23891398 3382,99,24350662 18207,96,10122224 1885,99,13149819 56936,89,4998462 3694,99,15041475 229226,80,2019245 70576,91,6006279 61428,83,2785348 3065,99,13229364 24683,80,1990823 39221,74,1102697 92920,75,1284583 9061,82,2438605 5669,81,2287788 13137,83,2677386 6202,91,5924583 10378,82,2455028 19154,73,1019663 19710,79,1928393 89,99,13472515 432,89,5060818 2154,1943 -1,-1 -1,-1 -1,-1"; $a = explode(',',$content); // explode each comma separated set into an array // for each position in the array... foreach ($a as $b) { $c[] = explode(' ',$b); // explode each space separated set into a nested array, making a 2d array overall } // if you wanted to echo say, that 4th number 3825 // that would be the 2nd number in the 3rd set. // remember, positions start at zero... echo $c[2][1]; // ..or, just to display it all foreach($c as $key => $val) { $x = 0; while ($val[$x]) { echo "$key - $x => " . $val[$x] . "<br>"; $x++; } echo "<br>"; } ?>
  2. do you have session_start() on all of your pages, including the initial page where you assign info to your session variable?
  3. If ALL you are wanting to do is update the table, you do not need all that other script whatsoever. The most immediate thing I see is that your update query is inside that loop so it keeps being executed with new conditions because the variables keep changing with each iteration of the loop.
  4. it doesn't matter whether you it's one column in one row or 100 columns in 100 rows, the command for retrieving something is different from the one for updating, so you can't use that query string to update it. Furthermore, the actual script takes the retrieved data and dumps it out. Since your goal is to put stuff in and not take it out (and then do something with it), the only code in that entire block you provided that's any kind of useful is...nothing. $sql = "update tablename set column = '$somevar' where someothercolumn = '$someothervar'" $result = mysql_query($sql); that's a generic update script.
  5. well here's my take. I'm sure there's a way more elegant way of doing it, but whatever. <?php $alpha = array ('a','b'); // alpha prefixes $size = 3; // dummy var for number of combos including alpha prefix // for each prefix in the array foreach ($alpha as $a) { // you want a combo of $size digits so here goes... for ($x = 1; $x < $size; $x++) { $max.="9"; // since 9999..is largest number in any set.. } // end for // let's start counting... for ($x = 1; $x <= $max; $x++) { // we need to split up the digits so we can... $w = preg_split('//',$x); // so we can put a _ between them. Also trim the last one off $w = $a . rtrim(implode('_',$w),'_'); // echo current iteration (or save to an array or whatever here) echo "$w <br />"; } // end for // reset $max for next alpha prefix $max = 0; } // end foreach ?>
  6. but if he consistently misspells it, then that wouldn't be what's rong
  7. That script it meant to retrieve info from your database. You need to write a script to get the info from the form and put it into the database. Getting info from a form and putting it into a database is a very common beginner tutorial.
  8. // inside your loop, add the following... while ($row=mysql_fetch_array($result)) { $r1=$row['state_id']; $r2=$row['state']. ", " .$row['state_abbrev']; echo "<option value='$r1'"; echo ($row['state'] == $sel) ? " selected" : ""; echo ">$r2</option>"; echo "<color = 'red'> {$row['state']} : $sel <br />"; //add this line here } post output
  9. I'd go for something that removes everything between the < >
  10. $r = mysql_query("select max(game_id) from tablenamehere"); $id = mysql_fetch_row($r); echo $id[0];
  11. okay for real it works now. For some reason I thought you wanted the first one to be default. I reread it and changed it. Works for really real now.
  12. oops i didn't think that through. this works. <?php include 'library/dbconfig.php'; include 'library/opendb.php'; $query="SELECT state_id, state, state_abbrev FROM byrnjobdb.states ORDER BY state ASC"; $result=mysql_query($query); echo "<select method='get'>"; echo "<option>---Select---</option>"; $sel = "somestate"; while ($row=mysql_fetch_array($result)) { $r1=$row['state_id']; $r2=$row['state']. ", " .$row['state_abbrev']; echo "<option value='$r1'"; echo ($row['state'] == $sel) ? " selected" : ""; echo ">$r2</option>"; } echo "</select>"; include 'library/closedb.php'; ?>
  13. <?php include 'library/dbconfig.php'; include 'library/opendb.php'; $query="SELECT state_id, state, state_abbrev FROM byrnjobdb.states ORDER BY state ASC"; $result=mysql_query($query); echo "<select method='get'>"; echo "<option>---Select---</option>"; $sel = FALSE; while ($row=mysql_fetch_array($result)) { $r1=$row['state_id']; $r2=$row['state']. ", " .$row['state_abbrev']; echo "<option value='$r1'" . ($sel) ? " selected" : "" . ">$r2</option>"; $sel = TRUE; } echo "</select>"; include 'library/closedb.php'; ?>
  14. That's because the original #2 from the sticky was actually an exception to rule #1, which basically said you could have a small, unobtrusive ad to your site in your sig. I guess Daniel had some c/p issues or somethin'.
  15. -> is an object pointer. If you have a class say class blah { function printSomething ($something) { echo $something; } // end printSomething } // end class $ps = new blah(); $ps->printSomething("some message here"); printSomething is a method inside class blah. First I made an object called $ps. Then call the method printSomething by taking my $ps object and pointing to it. Many people use object oriented programming (OOP) to handle database interaction. They would have a method for connecting to the database, making queries to the database, handling/formatting the results, etc... for example, someone could have an object called $db and to connect to the db, they'd point to a method inside some class they made $db->connect(); and the method would run the commands to connect. Or they'd maybe do $db->dumpTable(); and maybe the function would do a generic select * from table and list everything or something. It's supposed to be an easier way to code, because lots of people feel that the more separation of code and design the better. They would rather be able to have html code here html code here one little php command here html code here html code here than html code here html code here lots of php commands lots of php commands more php commands html code here html code here which is kind of a valid argument, especially when you have a whole lot of code and you've got more than one person working on a site and one dude focuses on the design and one on the code and maybe that designer doesn't know much about coding, so that makes it easier for him. [] is used to denote positions in an array. If you have an array, say: $blah = array('a','b','c'); echo $blah[1]; $blah is an array. I am echoing the 2nd position in the array (position one starts at 0, not 1). An array is pretty much an easy way to group together similar data. For instance, abc are letters in the alphabet. Instead of having a variable for each one $a = "a"; $b = "b"; $c = "c"; You can make an array to hold all of them; a "super" variable with more than one slot, if you will. variable = something that has 1 slot for info. array - something that has lots of slots for lots of info. Certain functions for retrieving and handling data from your database return you an array of information. Consider this: $sql = "select somecolumn from sometable"; $result = mysql_query($sql); while ($list = mysql_fetch_row($result)) { echo $list[0] . "<br />"; } $list is an array. mysql_fetch_row only returns one slot for this array, so it kinda seems like overkill to have an array with just one position. we use $list[0] because again, we start at 0 not 1. This is called a numerical array. You can label the array positions so you can more easily remember what is supposed to be there. Those are called associative arrays, because you are associating a name with the position. If we had used "mysql_fetch_assoc" instead of "_row" we would have echoed $list['somecolumn'] instead of $list[0]. $list['somecolumn'] still signifies the first (and in this case, only) position in the array, but mysql_fetch_assoc labeled the position 'somecolumn' - the same name as our column name we queried for - so that we can remember what kind of data we have. I have a sneaking suspicion that you probably already knew everything I've said here; I'm not trying to talk down to you. I was just trying to (further) explain how, although -> and [] are seen in things like db handling, they aren't directly associated with it.
  16. 1) array_slice() 2) Neither one of those are specifically related to getting data from a database.
  17. ^ Broken link. Go here: http://www.expertsrt.com/tutorials/Matt/install-apache.html I personally wouldn't recommend to beginners to install them individually. Checkout WAMP or XAMPP they come with everything you need (and more) and install themselves right out the box.
  18. Right. You need to use a server side language (like php) to access and retrieve the info from the db and pass the results to flash.
  19. Yeah, but not because of that. It's because of my 10 inch.... tongue.
  20. If you are wanting the user's score to be added to the database, then you're adding that code to your code as a separate thing. If you're simply wanting to check the rank against the db, you are changing the code to that.
  21. without the [] you would put a number or variable there just like any other argument.
  22. [Mod cap] Is it really that hard to use code or php tags when posting code, or only posting the part that's giving you the trouble or at least highlighting it? [/Mod cap] I'm not really that great with oop but my guess is when you do $this->blah it is expecting blah to be a variable or method inside your class. Going down a couple lines into your code I see $this->cache_dir being used and yet I do not see cache_dir declared as a variable or method in your class.
×
×
  • 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.