assign many attribute to one function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ammyra91
    New Member
    • Nov 2011
    • 18

    assign many attribute to one function

    Hi evryone....
    i need you help in this coding....
    i named this page search0.php.... .
    this is my code....


    Code:
    <?php
    include("dbconn.php");
    $dateday = $_POST['dateday'];
    $datemonth = $_POST['datemonth'];
    $dateyear = $_POST['dateyear'];
    
    
    $sql= "SELECT * FROM staffactivity WHERE dateday = '$dateday' AND datemonth = '$datemonth' AND dateyear = '$dateyear'";
    $query = mysql_query($sql) or die ("Error: " . mysql_error());
    $row = mysql_num_rows($query);
    
    if($row == 0){
    echo "No record found";
    }
    else{
    $r = mysql_fetch_assoc($query);
    //$studentid= $r['studentid'];
    //$studentnumber= $r['studentnumber'];
    //$studentname= $r['studentname'];
    //$studentpassword= $r['studentpassword'];
    ?>
    
    <html>
    <body>
    <form name="form4" method="post" action="process0.php">
    <table border="2" width="100" height="100">
    <?php
        $sqlGet= "SELECT * FROM staffactivity  WHERE dateday = '$dateday' AND datemonth = '$datemonth' AND dateyear = '$dateyear'";
    	$queryGet = mysql_query($sqlGet) or die("Error: " . mysql_error());
    	while($rGet = mysql_fetch_assoc($queryGet))
    	{
    		//echo "<table border='0'>";
    		echo "<tr>";
    		echo "<td class='fonttable'>".$rGet['dateday'];
    		echo "&nbsp;&nbsp;";
    		echo $rGet['datemonth'];
    		echo "&nbsp;&nbsp;";
    		echo $rGet['dateyear']."</td>";
    		echo "<td class='fonttable'>".$rGet['task2']."</td>";
    		echo "<td class='fonttable'>".$rGet['note2']."</td>";
    		echo "</tr>";
    	}
    ?>
    </table>
    <input type="submit" name="Update" value="Update">
    <input type="submit" name="Delete" value="Delete">
    </form>
    
    </body>
    </html>
    <?php
    }
    mysql_close($dbconn);
    ?>

    i would like to assign the code at line 3 until line 5 to one attribute or variable....so that, when i want to call the 3 attribute,i just need to call one variable.....is it possible? how is it?
    plz help me anyone...
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I suppose you could combine them into a date but why would you want to do that? It looks like your database is set up with them separated anyways so even if you combine them, you will have to separate them. It's just more work.

    Ideally, it should be a date variable and the database should also be set up as a date field.

    Comment

    Working...