By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,377 Members | 3,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,377 IT Pros & Developers. It's quick & easy.

assign many attribute to one function

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


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include("dbconn.php");
  3. $dateday = $_POST['dateday'];
  4. $datemonth = $_POST['datemonth'];
  5. $dateyear = $_POST['dateyear'];
  6.  
  7.  
  8. $sql= "SELECT * FROM staffactivity WHERE dateday = '$dateday' AND datemonth = '$datemonth' AND dateyear = '$dateyear'";
  9. $query = mysql_query($sql) or die ("Error: " . mysql_error());
  10. $row = mysql_num_rows($query);
  11.  
  12. if($row == 0){
  13. echo "No record found";
  14. }
  15. else{
  16. $r = mysql_fetch_assoc($query);
  17. //$studentid= $r['studentid'];
  18. //$studentnumber= $r['studentnumber'];
  19. //$studentname= $r['studentname'];
  20. //$studentpassword= $r['studentpassword'];
  21. ?>
  22.  
  23. <html>
  24. <body>
  25. <form name="form4" method="post" action="process0.php">
  26. <table border="2" width="100" height="100">
  27. <?php
  28.     $sqlGet= "SELECT * FROM staffactivity  WHERE dateday = '$dateday' AND datemonth = '$datemonth' AND dateyear = '$dateyear'";
  29.     $queryGet = mysql_query($sqlGet) or die("Error: " . mysql_error());
  30.     while($rGet = mysql_fetch_assoc($queryGet))
  31.     {
  32.         //echo "<table border='0'>";
  33.         echo "<tr>";
  34.         echo "<td class='fonttable'>".$rGet['dateday'];
  35.         echo "&nbsp;&nbsp;";
  36.         echo $rGet['datemonth'];
  37.         echo "&nbsp;&nbsp;";
  38.         echo $rGet['dateyear']."</td>";
  39.         echo "<td class='fonttable'>".$rGet['task2']."</td>";
  40.         echo "<td class='fonttable'>".$rGet['note2']."</td>";
  41.         echo "</tr>";
  42.     }
  43. ?>
  44. </table>
  45. <input type="submit" name="Update" value="Update">
  46. <input type="submit" name="Delete" value="Delete">
  47. </form>
  48.  
  49. </body>
  50. </html>
  51. <?php
  52. }
  53. mysql_close($dbconn);
  54. ?>

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...
Feb 13 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,366
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.
Feb 13 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.