-
Posts
488 -
Joined
-
Last visited
Posts posted by chriscloyd
-
-
I agree with Psycho, but it does not have to be a cron job, if you do not want to use one. You could do it on login. When the user logs in and if it is the first login of the day you can show all available job matches/alerts for that user.
-
Hello,
I would create another row in your member table called subscription_id or what ever you would name the subscriptions table. Then in the subscriptions table just create the rows for the id, name, description (if one), term (months, years), cost, renewal automatically, signup_date, end_date? Some of the things I add to the new table. Then just do your magic.
-
var x = "#inputList",
y = 2;
$(add_button).on('click', function(e)
{
e.preventDefault();
$(x + y).css('display','inline);
console.log($(x + y)); //this should show you if you have the right object check your console
y++;
return false;
}); -
Well hello this is easy if you use jquery....
A couple of things
$(document).ready(function() { var appendEle = $("#updateFixture"); $("#fixtures").on('change', function() { appendEle.html(""); var stage = $(this).val(); $.post('getFixtures.php', {stage: stage}, function(data) { var obj = $.parseJSON(data); $.each(obj, function(index, fixture) { var newEle = $("<div></div>"); var goalsfor = $('<label>' + fixture.hometeam + ' Goals</label><input type="text" id="goalsfor_' + fixture.id + '" name="goalsfor_' + fixture.id + '" value="' + fixture.goalsfor + '" />'); var goalsagainst = $('<label>' + fixture.awayteam + ' Goals</label><input type="text" id="goalsagaint_' + fixture.id + '" name="goalsagaint_' + fixture.id + '" value="' + fixture.goalsagaint_+ '" />'); goalsfor.append(newEle); goalsagainst.append(newEle); newEle.append(appendEle); }); }); }); $("#saveButton").on('click', function() { $.post('saveFixtures.php', $("#contactForm").serialize(), function(data) { if(data == "success") { //do what you want } else { //do what you want } }); }); });
That is the jquery file you will need two other files to save the changes and update I can help with that too if you need
-
function multi_array_permutations($arrays)
{
$loops = 1;
foreach ($arrays as $array)
{
$loops *= count($array);
}
for ($i = 0; $i < $loops; $i++)
{
$product = 1;
for ($j = 0; $j < count($arrays); $j++)
{
$product *= count($arrays[$j]);
print($arrays[$j][$i/($loops/$product) % count($arrays[$j])]);
}
print(PHP_EOL);
}
} -
What exactly are you trying to do with this array?
-
Fastsol, you know he was trying to show an example so I will help him with that
array(array(1,1,1,1),array(2,2,2,2),array(3,3,3,3),array(4,4,4,4));
-
<form action="" method="post" name="contact">
<input type="text" name="name" placeholder="First and Last Name" /><br />
<input type="email" name="email" placeholder="Email Address" /><br />
<input type="text" name="phone" placeholder="Phone Number" /><br />
<textarea name="message">
Type Your Message Here
</textarea><br />
<input type="submit" name="submit" value="Send" /><br />
</form>
<?php
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$to = 'Your Email Address';
$subject = 'Contact Message From - ' . $name;
$body = "Name: {$name}\n
Email: {$email}\n
Phone: {$phone}\n
Message:\n
{$message}";
mail($to, $subject, $body);
} -
$team = $_GET['team'];
echo $team;
$query = 'SELECT * FROM a_players WHERE team= '. $team .' ORDER BY nameLast ASC';
$results = mysql_query($query);
$count = 0;
while($line = mysql_fetch_assoc($results)) {
I cleaned up your code a little bit.<?php $team = mysql_escape_string($_GET['team']); if(is_int($team)){ $query = "select `nameFirst`, `nameLast` from `a_players` where 'team' = '{$team}' order by nameLast asc"; $results = mysql_query($query); $count = 0; //why are you counting if you mind me asking while($player = mysql_fetch_assoc($results)) { $nameFirst = $player['nameFirst']; $nameLast = $player['nameLast']; echo <<<EOT <div> <a href="http://eg10basketball.com/playerinfo?nameFull={$nameFirst}-{$nameLast}">{$nameFirst} {$nameLast}</a> <br> </div> EOT; } }
-
You can always try printing out the global variable $_GET
try this
echo '<pre>';
print_r($_GET);
echo '</pre>';
it will show all the variables sent through
-
do this on your page before adding to the database just to make sure you are getting everything
<?php echo "<pre>"; print_r($_POST); echo "</pre>";
-
-
Google is a good way to find out information. I googled accessing Google spread sheet and found this. http://sim.plified.com/2008/09/14/accessing-google-spreadsheet-with-php/
-
my code
<?php error_reporting(E_ALL); include("security/config.php"); //create season for testing purposes $sql_season = "insert into season (`season`) values ('1')"; $conn->query($sql_season) or die($conn->error); $season = 1; //echo "Season 1:<br />"; //get number of teams $sql_teams = "select * from teams"; $rs = $conn->query($sql_teams) or die($conn->error); $num_of_teams = $rs->num_rows; //echo " Number of teams this season: {$num_of_teams}<br />"; //put all teams in array $teams = array(); while($ts = $rs->fetch_array(MYSQLI_ASSOC)){ $teams[] = $ts; } if($num_of_teams % 2 != 0){ $teams[] = array('name' => 'bye week', 'id' => 0); $sql_dummy = "insert into teams (`name`) values ('bye week')"; $conn->query($sql_dummy); } //how many matches $weeks = 10; $matches = 10; //echo " This Seaon will be {$weeks} consisting of {$matches} matches<br /><br />"; for($i = 0; $i < $weeks; $i++){ //mix up teams $teams1 = $teams; shuffle($teams1); $number_of_matches = (count($teams) / 2); shuffle($teams); $teams1 = array_slice($teams, 0, $number_of_matches); $teams2 = array_slice($teams, $number_of_matches, $number_of_matches); $teams2 = array_reverse($teams2); shuffle($teams1); shuffle($teams2); $week = $i + 1; $sql_week = "insert into weeks (`number`, `season_id`) values ('{$week}', '{$season}')"; $conn->query($sql_week) or die($conn->error); $weekID = $conn->insert_id; //echo " Week {$week} Created:<br />"; $matchup = array(); $x = 0; do{ shuffle($teams1); shuffle($teams2); $team_1 = array_pop($teams1); $team_2 = array_pop($teams2); $sql_search = "select * from matches where (`team_1` = '{$team_1['id']}' or `team_1` = '{$team_2['id']}') and (`team_2` = '{$team_1['id']}' or `team_2` = '{$team_2['id']}') and `season_id` = '{$season}'"; $rs = $conn->query($sql_search) or die($conn->error); if($rs->num_rows == 0){ $sql_create = "insert into matches (`team_1`, `team_2`, `week`, `season_id`) values ('{$team_1['id']}', '{$team_2['id']}', '{$weekID}', '{$season}')"; $rs = $conn->query($sql_create); $x++; } else{ //echo "{$team_1['name']} vs {$team_2['name']} ==== Played already find new match up<br />"; $teams2[] = $team_1; $teams1[] = $team_2; array_reverse($teams2); shuffle($teams1); } } while($x < $number_of_matches); }
-
thanks, i made it work
Data printed:
Season 1:
Number of teams this season: 42
This Seaon will be 10 consisting of 10 matches
Week 1 Created:
Team 12 vs Team 31
Team 3 vs Team 40
Team 8 vs Team 6
Team 23 vs Team 5
Team 25 vs Team 1
Team 18 vs Team 39
Team 9 vs Team 14
Team 21 vs Team 15
Team 36 vs Team 38
Team 17 vs Team 7
Team 19 vs Team 11
Team 16 vs Team 20
Team 29 vs Team 32
bye week vs Team 2
Team 22 vs Team 10
Team 27 vs Team 13
Team 24 vs Team 34
Team 4 vs Team 35
Team 33 vs Team 37
Team 28 vs Team 20
Team 26 vs Team 30
Week 2 Created:
Team 10 vs Team 23
Team 27 vs Team 29
Team 1 vs Team 13
Team 40 vs Team 34
Team 35 vs Team 24
Team 37 vs Team 2
Team 25 vs Team 39
Team 20 vs Team 32
Team 36 vs Team 38 ==== Played already find new match up
Team 28 vs Team 7
Team 33 vs Team 31
Team 16 vs Team 11
Team 19 vs Team 8
Team 20 vs Team 9
Team 6 vs Team 14
Team 12 vs Team 26
Team 5 vs Team 22
Team 4 vs Team 30
Team 17 vs Team 36
bye week vs Team 21
Team 18 vs Team 3
Team 38 vs Team 15
Week 3 Created:
Team 16 vs Team 18
bye week vs Team 32
Team 2 vs Team 11
Team 23 vs Team 29
Team 20 vs Team 36
Team 21 vs Team 10
Team 9 vs Team 24
Team 13 vs Team 6
Team 7 vs Team 26
Team 40 vs Team 39
Team 33 vs Team 12
Team 8 vs Team 3
Team 38 vs Team 27
Team 34 vs Team 14
Team 4 vs Team 31
Team 22 vs Team 19
Team 5 vs Team 30
Team 1 vs Team 20
Team 28 vs Team 17
Team 15 vs Team 37
Team 25 vs Team 35
Week 4 Created:
Team 20 vs Team 11
Team 27 vs Team 28
bye week vs Team 15
Team 17 vs Team 2
Team 9 vs Team 21
Team 16 vs Team 13
Team 39 vs Team 5
Team 24 vs Team 6
Team 32 vs Team 19
Team 22 vs Team 37
Team 26 vs Team 10
Team 4 vs Team 36
Team 23 vs Team 20
Team 8 vs Team 34
Team 18 vs Team 14
Team 12 vs Team 1
Team 31 vs Team 7
Team 25 vs Team 40
Team 30 vs Team 33
Team 29 vs Team 35
Team 38 vs Team 3
Week 5 Created:
Team 18 vs Team 8
Team 22 vs Team 35
Team 19 vs Team 39
Team 12 vs Team 40
Team 37 vs Team 33 ==== Played already find new match up
Team 6 vs Team 20
Team 24 vs Team 5
Team 32 vs Team 20 ==== Played already find new match up
Team 3 vs Team 32
Team 20 vs Team 1 ==== Played already find new match up
bye week vs Team 15 ==== Played already find new match up
Team 13 vs Team 16 ==== Played already find new match up
Team 7 vs Team 13
Team 4 vs Team 2
Team 30 vs Team 11
Team 1 vs Team 10
Team 29 vs Team 38
Team 15 vs Team 21 ==== Played already find new match up
Team 27 vs Team 20
Team 28 vs Team 37
Team 25 vs Team 34
Team 9 vs bye week
Team 21 vs Team 15 ==== Played already find new match up
Team 33 vs Team 26
Team 16 vs Team 31
Team 36 vs Team 21
Team 15 vs Team 14
Team 23 vs Team 17
Week 6 Created:
Team 14 vs Team 36
Team 7 vs Team 40
Team 20 vs Team 30
Team 24 vs Team 4
Team 28 vs Team 37 ==== Played already find new match up
Team 13 vs Team 22
Team 39 vs Team 5 ==== Played already find new match up
bye week vs Team 33
Team 8 vs Team 10
Team 25 vs Team 18
Team 12 vs Team 27
Team 21 vs Team 28
Team 38 vs Team 9
Team 5 vs Team 32
Team 23 vs Team 16
Team 34 vs Team 20
Team 17 vs Team 3
Team 11 vs Team 1
Team 37 vs Team 31
Team 26 vs Team 2
Team 19 vs Team 6
Team 29 vs Team 15
Team 35 vs Team 39
Week 7 Created:
Team 11 vs Team 17
Team 4 vs Team 22
Team 39 vs Team 1
Team 20 vs Team 24
Team 33 vs Team 7
Team 12 vs Team 26 ==== Played already find new match up
Team 6 vs Team 35
Team 2 vs Team 36
Team 37 vs Team 19
Team 5 vs Team 14
Team 38 vs Team 10
Team 28 vs Team 3
Team 40 vs Team 32
Team 21 vs Team 23
Team 15 vs Team 20
Team 26 vs Team 27
Team 8 vs Team 9
Team 16 vs Team 34
Team 29 vs Team 31
Team 25 vs bye week
Team 18 vs Team 12
Team 30 vs Team 13
Week 8 Created:
Team 26 vs Team 33 ==== Played already find new match up
Team 40 vs Team 20
Team 25 vs Team 26
Team 10 vs Team 2
Team 35 vs Team 5
Team 30 vs Team 14
Team 15 vs Team 7
Team 20 vs Team 24 ==== Played already find new match up
Team 33 vs Team 27
Team 9 vs Team 20
Team 8 vs Team 6 ==== Played already find new match up
Team 29 vs Team 23 ==== Played already find new match up
Team 23 vs Team 19
Team 31 vs Team 18
Team 4 vs bye week
Team 11 vs Team 29
Team 1 vs Team 32
Team 6 vs Team 22
Team 16 vs Team 37
Team 12 vs Team 28
Team 36 vs Team 3
Team 38 vs Team 34
Team 24 vs Team 8
Team 17 vs Team 39
Team 21 vs Team 13
Week 9 Created:
Team 2 vs Team 20
Team 31 vs Team 33 ==== Played already find new match up
Team 21 vs Team 22
Team 17 vs Team 27
Team 12 vs Team 26 ==== Played already find new match up
Team 39 vs Team 16
Team 11 vs Team 25
Team 35 vs Team 19
Team 13 vs Team 32
Team 34 vs Team 20 ==== Played already find new match up
Team 6 vs Team 18
Team 7 vs Team 28 ==== Played already find new match up
Team 28 vs Team 4
Team 36 vs Team 8
Team 33 vs Team 31 ==== Played already find new match up
Team 30 vs Team 37
Team 40 vs Team 9
Team 26 vs bye week
Team 24 vs Team 12
Team 14 vs Team 34 ==== Played already find new match up
Team 34 vs Team 7
Team 29 vs Team 10
Team 38 vs Team 14
Team 15 vs Team 5
Team 20 vs Team 23 ==== Played already find new match up
Team 31 vs Team 3
Team 1 vs Team 20
Team 23 vs Team 33
Week 10 Created:
Team 38 vs Team 20
Team 40 vs Team 30
Team 34 vs Team 28
Team 20 vs Team 1 ==== Played already find new match up
Team 22 vs Team 10 ==== Played already find new match up
Team 25 vs Team 24
Team 29 vs Team 20
Team 19 vs Team 11 ==== Played already find new match up
Team 1 vs Team 4
Team 37 vs Team 36
Team 7 vs Team 2
bye week vs Team 18
Team 14 vs Team 6 ==== Played already find new match up
Team 9 vs Team 21 ==== Played already find new match up
Team 21 vs Team 31
Team 5 vs Team 26
Team 23 vs Team 19 ==== Played already find new match up
Team 10 vs Team 33
Team 6 vs Team 14 ==== Played already find new match up
Team 17 vs Team 6
Team 35 vs Team 22 ==== Played already find new match up
Team 39 vs Team 23
Team 32 vs Team 12
Team 22 vs Team 8
Team 14 vs Team 3
Team 27 vs Team 13 ==== Played already find new match up
Team 16 vs Team 35
Team 13 vs Team 15
Team 11 vs Team 9
Team 19 vs Team 27 -
I noticed i had some errors in my code. Updated code and still no luck
<?php error_reporting(E_ALL); include("security/config.php"); //create season for testing purposes $sql_season = "insert into season (`season`) values ('1')"; $conn->query($sql_season) or die($conn->error); $season = 1; echo "Season 1:<br />"; //get number of teams $sql_teams = "select * from teams"; $rs = $conn->query($sql_teams) or die($conn->error); $num_of_teams = $rs->num_rows; echo " Number of teams this season: {$num_of_teams}<br />"; //put all teams in array $teams = array(); while($ts = $rs->fetch_array(MYSQLI_ASSOC)){ $teams[] = $ts; } if($num_of_teams % 2 != 0){ $teams[] = array('name' => 'bye week', 'id' => 0); $sql_dummy = "insert into teams (`name`) values ('bye week')"; $conn->query($sql_dummy); } //how many matches $weeks = 10; $matches = 10; echo " This Seaon will be {$weeks} consisting of {$matches} matches<br /><br />"; for($i = 0; $i < $weeks; $i++){ //mix up teams $teams1 = $teams; $teams2 = $teams; shuffle($teams1); shuffle($teams2); $week = $i + 1; $sql_week = "insert into weeks (`number`, `season_id`) values ('{$week}', '{$season}')"; $conn->query($sql_week) or die($conn->error); //$weekID = $conn->insert_id; echo " Week {$week} Created:<br />"; $matchup = array(); for($x = 0; $x < $matches; $x++){ shuffle($teams1); shuffle($teams2); $team_1 = array_pop($teams1); $team_2 = array_pop($teams2); $rs = true; $rs = ($team_1['id'] != $team_2['id'] ? true : false); $sql_search = "select * from matches where season_id = '{$season}' "; $sql_search .= "and team_1 = ('{$team_1['id']}' or '{$team_2['id']}') "; $sql_search .= "and team_2 = ('{$team_1['id']}' or '{$team_2['id']}')"; $rss = $conn->query($sql_search) or die($conn->error); if($rs && !$rss){ $sql_create = "insert into matches (`team_1`, `team_2`, `week`, `season_id`) values ('{$team_1['id']}', '{$team_2['id']}', '{$week}', '{$season}')"; $rs = $conn->query($sql_create); if($rs){ echo " "; echo "{$team_1['name']} vs {$team_2['name']}<br />"; } else{ echo 'error: ' . $conn->error . '<br />'; } } else{ $teams1[] = $team_1; $teams2[] = $team_2; $x--; } } }
-
I am having a dilemma. I am working on a script for a client. It is a match making system. It takes all the teams, minimum of 20 teams. 10 matches a season. No team can play the same team in the season. Here is my code I have so far. If it does not make sense ask me, I will try to explain more in depth.
<?php error_reporting(E_ALL); include("security/config.php"); //create season for testing purposes $sql_season = "insert into season (`season`) values ('1')"; $conn->query($sql_season) or die($conn->error); $season = 1; //testing purpose echo "Season 1:<br />"; //testing purpose //get number of teams $sql_teams = "select * from teams"; $rs = $conn->query($sql_teams) or die($conn->error); $num_of_teams = $rs->num_rows; echo " Number of teams this season: {$num_of_teams}<br />"; //testing purpose //put all teams in array $teams = array(); while($ts = $rs->fetch_array(MYSQLI_ASSOC)){ $teams[] = $ts; } if($num_of_teams % 2 != 0){ $teams[] = array('name' => 'bye week', 'id' => 0); $sql_dummy = "insert into teams (`name`) values ('bye week')"; $conn->query($sql_dummy); } //how many matches $weeks = 10; $matches = 10; echo " This Seaon will be {$weeks} consisting of {$matches} matches<br /><br />"; //testing purpose for($i = 0; $i < $weeks; $i++){ //mix up teams $teams1 = $teams; $teams2 = $teams; shuffle($teams1); shuffle($teams2); $week = $i + 1; //$sql_week = "insert into weeks (`number`, `season_id`) values ('{$week}', '{$season}')"; //$conn->query($sql_week) or die($conn->error); //$weekID = $conn->insert_id; echo " Week {$week} Created:<br />"; //$matchup = array(); for($x = 0; $x < $matches; $x++){ shuffle($teams1); shuffle($teams2); $team_1 = array_pop($teams1); $team_2 = array_pop($teams2); $rs = false; $rs = ($team_1['id'] == $team_2['id'] ? true : false); $sql_search = "select * from matches where season_id = '{$season}' " $sql_search .= "and team_1 = ('{$team_1['id']}' or '{$team_2['id']}') "; $sql_search .= "and team_2 = ('{$team_1['id']}' or '{$team_2['id']}')"; $rss = $conn->query($sql_search) or die($conn->error); if(!$rs || !$rss){ $sql_create = "insert into matches (`team_1`, `team_2`, `week`, `season_id`) values ('{$team_1['id']}', '{$team_2['id']}', '{$week}', '{$season}')"; $rs = $conn->query($sql_create); if($rs){ echo " "; //testing purpose echo "{$team_1['name']} vs {$team_2['name']}<br />"; //testing purpose } else{ echo 'error: ' . $conn->error . '<br />'; //testing purpose } } else{ $teams1[] = $team_1; $teams2[] = $team_2; $x--; } } }
-
Try this....
<html> <head> <script type="text/javascript" src="swfobject.js"></script> </head> <body> <?php if($user->data['is_registered']){ echo <<<EOT <script type="text/javascript"> var multiplayer = new SWFObject("player.swf?xml=config.xml&player_skin=skin.swf", "multiVideoPlayer", "361", "283", "7", "#FFFFFF", true); multiplayer.write("flashcontent"); </script> EOT; } else{ echo "Please login to access this page!"; } ?> </body> </html>
-
I have not tested it...
global $tax; $tax = .06; //You should make each item added go into one cookie as an array //example say i add shoe 2 and three this is what is could look like //$_COOKIE['Products']['shoe1'] = array('Price' => '', 'Description' => ''); //$_COOKIE['Products']['shoe2'] = array('Price' => '', 'Description' => ''); //then you can run an foreach loop if(!empty($_COOKIE['Products'])){ $price = 0; //scope $total = 0; //scope foreach($_COOKIE['Products'] as $Product => $Info){ print "<tr><td>"; print "<img src=\"Images/1.jpg\" width=\"100px\" height=\"75px\">"; print "</td><td>"; echo $Info['Description']; print "</td><td>"; echo $Info['Item#']; print "</td><td>"; echo "$" . $Info['Price']; print "</td><td> <form action=\"cart.php\" method=\"POST\"> <select name=\"dropdown1\" id=\"dropdown1\"> <option value=\"1\">1</option> <option value=\"2\">2</option> <option value=\"3\">3</option> <option value=\"4\">4</option> </select>"; print "<input type=\"submit\" name=\"Calculate\" value=\"Calculate\"> </form></td> <td style=\"align:center;\" width=\"100px\">"; $amount = $_POST['dropdown1']; $price .= $Info['Price']; $total .= $price * $amount + $tax; print "</td></tr>"; } } }
-
You are setting the id's but if a page is reloaded and the user does not have a cookie or a session it will not remember which user is logged in
-
here are two ways of doing what you want
$data = mysql_query("SELECT * FROM news") or die(mysql_error()); $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )){ foreach($info as $k => $v){ $$k = $v; } echo <<<EOT <div class="newsBody"> <div class="newsHeader"> <div class="newsDate"> Posted: {$date} </div> <div class="newsAuthor"> Posted By: {$author} </div> {$subject} </div> <div class="newsSynop"> {$body} </div> </div> EOT; }
OR which I prefer:
$data = mysql_query("SELECT * FROM news") or die(mysql_error()); $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array($data)){ echo <<<EOT <div class="newsBody"> <div class="newsHeader"> <div class="newsDate"> Posted: {$info['date']} </div> <div class="newsAuthor"> Posted By: {$info['author']} </div> {$info['subject']} </div> <div class="newsSynop"> {$info['body']} </div> </div> EOT; }
-
<?php
function confirmed_logged_in( ) {
$returned = isset($_SESSION['user_id']) && $_SESSION['access'] == 1 ? true : false;
return $returned;
}
function store_logged_in( ) {
if(!confirmed_logged_in( )){
goto_page('urlgoeshere.com');
}
//other code here
} -
When you use _END there and be no whitespaces before or after and has to be all the way to the left.
-
yep! you did nothing wrong but here is a short hand echo that I like to work with.
<?=$record['studyName'];?>
I hope you have a good time coding
data not inserted into database ..
in PHP Coding Help
Posted
Try this