Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. Are you trying to store all of the player names in an multi-dimensional array? So that msgColor1 is an array and has an array inside of it with the key named "name" and each value of the array "name" has each of the player names?

     

    If that's the case:

    foreach($playerName1 AS $value){
        $msgColor1['name'][] = $value;
    }

     

    And calling print_r on msgColor1 will give you an output of something similar to:

     

    Array
    (
        [name] => Array
            (
                [0] => johnny
                [1] => bob
                [2] => malcolm
            )
    
    )

  2. Why would you need to use Javascript for this? It's simply just using

     

    <input type="checkbox" name="interest[]" value="hockey">

     

    for all interests.

     

    <form method="post">
        <input type="checkbox" name="interest[]" value="hockey" />Hockey<br />
        <input type="checkbox" name="interest[]" value="soccer" />Soccer<br />
        <input type="checkbox" name="interest[]" value="baseball" />Baseball<br />
        <input type="checkbox" name="interest[]" value="basketball" />Basketball<br />
        <input type="submit" name="submit" value="Delete Selected Interested" />
    </form>
    <?php
    if($_POST['submit']){
        $interests = $_POST['interest'];
        if(count($interests) > 0){
            foreach($interests AS $interest){
                $sql = "DELETE FROM `interests` WHERE `interest`='".mysql_real_escape_string($interest)."'";
                $res = mysql_query($sql) or die(mysql_error());
                echo htmlentities($interest) . " has been removed!";
            }
        }
    }
    ?>

     

    Obviously other security measures could be implemented.

  3. <select name="mediaList" id="mediaList">
        <?php
        $options = array('Physical Only', 'Checkup Only', 'Both');
        foreach($options AS $option){
            $selected = ($option == $rows['media_type']) ? ' SELECTED' : '';
            echo '<option'.$selected.'>'.$option.'</option>' . "\n";
        }
        ?>
    </select>

  4. Are you sure that's the whole code? Seems to me there's some conditional statement we can't see. Are there statements in header.php?

     

    You're closing a statement when a statement hasn't even been called.

  5. $month='Feb';
    $query = "SELECT date FROM table WHERE date LIKE '$month%'";
    $result = mysql_query($query) or die(mysql_error());
    $events = array();
    while($row = mysql_fetch_array($result)) {
       $events[] = substr($row['date'], 3);
    }
    echo implode(',', $events);

     

     

  6. Like if statements to check whether or not the "message ID" exists and belongs to that user?

     

    <form method="post">
    box 1 <input type="checkbox" name="box[]" value="1"><br />
    box 2 <input type="checkbox" name="box[]" value="2"><br />
    box 3 <input type="checkbox" name="box[]" value="3"><br />
    <input type="submit" name="submit" value="View Checked Boxes">
    </form>
    <?php
    if(isset($_POST['submit'])){
    $box = $_POST['box']; // this will be an array
    
    if(count($box) > 0){
    	foreach($box AS $id){
    		$sql = "SELECT * FROM `messages` WHERE `id`='".mysql_real_escape_string($id)."'";
    		$res = mysql_query($sql) or die(mysql_error());
    		if(mysql_num_rows($res) > 0){
    			// msg exists
    			$row = mysql_fetch_assoc($res);
    			if($row['uid'] == $_SESSION['uid']){
    				// msg belongs to logged in user
    				$sql2 = "DELETE FROM `messages` WHERE `id`='".mysql_real_escape_string($id)."'";
    				$res2 = mysql_query($sql2) or die(mysql_error());
    				// msg deleted
    			}else {
    				// msg doesn't below to user, nothing is deleted
    				// you can put your error msgs in here if you want
    			}
    		}else {
    			// msg doesn't exist, nothing is deleted
    			// you can put your error msgs in here if you want
    		}
    	}
    }
    }
    ?>

×
×
  • 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.