-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
Ok, so what I'm trying to do is go through an array, and get the columns of the array that are numeric (its a 2-d array) Is there an easy way to simply delete an entry in an array. I looked up on google for a few answer, but most answers used the array_filter function, which isn't what I want. basically I have the following so far temp_cols = array(); $non_cols = array(); $arr = $this->data; foreach($arr as $row){ foreach($row as $key => $cols){ if (ctype_digit($cols) && !in_array($key, $non_cols)){ if (!in_array($key, $temp_cols)){ temp_cols[] = $key; } } else { $non_cols[] = $key; if (in_array($key, $temp_cols)){ //remove entry here } } } } basically, this function goes through every cell in the 2d array, and checks if the specific cell is numeric, and if the column it is part of isn't in the array of numeric columns, then I want to add it to the columns. however, since some columns may have some numeric, and some non-numeric entries, I put any columns that have non-numeric entries into the another array, and remove the column from the numeric columns array if it is in there. I know this is probably pretty simple, but I just can't think of how to do it efficiently and painless (I would rather not have to use array_filter, and make my own function) Any ideas? Anyone have any ideas? EDIT: Just noticed im using in_array horribly wrong. Fixed now to reflect my actual code
-
I see, cool, just wanted to clear that up. thanks for the reply!
-
[SOLVED] Using a double if/else statement...
mikesta707 replied to dannyluked's topic in PHP Coding Help
oh your mysql syntax was wrong. change to $result = mysql_query("SELECT userlevel FROM ac_users WHERE username = '" . $_SESSION['loggedin'] . "'"); -
I never quite grasped the concept of private functions vs. public functions. What exactly is the difference. Are private functions only callable inside the class itself? say i had a class class foo{ public function hi(){ $this->bar(); } private function bar(){ echo "can't touch this"; } } $foo = new foo(); //would this not work $foo->bar(); //but this wwould work? $foo->hi(); Is there more than just that?
-
[SOLVED] Using a double if/else statement...
mikesta707 replied to dannyluked's topic in PHP Coding Help
.... if (!isset($_SESSION['loggedin'])){ echo "not logged in"; exit(); } else { $result = mysql_query("SELECT userlevel FROM ac_users WHERE username = '"$_SESSION['loggedin']"'") or die(mysql_error()); $row = mysql_fetch_array( $result ); $userlevel = $row['userlevel']; if ($userlevel == 0){ echo ".."; } } EDIT: Oh i see your problem now. -
I would suggest not having a count, and just getting the count whenever you calculate the points. if you really want to store the count, store it in a different table. (called competitions of something, which you could link to the other table via the unique competition id) How exactly do you want to calculate the points? Is it simple math? What your describing sounds pretty straight forward. Just query the table, get the information for each player by iterating the mysql_results and update your other table.
-
what do you mean by replace the blocked URL? replace them with what?
-
[SOLVED] problem with sql with get and user.
mikesta707 replied to Eggzorcist's topic in PHP Coding Help
well first off, you don't need to wrap your variables in curly brackets unless they are arrays I think. also change your query to $query = mysql_query("SELECT * FROM events WHERE id = '{$eid}' and user = '{$euser}'"); or die(mysql_error()); there is obviously an error occuring, that will show what it is. -
Nope, it will drop out at the boundry before the foreach loop started. so the following will only output 1-10 $arr = array(1, 2,3,4,5,6,7,8,9,10); foreach($arr as $ass){ $arr[] = $ass + 1; echo $ass; } Output: 12345678910 However, the following will show the full array $arr = array(1, 2,3,4,5,6,7,8,9,10); foreach($arr as $ass){ $arr[] = $ass + 1; } foreach ($arr as $ass){ echo $ass . "<br />"; } 1 2 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 11 however, rhodesa's example does keep going if you add more and more to the array, but the following example for($n=0;$n < count($arr);$n++){ $arr[] = $n + 1; echo $arr[$n] . "<br />"; } results in an endless loop, so make sure you don't add something to the array at every pass
-
It depends. If each of your posts are different from one another, you can do a check to make sure that the data isn't the same before posting it. If not, you can have a column in the array that logs the IP, and check if the IP has submitted data before on that table. You could also check if the very last row submitted is the same as the row thats about to be submit, and exit the script if they are the same
-
so you basically have a 4 dimensional array? do print_($games['slots']); but for each of your arrays, and post the output
-
you aren't using the in_array() function correctly... at all...
-
getting blank email from Apache...need help!
mikesta707 replied to nickalmand's topic in PHP Coding Help
The echo wouldn't be causing the problem, its just a test to make sure that the variable is being populated with data as you expect it to be. Assuming that you have SMTP installed correctly on your server, and you aren't getting any error messages, your script should work. -
Do you want help, or do you want someone to do it for you? If you want someone to do it for you, you can pay me to do it. But i'm not, and I doubt anyone else will just make your website for you. If you are looking for some direction on where to start, we would be glad to help. here are some tutorials: login tutorial: http://www.phpeasystep.com/workshopview.php?id=6 php/mysql tutorial: http://www.freewebmasterhelp.com/tutorials/phpmysql basic php tutorial: http://www.w3schools.com/PHP/DEfaULT.asP another basic php tutorial: http://www.tizag.com/phpT/ You will probably want to start with the PHP basics, then start learning how MySQL and PHP interact with each other. create a database, and a table, and then create a simple login system. after that you can come here, and use google to start doing the more complicated stuff
-
getting blank email from Apache...need help!
mikesta707 replied to nickalmand's topic in PHP Coding Help
after this line $email = $_POST['email']; write this echo $email . "<br />"; echo $_POST['email'] . "<br />"; -
$test = $apicall['xml']['anotherval'];
-
getting blank email from Apache...need help!
mikesta707 replied to nickalmand's topic in PHP Coding Help
echo the email variable, and the post variable before you execute the mail function. it seems like the post variable is empty. The form name may be slightly off (missing a capitalization or something) -
hmm.. do you get an error? post your code
-
Sure! I'll assume you know how to create a database table, and how to set up the rows and columns (if not, there are many very good tutorials out there for it. just google php and mysql table), and I will also assume you know basic mysql functions like mysql_query, fetch array, etc. etc so here is how I would get the list of words (assuming that your table is composed of only the words you want to output sql = "SELECT * FROM myWords ORDER BY votes"; $query = mysql_query($sql); echo "<table>";//gonna put stuff in table for formatting $i = 1; echo "<tr>"; while($row = mysql_fetch_assoc($query)){ echo "<td>" . $row['word'] . "</td>";//assuming the word column is called 'word' if ($i % 5 == 0){ //% = modulus. Its to basically to see if this is the fifth row in the column. do a google search for //modulus to find out more info on it //I want to make each row 5 columns long, so every 5th word I end the //current row and start a new one echo "</tr><tr>"; } $i++; }//end while echo "</tr></table>" Now to make each word votable, instead of just echoing the word, I would make the word a link. Lets assume the primary key is the column 'id'. well I would change the inside of my loop to the following while($row = mysql_fetch_assoc($query)){ echo "<td><a href='vote.php?id=".$row['id'].">" . $row['word'] . "</a></td>";//assuming the word column is called 'word' if ($i % 5 == 0){ echo "</tr><tr>"; } $i++; }//end while Now, on the vote.php page, which will do the updating, I would have something like $id = $_GET['id'];//this is from the vote.php?id= part of the link. id is the get variable, and $row['id'] is the value $insert = "UPDATE myWords set votes = votes + 1 WHERE id='$id'" $query = mysql_query($insert); echo "Word updated!"; this is very basic, but includes the basic logic required. Hope that helps!
-
change expenses.php to have the button look like Print "<td><form action='../expenses/expenses_delete.php?id=".$info['ID']."' method='post' name='Delete' id='Delete'> <input name='Delete' type='submit' id='Delete' value='Delete' > </td>"; though I would just make a simple link. like so: print "<a href='../expenses/expenses_delete.php?id=".$info['ID']."'>Delete</a>"; then on delete.php <?php include "../config.php"; $userid = $_SESSION['userid']; $Id = $_GET[id'];//assuming this is the primary key that you want to delete. mysql_query("DELETE FROM expenses WHERE UserID='$userid' AND Id='$Id' ") or die(mysql_error()); header("Refresh: 2; url=\"../expenses/expenses_frame1.php\""); echo "<br><br><br><h3><center>Record Deleted"; mysql_close("config.php") ?> Hope that helps!
-
delete the comma between the last set and the where clause. it should look like $query3="UPDATE `fixtures` SET `home_user` = '$newuser', `home_team` = '$newteam' WHERE `home_user` = '$olduser' AND `comp` = '$comp'"; $query4="UPDATE `fixtures` SET `away_user` = '$newuser',`away_team` = '$newteam' WHERE `away_user` = '$olduser' AND `comp` = '$comp'"; $query5="UPDATE `submittedresults` SET `home_user` = '$newuser',`home_team` = '$newteam' WHERE `home_user` = '$olduser' AND `comp` = '$comp'"; $query6="UPDATE `submittedresults` SET `away_user` = '$newuser',`away_team` = '$newteam' WHERE `away_user` = '$olduser' AND `comp` = '$comp'";
-
Well, to start off you want to create a table, with a column for the primary key, the word itself, its rank, number of clicks, and any other information you want. You should go through the database, and all the words in the table, ordered by votes, and output them, perhaps in an HTML table to make them look nice. You will want to make the each word a link, with a get variable that is specific to its primary key. You want that link to go to a different php page, that will update the count of votes on a specific entry based on the get variables ID. thats how I would do it anyways. Hope that helps!
-
try removing the quotes around the parameters of the mail function
-
hahaha jew page. $array = Array ( "" => Array ( 'jewpage_id' => e2acfb0606d1e8f994b687fd8de5b032, 'name' => lo, 'description' => ocation..., 'date' => 0000-00-00, 'address' => 250 Kearsing Pkwy, 'contact' => '', 'log' => 41.1265328, 'lat' => -74.0640814, 'state' => GA, 'city' => MONSEY, 'zip' => 91401, 'pic1' => upload/e2acfb0606d1e8f994b687fd8de5b032, 'pic2' => upload/e2acfb0606d1e8f994b687fd8de5b032, 'post_user' => 10, 'type' => Wedding Flowers, 'section' => "", 'price' => expensive, 'homepage' => "", 'rating' => 0, 'category_id' => 0 )); ? that should work that array is kind of screwy though.. has a bunch of empty elements, and the first index is null
-
I see. I would suggest, rather than breaking the PHP tags and putting in static html, just echoing the whole HTML itself in PHPO, (like some people have done here) I don't really see a problem in your code, so unless some obvious syntax error is eluding us all, I don't really know whats wrong EDIT: yeah im thinking its your PHP setup or something, because I can't see anything wrong with those lines