SELECT staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM staff, event WHERE staff.emp_no = event.emp_no AND event.emp_no =201 AND event.event_date = "27-01-2008" AND timeStart = "1020"
$sql = 'staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM staff, event WHERE staff.emp_no = event.emp_no AND event.emp_no = "$check_array" AND event.event_date = "$e_date" AND timeStart = "$s_time"';
$var = 'hi'; echo "Var = $var"; // Var = hi echo 'Var = $var'; // Var = $var
<html> <head> <title>Search - Online Diary System</title> </head> <body bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC"> <p> </p> <p align="center"><img src="images/logo.GIF" width="543" height="72"></p> <center> <table width="75%" border="0"> <tr> <td> <form name="searchf1" method="post" action="meet_list.php"> <div align="center"> <input type="submit" name="search1" value="Back"> </form></td> </tr> </table> </center> <?php $link = mysql_connect('localhost','db', 'database') or die('Could not connect: ' . mysql_error()); // echo 'Connected successfully'; mysql_select_db("online_diary",$link) or die ('Could not connect ' .mysql_error()); // search db and put results into array FOREACH ($_SESSION['check_array'] as $check_array) { $sql = "staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM staff, event WHERE staff.emp_no = event.emp_no AND event.emp_no = '$check_array' AND event.event_date = '$e_date' AND timeStart = '$s_time'"; $result=mysql_fetch_array($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); echo "$count"; // check $count if ($count==0) { // no records match - go ahead and write record /** * $face2face = new meet; * $face2face->w_meet(); */ header('location:meet.php'); exit(); } if ($count>0) { // print the list into a table ?> <body> <form name="check" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <center> <?php echo "<table border='1'> <tr> <th> Colleague(s) </th> <th>Date (d-m-y)</th> <th>Meeting Time</th> <th>Agenda </th> <th>Status </th>"; // use a while on the array to print the contents of the array while ($e_row = mysql_fetch_array($result)){ // $_SESSION['e_search'] $status = 'busy'; echo "<tr>"; echo "<td>" . $e_row['fName'] . $e_row['lName'] . "</td>"; echo "<td>" . $e_row['event_date'] . "</td>"; echo "<td>" . $e_row['timeStart'] . "</td>"; echo "<td>" . $e_row['Agenda'] . "</td>"; echo "<td>" . $status ."</td>"; } } echo "</table>"; echo "<br />"; echo "<br />"; ?> <table> <tr> <td><input type="submit" name="search_cancel" value="Abandon"></td> <td><input type="submit" name="search_next" value="Auto Fix" /> </td> </tr> </table> </form> </center> <?PHP } if(isset($_POST['search_next'])){ /** * ensure all the selected checkboxes pass their ids to a new array * */ //print_r($_POST['dname']); echo "<br />"; echo "<br />"; //foreach ($locations as $key => $value) { $_SESSION['check_array'] = $_POST['dname']; //print_r($_SESSION['check_array']); // where to pass control to???? header('location:meet_fix.php'); echo "<br />"; exit(); }else if (isset ($_POST['search_cancel'])){ // return to my_meeting.php header('location:monthly.php'); echo "<br />"; exit(); } ?> </body> </html>
php Syntax (Toggle Plain Text)
$sql = 'staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM staff, event WHERE staff.emp_no = event.emp_no AND event.emp_no = "$check_array" AND event.event_date = "$e_date" AND timeStart = "$s_time"';
$sql = 'SELECT staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM `staff`, `event` WHERE staff.emp_no = event.emp_no AND event.emp_no = "'.$check_array.'" AND event.event_date = "'.$e_date.'" AND staff.timeStart = "'.$s_time.'"';
$sql = 'SELECT staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM `staff`, `event` WHERE staff.emp_no = event.emp_no AND event.emp_no = "'.$check_array.'" AND event.event_date = "'.$e_date.'" AND event.timeStart = "'.$s_time.'"';
mysql_fetch_array function.mysql_fetch_array function is meant to process the return value from a mysql_query function and return a single row (See http://php.net/mysql_fetch_array).
<?php // Assuming you already opened a connection before this... $sql = "SELECT * FROM someTable"; $result = mysql_query($sql) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_row($result)) { echo "<tr>"; foreach($row as $col) { echo "<td>$col</td>"; } echo "</tr>"; } echo "</table>"; ?>
mysql_fetch_array , mysql_fetch_row and mysql_fetch_assoc functions are siblings. That is; they all fetch a single row from the resource returned by a mysql_query call.mysql_fetch_assoc returns an associative array, using the column names as keys while the mysql_fetch_row function returns a zero-indexed array.mysql_fetch_array returns a combination of both, like if you were to merge the results of the other two.
<?php session_start(); $met = mysql_connect("","",""); if (!$met) { die('Could not connect: ' . mysql_error()); } mysql_select_db("face2face", $met); $e_date = $_SESSION['meet_date']; $s_time = $_SESSION['stime']; echo $e_date; echo $s_time; echo "<br />"; ?> <html> <head> <title>Search - Online Diary System</title> </head> <body bgcolor="#FFFFFF" link="#0000CC" vlink="#0000CC"> <p> </p> <p align="center"><img src="images/logo.GIF" width="543" height="72"></p> <center> <table width="75%" border="0"> <tr> <td> <form name="searchf1" method="post" action="meet_list.php"> <div align="center"> <input type="submit" name="search1" value="Back"> </form></td> </tr> </table> </center> <body> <form name="check" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <center> <?php echo "<table border='1'> <tr> <th> Colleague(s) </th> <th>Date (d-m-y)</th> <th>Meeting Time</th> <th>Agenda </th> <th>Status </th>"; // search db and put results into array FOREACH ($_SESSION['check_array'] as $check_array) { $sql = 'SELECT staff.emp_no, staff.fName, staff.lName, event.event_date, event.timeStart, event.timeEnd, event.emp_no, event.agenda FROM `staff`, `event` WHERE staff.emp_no = event.emp_no AND event.emp_no = "'.$check_array.'" AND event.event_date = "'.$e_date.'" AND event.timeStart = "'.$s_time.'"'; $result = mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // echo "$count"; // check $count if ($count==0) { // no records match - go ahead and write record header('location:meet.php'); //exit(); } elseif (!$count=0) { while ($e_row = mysql_fetch_array($result)) { $status = 'busy'; // print the list into a table echo "<tr>"; echo "<td>" . $e_row['fName'] . $e_row['lName'] . "</td>"; echo "<td>" . $e_row['event_date'] . "</td>"; echo "<td>" . $e_row['timeStart'] . "</td>"; echo "<td>" . $e_row['agenda'] . "</td>"; echo "<td>" . $status ."</td>"; } } echo "</table>"; echo "<br />"; echo "<br />"; ?> <table> <tr> <td><input type="submit" name="search_cancel" value="Abandon"></td> <td><input type="submit" name="search_next" value="Auto Fix" /> </td> </tr> </table> </form> </center> <?PHP } if(isset($_POST['search_next'])){ //print_r($_POST['dname']); echo "<br />"; echo "<br />"; //foreach ($locations as $key => $value) { //$_SESSION['check_array'] = $_POST['dname']; //print_r($_SESSION['check_array']); // where to pass control to???? header('location:meet_fix.php'); echo "<br />"; exit(); }else if (isset ($_POST['search_cancel'])){ // return to my_meeting.php header('location:monthly.php'); echo "<br />"; exit(); } ?> </body> </html>
} } } echo "</table>"; echo "<br />"; echo "<br />"; ?> <table>
// $_SESSION array to accept 'event' emp_no & timeEnd $endt=array($e_row['emp_no'] => $e_row['timeEnd']);
function max_time() { // find out the highest figure in the array for the timeEnd, then add 100 for the next hour FOREACH($endt as $key => $val) { if ($val == max($endt)) { $_SESSION['my_key'] = $key; } } add_time(); }
$endt variable you are using isn't an array.
<?php // This defnies a varaible in the global scope $arr = array(0 => "value"); function doError() { // At this point, there is no variable named // $arr in the local scope. The $arr variable // defined in the global scope is not visible here. // Which means that this foreach loop is using a // undefined variable, which generates a warning. foreach($arr as $_key => $_value) { // etc... } } function doCorrect() { // This imports the $arr variable into // the current scope. global $arr; // And now we are working with the global variable. foreach($arr as $_key => $_value) { // etc... } } ?>
| DaniWeb Message | |
| Cancel Changes | |