Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. if(!$_POST['submit']){
    echo "<form method=post action=thispage.php>\n";
    echo "Teacher Name: <input type=text name=tname><br>\n";
    echo "Room #: <input type=text name=room><br>\n";
    echo "<input type=submit name=submit value=go>\n";
    echo "</form>\n";
    }else {
    $teacher = $_POST['tname'];
    $room = $_POST['room'];
    
      if($teacher && $room){
      //do this
      }else {
      //not supplied
      }
    }
    

  2. Why not use a dropdown? Lol. It looks fine to me.

     

    $array = array('edit','delete','change');
    
    if(!$_GET['action'] || !in_array($_GET['action'],$array)){
    echo "<form name=\"switch\" method=\"get\" action=\"switch.php\">\n";
    echo "Option: <select name=\"action\">\n";
        foreach($array AS $options){
        echo "<option value=\"$options\">".ucfirst($options)."</option>\n";
        }
    echo "</select> <input type=\"submit\" value=\"Switch Away Captain\"></form>\n";
    }else {
    
    switch($_GET['action']){
    case edit: echo "omfg edit"; break;
    case delete: echo "omfg delete"; break;
    case change: echo "omfg change"; break;
    default: echo "omfg wtf";
    }
    
    }
    

  3. $sql = "SELECT * FROM `this` WHERE `that`='grapejuice'";
    $res = mysql_query($sql) or die(mysql_error());
    
    while($row = mysql_fetch_assoc($res)){
    $first = $row['first'];
    $last = $row['last'];
    $dname = $row['displayname'];
    $picurl = $row['pictureurl'];
    echo "Like hello your name is $first $last, your display name is $dname and your picurl is $picurl, get used to it!\n";
    }
    

     

    Might I add if you're going to use the $i < $num, make sure the less than sign has the inequality of less than or equal to. Because 1 < 3 will produce results 1 and 2.

  4. <?php
    if(!$_POST[submit]){
    echo "<form name=\"this\" action=\"index.php\" method=\"post\">place: <input type=\"text\" name=\"place\">\n";
    echo "<input type=\"submit\" value=\"GO GO GO\" name=\"submit\"></form>\n";
    }else {
    $place = $_POST['place'];
    
    if($place){
    	$sql = "SELECT * FROM `tbl` WHERE `place` LIKE '%$place%'";
    	$res = mysql_query($sql) or die(mysql_error());
    		if(mysql_num_rows($res) == 0){
    		echo "no results\n";
    		}else {
    			while($row = mysql_fetch_assoc($res)){
    			echo "place name: $row[place] | some other field: $row[field1]<br>\n";
    			}
    		}
    }else {
    echo "omg no place\n";
    }
    }
    ?>
    

     

    modify it to your extent

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