Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I have 2 equal arrays. 1 has ID values for the database table and the other has the corresponding update data. The array lengths keep changing as new data at different times is updated. However they will always be equal. How do I go about updating my mysql database table by extracting each ID from the array and then use that to commit the necessary update with the corresponding data in another array. Below is what I have tried but It only updates the last element and nothing else: $arraysIDs; //array containing database table IDs $arrayVALUES; // array containing update data for ($x = 0; $x < count($arraysIDs); $x++){ $element = "UPDATE TableToUpdate SET newUpdateData = '$arrayVALUES[$x]' WHERE ID = $arraysIDs[$x])"; } Thank you for your help.
  2. Hello guys. I’m having trouble understanding JOIN and GROUP. I have two tables that I want to merge into one but when I try it, the result is not what is expected and I don’t know where I’m wrong. I want to merge Table A and B to get Table C as shown below: Table A Client Name Username Amount Deposited John Doe joh@doe.com 2500 Julian Cram jul@cram.com 2000 Peter Stalone pet@sta.com 1200 Creig Davies creg@davies.com 3000 Table B Client Name Username Invoice Amount John Doe joh@doe.com 1000 Julian Cram jul@cram.com 500 Peter Stalone pet@sta.com 4500 Creig Davies creg@davies.com 1500 Table C Client Name Username Invoice Amount Amount Deposited John Doe joh@doe.com 1000 2500 Julian Cram jul@cram.com 500 2000 Peter Stalone pet@sta.com 4500 1200 Creig Davies creg@davies.com 1500 3000 echo "<table width='100%' class='table table-striped tbl'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Client's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Amount Deposited</font></th> </tr>"; $stmt = $pdo->query(" SELECT d.firstname, d.surname, d.username, SUM(d.amt_deposited) AS sum_deposited FROM ca_my_payments d GROUP BY d.username "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ echo "<tr><td>"; $client = ucwords($row['firstname'] . " " .$row['surname']); echo $client; echo "</td><td>"; echo $row['username']; echo "</td><td>"; echo $row['sum_deposited']; echo "</tr></td>"; } echo "</table>"; echo "<br><br>"; echo "<table width='100%' class='table table-striped tbl'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Client's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Invoice</font></th> </tr>"; $stmt = $pdo->query(" SELECT p.payee, p.username, SUM(p.total_payment) AS total_invoice FROM ca_processed p GROUP BY p.username "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<tr><td>"; echo $row['payee']; echo "</td><td>"; echo $row['username']; echo "</td><td>"; echo number_format($row['total_invoice'],2); echo "</tr></td>"; } echo "</table>"; echo "<br><br>"; echo "<table width='100%' class='table table-striped tbl'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Client's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Invoice</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Amount Deposited</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Current Balance</font></th> </tr>"; $stmt = $pdo->query(" SELECT a.payee, a.username, b.username, SUM(a.total_payment) AS total_invoice, SUM(b.amt_deposited) AS sum_deposited FROM ca_processed a LEFT JOIN ca_my_payments b ON a.username = b.username GROUP BY a.username "); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<tr><td>"; echo $row['payee']; echo "</td><td>"; echo $row['username']; echo "</td><td>"; echo number_format($row['total_invoice'],2); echo "</td><td>"; echo number_format($row['sum_deposited'],2); echo "</tr></td>"; } echo "</table>";
  3. I have data on a table1 on one server I need copied onto a table1 on another server that is freshly truncated. I am not getting any error output in the logs or on the screen, but no data ever appears on the second server. mysql replication is banned and no access to cli for mysqldump (this code will be hit numerous times during the day) $pdo = new PDO( 'mysql:host=' . DB_HOST_R2D2 . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); //yoda pdo settings $pdoyd = new PDO( 'mysql:host=' . DB_HOST_YODA . ';dbname=' . DB_DATABASE_DNS, DB_USER_DNS, DB_PASSWORD ); $pdoyd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdoyd->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //records table column names $recordstbl = array('id', 'name', 'type', 'content', 'ttl', 'prio', 'change_date', 'disabled', 'ordername', 'auth'); //domain table column names $domainstbl = array('id', 'name', 'master', 'last_check', 'type', 'notified_serial', 'account'); //crypto table column names $cryptotbl = array('id', 'domain_id', 'flags', 'active', 'content'); $tblnames = array('cryptokeys', 'domains', 'records'); //loop through yoda and trunacate all 3 tables foreach($tblnames as $tbl){ $sql = 'truncate '.$tbl; $statementyd = $pdoyd->prepare($sql); $useryd = $statementyd->execute(); var_dump($statementyd); echo '<br>'; } //crazy triple loop to get sql query correct foreach($tblnames as $tbl){ if($tblnames == 'cryptokeys'){ foreach($cryptotbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } if($tblnames == 'domains'){ foreach($domainstbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } if($tblnames == 'records'){ foreach($recordstbl as $column){ foreach ($column as $pdcolumn){ $pdcolumn = ':'.$pdcolumn; } $insert_stmt = $pdoyd->prepare("INSERT INTO ".$tbl." (".$column.") VALUES (".$pdcolumn." ON DUPLICATE KEY IGNORE"); $select_results = $pdo->query("SELECT * FROM ".$tbl); while ($row = $select_results->fetch(PDO::FETCH_ASSOC)) { $insert_stmt->execute($row); } } } } logs (source) db1: mysql> select * from mysql.general_log; +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | event_time | user_host | thread_id | server_id | command_type | argument | +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and name='nyctelecomm.com' and domain_id=6 | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='PRESIGNED' | | 2016-01-17 00:34:10 | root[root] @ localhost [127.0.0.1] | 7 | 1 | Query | select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name='nyctelecomm.com' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='NSEC3PARAM' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select min(ordername) from records where ordername > '' and domain_id=6 and disabled=0 and ordername is not null | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select ordername, name from records where ordername <= '' and domain_id=6 and disabled=0 and ordername is not null order by 1 desc limit 1 | | 2016-01-17 00:34:11 | root[root] @ localhost [127.0.0.1] | 6 | 1 | Query | select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='nyctelecomm.com' and domainmetadata.kind='SOA-EDIT' | | 2016-01-17 00:34:11 | [powerdns] @ [108.61.175.20] | 420 | 1 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Prepare | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Execute | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Close stmt | | | 2016-01-17 00:34:12 | powerdns[powerdns] @ [108.61.175.20] | 420 | 1 | Quit | | | 2016-01-17 00:34:13 | [powerdns] @ [108.61.175.20] | 421 | 1 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:13 | powerdns[powerdns] @ [108.61.175.20] | 421 | 1 | Quit | | | 2016-01-17 00:34:19 | root[root] @ localhost [] | 411 | 1 | Query | select * from mysql.general_log | +---------------------+---------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+ 17 rows in set (0.00 sec) logs (target) db2: mysql> select * from mysql.general_log; +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ | event_time | user_host | thread_id | server_id | command_type | argument | +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='www.zippy-mail.com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='zippy-mail.com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='com' | | 2016-01-17 00:34:15 | powerdns[powerdns] @ localhost [127.0.0.1] | 9 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='' | | 2016-01-17 00:34:23 | powerdns[powerdns] @ localhost [127.0.0.1] | 8 | 2 | Query | SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM records WHERE disabled=0 and type='SOA' and name='nyctelecomm.com' | | 2016-01-17 00:34:25 | [powerdns] @ [108.61.175.20] | 246 | 2 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Prepare | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Execute | SELECT domain_id, name, type FROM records | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Close stmt | | | 2016-01-17 00:34:25 | powerdns[powerdns] @ [108.61.175.20] | 246 | 2 | Quit | | | 2016-01-17 00:34:26 | [powerdns] @ [108.61.175.20] | 247 | 2 | Connect | powerdns@108.61.175.20 on powerdns | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate cryptokeys | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate cryptokeys | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate domains | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate domains | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Prepare | truncate records | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Execute | truncate records | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Close stmt | | | 2016-01-17 00:34:26 | powerdns[powerdns] @ [108.61.175.20] | 247 | 2 | Quit | | | 2016-01-17 00:34:41 | root[root] @ localhost [] | 237 | 2 | Query | select id, domain_id, name, type, content from records | | 2016-01-17 00:34:49 | root[root] @ localhost [] | 237 | 2 | Query | select * from mysql.general_log | +---------------------+--------------------------------------------+-----------+-----------+--------------+--------------------------------------------------------------------------------------------------------------------------------------+ 23 rows in set (0.00 sec)
  4. Hi guys, I have this script I am running, http://pastebin.com/NR1A03hY, works perfectly and does everything I need it to do. The only thing is the redirect at the bottom of the script does not work if line 40 is true. I think I have a problem with my foreach loop and the if statements in-between. Please can someone check, I have no idea on this one! Edit: in the pastebin the redirect is striked out as i was problem solving it. Of course i would not strike it out once its back working! Thanks
  5. Hello... I want to calculate the value from 2 difference files using simplexml load file... But the result not as expected.. My output should be 7 and 5 where 10 - 7 and 8 - 3. My first xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>10</value> </item> <item> <q_id>4232002</q_id> <value>8</value> </item> </items> My second xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>7</value> </item> <item> <q_id>4232002</q_id> <value>3</value> </item> </items> My scripts. <?php $xml = simplexml_load_file('q1.xml'); $xml2 = simplexml_load_file('q2.xml'); foreach ($xml -> item as $item) { $value1 = $item->value; echo $item->q_id.'<br />'; //echo $value1.'<br />'; foreach ($xml2 -> item as $item2) { $value2 = $item2->value; $total = $value1 - $value2; echo $total.'<br />'; } } ?> The result should be 7 and 5 where 10 - 7 and 8 - 3 but there is another unknows value which is 3 and 1... How to solve the issue.. Thank for any help..
  6. Hi I am a newbie with PHP. I created a contact form following a tutorial online and have uploaded the index.html and contact-form.php form to a server with php enabled. I am getting an error message Warning! Please fill all the fields. ”; } else { mail($to,$subject,$msg,”From:”.$email); echo “ I am wondering if anyone can advise me? The PHP: <?php $to="calming1@yahoo.co.uk";/*Your Email*/ $subject="Message from the website"; $date=date("l, F jS, Y"); $time=date("h:i A"); $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['message']; $msg=" Message sent from website form on date $date, hour: $time.\n Name: $name\n Email: $email\n Message: $message\n "; if($email=="") { echo "<div class='alert alert-danger'> <a class='close' data-dismiss='alert'>×</a> <strong>Warning!</strong> Please fill all the fields. </div>"; } else { mail($to,$subject,$msg,"From:".$email); echo "<div class='alert alert-success'> <a class='close' data-dismiss='alert'>×</a> <strong>Thank you for your message!</strong> </div>"; } ?> HTML <form id="contact" class="form-inline" action="contact-form.php" method="post" accept-charset="utf-8"> <div class="form-group pull-left"> <label class="sr-only" for="name">Name</label> <input type="text" class="form-control" id="name" placeholder="Name" name="name"> </div> <div class="form-group pull-right"> <label class="sr-only" for="email">Email</label> <input type="email" class="form-control" id="email" placeholder="Email" name="email"> </div> <textarea class="form-control pull-left" rows="8" placeholder="Message" name="message"></textarea> <button type="submit" class="btn pull-right">Send email</button> </form>
  7. Hello all. I dont know how to go about this. I have a table (Transactions) that contains transactions of users. Another table (Confirmed) contains details of every confirmed user. I want to do a select statement that will display all the confirmed user with only the last of their transaction. But so far all it does is replicate the user and their date of transaction and that is not what i want. My intention is to get something like: Firstname Surname Date Registered Last Transaction andrews john 12-12-2014 10-10-2015 doe andy 12-12-2010 12-12-2014 But i'm getting something like: Firstname Surname Date Registered Last Transaction andrews john 12-12-2014 10-10-2015 andrews john 12-12-2014 10-11-2015 doe andy 12-12-2010 12-12-2014 doe andy 12-12-2010 01-12-2014 doe andy 12-12-2010 12-12-2013 Thanks $stm=$pdo->query("select * from confirmed left join transaction on confirmed.user_id = transaction.user_id where confirmed.status='confirmed' order by date"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['firstname']; echo $row['surname']; echo $row['regDate']; echo $row['lastTrans']; }
  8. Hello... I have problem concerning in php fwrite function... Each time i run the codes, it will add blank spaces/tab for every loop... My screenshot My Codes //create a file $fileCreate = fopen("test.txt","w") or die("Unable to open file!"); foreach ($in_xml_river->item as $item) { $pushData = $item->station_id."::LEVEL\r\n"; fwrite($fileCreate, $pushData); fclose($fileCreate) } Please help me out to solve this issue...thanks
  9. I am using a barebones script listed as a members area but all it does is give me login and secure pages using the auth.php (code listed below) since I got the script I have added a new column 'Rank' to the database table 'members' with this rank there are 4 ranks: Guest Blocked/Banned Helpers Administration The new page I am creating I want it to use this rank system I added, ranks 3 and 4 get access, rank 2 I want to redirect to my 403 Access Forbidden located at my main site 'bullwebhost.co.uk/error.php?cmd=403' , rank 1 gets a message shown saying 'Welcome Guest print '$_SERVER["REMOTE_ADDR"]; , You have tried accessing a Restricted Area Your IP print '$_SERVER["REMOTE_ADDR"]; has been logged and Webmaster Informed (if possible via phpmail as i cant use smtp) of your accessing this area. Now For the code auth.php //Start session session_start(); //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } Database Structure CREATE TABLE IF NOT EXISTS `members` ( `member_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `Rank` int(11) NOT NULL DEFAULT '1', `firstname` varchar(100) DEFAULT NULL, `lastname` varchar(100) DEFAULT NULL, `login` varchar(100) NOT NULL DEFAULT '', `passwd` varchar(32) NOT NULL DEFAULT '', PRIMARY KEY (`member_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; config.php <?php define('DB_HOST', '****'); define('DB_USER', '****'); define('DB_PASSWORD', '****'); define('DB_DATABASE', '***'); ?> Restricted File require_once('auth.php'); include 'config.php'; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'SELECT Rank FROM members WHERE Rank="3" or Rank="4"'; mysql_select_db(DB_DATABASE); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { print ' <!DOCTYPE html PUBLIC "-//W3C//DTD(I have code for this part) XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Profile</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>My Profile </h1> <a href="member-index.php">Home</a> | <a href="logout.php">Logout</a> <p>This is another secure page. </p> </body> </html>'; } Attempts Okay I did a more detailed (I think) search and came across something but it didn't work my edited code is below $sql = mysql_query("SELECT * FROM members WHERE Rank ='3 or 4' AND member_id ='".$_SESSION['SESS_MEMBER_ID']); Code Removed else { (redirect to error document) mysql_close($conn); } That is all I changed in the Restricted File code above. I still am not getting errors printed I have php errors in htaccess and using the trigger but still blank white screen Trying to get my question across (not very easy for me), I am trying to make a page (not giving name of file) that using the auth and config files to do a check for the users rank is either 3 or 4 user gets access, 1 print message 2 redirect to 403 document (easiest way possible) so that even if someone tries to bypass any security in place they still need to be rank 3 or 4 to even see the page contents. Also possible long shot but what would be the best way to block IP addresses would php and mysql/mysqli (don't know PDO, willing to learn mysqli) or would it be better to use .htaccess for the reason being I wanting to block Loads of IPS but want adding them to be easy and also using my new pages was looking at building forms to add entries, remove entries Viewing the list, (I have code for this part). What I asking is would I be better of using php and mysql/i or .htaccess because some of the ips are wildcard ips to be banned and redirected to my error document. Kind regards Harry Smith
  10. Hi guys, I am trying to create a simple PHP script to send a new password to my users using the script below. I believe it was working however seemed to stop after a few tests. Any ideas why? Thanks $rand_password_md5 = md5($rand_password); $sql = "UPDATE Users SET password = '$rand_password_md5' WHERE username = '$code' AND Base = '$base'"; $result = mysqli_query($cxn,$sql) or die ("Can not change your password in our database."); // the email reply // use wordwrap() if lines are longer than 70 characters $msg = wordwrap($msg,70); // send email $to = $row['Femail']; $subject = "website.com | Password reset requested."; $txt = "Hi ".$row['Ffname'].", Please go back to www.website.com and login with your username ".$row['username']." and new password ".$rand_password.". You can then change your password by going to 'Settings' > 'Personal Settings'.!"; $headers = "From: noreply@website.com" . "\r\n" . "CC: info@website.com"; mail($to,$subject,$txt,$headers);
  11. In the following pages I'm trying to validate if a user is signed in or not. If the user is signed in I would like to see 'Log Out' printed to the screen(I'll do more with that later). If the user is not signed in I would like to see a login form at the top right of the screen. As it stands I'm only seeing 'Log Out' on the screen, I can't get the form to show up anymore. I thought it might be because the session variable was still hanging around but I restarted my computer to make absolutely sure but I'm still just getting 'Log Out'. At the moment I need this program to work as is as much as possible. If you see an entirely different approach that you would use that's fine but I don't currently have the time to go changing a lot, I need to get this going kinda quick. Thanks. records-board.php <?php require_once('includes/init.php'); if(!isset($_SESSION)) { init_session(); } ?> <html> <head> <Title>Pop Report</title> <link rel="stylesheet" type="text/css" href="styles/popreport2.css"> <h1>Pop Report</h1> </head> <body> <?php if(isset($_POST['nameinput']) && isset($_POST['passinput'])) { $nameinput = $_POST['nameinput']; $passinput = $_POST['passinput']; User::sign_in($nameinput, $passinput); } if(!isset($_SESSION['user'])) { print_form(); } else { echo "Log Out "; echo $_SESSION['user']->name; // this line was just trouble shooting, it told me nothing! } ?> user.php <?php if(!isset($_SESSION)) { init_session(); } class User { public $name; public function __construct($username, $password) { $connection = get_db_connection(); $query = $connection->query("SELECT * FROM users WHERE username='$username' AND password='$password'"); if(!$query) { echo "Invalid username or password"; } else { $result = $query->fetch(PDO::FETCH_ASSOC); if(!$result['username'] == $username || !$result['password'] == $password) { echo "Invalid username or password"; } else { $this->name = $result['username']; } } } public static function sign_in($username, $password) { $_SESSION['user'] = new User($username, $password); } } ?> <?php function print_form() { echo "<form id='loginform' name='loginform' action='records-board.php' method='post'>"; echo "Username: <input type='text' name='nameinput'>"; echo "Password: <input type='text' name='passinput'><br />"; echo "<input type='submit' value='Sign In'>"; echo "</form>"; } ?>
  12. Background I am relatively proficient in HTML/CSS and the Joomla! Content Management System. Until yesterday I am ashamed to say I had tried my best to avoid learning any PHP code. That being said, I am currently going through the introductory course on PHP with Codecademy in the hope that that will shed some light on my next step... What I am trying to do... Integrate an online classroom on our website for our teachers and students to use on a one to one basis (a single teacher to be paired up with a single student). I am using classroom software from a company called Groupworld (here is their API documentation: https://www.groupworld.net/api.shtml). Our Groupworld subscription allows for up to 10 simultaneous users, so for us that would be 5 teachers and 5 students at any one time. Their instructions are to configure the classroom as you want to display it and then go into the source code and simply copy the HTML onto your own hosting server. We have copied the classroom code to five different folders (one classroom per teacher) each under a master folder called classrooms. So the folder structure looks like this... classrooms ----room-1 --------index.html ----room-2 --------index.html ----room-3 --------index.html etc... Here is the classroom sourcecode for each of those pages... <!DOCTYPE html> <html> <head> <title>Groupworld HTML5 Conference Room</title> <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/bkpfcahabbgcjikdomdcamdlcipolkcf"> <link rel="stylesheet" href="//www.groupworld.net/style.css" type="text/css"> <link rel="stylesheet" type="text/css" href="//www.groupworld.net/js/dialog.css"> <script type="text/javascript" src="//www.groupworld.net/js/aes-enc.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/aes-dec.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/aes-test.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/sha1.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/newbase64.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/dialog.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/tunnel.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/gsm610.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/groupworld.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/deskshare.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/polls.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/jscolor/jscolor.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/new_conference.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/new_whiteboard.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/new_videostrip.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/chat.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/jspdf.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/jspdf.plugin.addimage.min.js"></script> <script type="text/javascript" src="//www.groupworld.net/js/FileSaver.min.js"></script> <script type="text/javascript"> function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(';'); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf('=')); y=ARRcookies[i].substr(ARRcookies[i].indexOf('=')+1); x=x.replace(/^\s+|\\s+$/g,''); if (x==c_name) { return unescape(y); } } } function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? '' : '; expires='+exdate.toUTCString()); document.cookie=c_name + '=' + c_value + ';path=/'; } var agt=navigator.userAgent.toLowerCase(); var is_ipad = (agt.indexOf('ipad') != -1); var is_android = ((agt.indexOf('ventana') != -1) || (agt.indexOf('android') != -1)); var app_url = 'groupworld://www.groupworld.net?instance=room_1&object=new_conference&installation_id=1630'; if (is_ipad || is_android) { var appstore_url = 'http://itunes.apple.com/us/app/groupworld/id474262955?ls=1&mt=8'; if (is_android) { appstore_url = 'https://market.android.com/details?id=com.grouptechnologies.groupworld'; } var has_app = getCookie('has_groupworld_app'); var msg = 'In order to connect to Groupworld you must use'; if (is_android) { msg = 'For the best experience, we recommend that you use'; } if (has_app) { if (confirm(msg+' the Groupworld App. Launch the Groupworld App Now?')) { window.location = app_url; } } else { if (confirm(msg+' the Groupworld App. Install the Groupworld App Now?')) { setCookie('has_groupworld_app', 'true', 20000); window.location = appstore_url; } } } if ('1630' == '') { document.write("inst_id parameter missing. Please check the url."); } if ('1630' == '1049') { window.location = 'https://www.groupworld.net/mp/parse.cgi?filename=compmathtutor_js.html&instance=room_1&width=100%&height=100%&show_room_name=&show_timer=true&inst_id=1630&username=&password='; } function start() { // Optional username and password. If not specified here, a popup dialog // box will appear. var username = ''; var password = ''; // The Groupworld server to connect to. You can optionally specify the // port number (using the format "server:port"). var base = 'www.groupworld.net:9175:1630'; // The object to load and instance name. To create a different "session", // just copy the html page and change the instance name. var object = 'new_conference:room_1'; // Flags: not currently used. var flags = 0; groupworld.startup(username, password, base, object, flags); } </script> <style> /* Bug in Chrome: if you draw on the whiteboard and move off the top, Chrome will select a bunch of stuff which will then be dragged the next time you click on the whiteboard. To fix, we just turn off selection for all elements. */ * { -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; -o-user-select: none; } /* Setting webkit-user-select to none screws up inputs on Safari. */ input { -webkit-user-select: auto; } /* For IE we need to disable touch behaviours (pan/zoom) on the canvas elements, so that the events are sent to the application instead. */ canvas { touch-action: none; } body { padding: 0; margin: 0; } p { padding-left: 8px; } </style> </head> <body onLoad="REDIPS.dialog.init(); start();"> <script src="//www.groupworld.net/js/strings.js"></script> <script type="text/javascript"> var start_time; function timer() { if (null == start_time) { return; } var cur_time = new Date(); var time_diff = (cur_time.getTime() - start_time.getTime())/1000; var hours = parseInt(time_diff/3600); var mins = parseInt((time_diff-hours*3600)/60); var secs = parseInt(time_diff - hours*3600 - mins*60); var t = document.getElementById("t"); t.innerHTML = hours+":"+mins+":"+secs; setTimeout("timer();", 1000); } </script> <h1>Time: <span id="t">0:0:0</span><script type="text/javascript">start_time = new Date(); setTimeout("timer();", 1000);</script></h1> <table border=0 cellspacing=0 width="100%" height="100%"> <tr><td> <script type="text/javascript"> // Generate the actual Groupworld object. Parameters: width and height of // object groupworld.htmlgen('100%','100%'); </script> </td></tr> </table> </body> </html> The problem...s As it stands ANYONE off the street can enter ANY of the rooms so long as they have the link to that room. Not good! So as an example... if a teacher is teaching a student in "room-1" and a previous student decides to log-in using the same "room-1" link then we have a problem. We need our classroom url to be uniquely generated each time a "teacher" logs in. Now the url for each classroom is generated as follows: https://www.groupworld.net/mp/parse.cgi?filename=ncjs&show_timer=true&hide_playback=true&hide_help=true&inst_id=1630&instance=room-1&width=100%&height=100% The interesting part is that the &instance=room_1 can be changed to any string and the Groupworld software will then create a new classroom on the fly! The problem now is that I do not want my teachers to have to manually change the &instance="xxxx" and then somehow copy the new url, this will not work. My closest guess as to how we can do this is as follows, apologies if this is as clear as mud, I simply do not know where to begin coding this! ---- When you enter the classroom called room-1... 1 - A popup appears that asks for a username (this is already coded into the system) 2 - If you enter the correct teacher name then... (this is already coded into the system) 2,a - another popup appears to name the class as $className 2,b - else you cant access the class (this is already coded into the system) 3 – In the class name you name the class e.g. "bobs-class" (no breaking spaces allowed) 4 – Now we want the string "bobs-class" to be added to the Instance ID so that the url instance is now 5 – &instance=room-1-bobs-class 6 – Once the class name is entered then another popup appears that says "share this link" from which the teacher can copy the private link to give to the student. ---- I can't think of another way to do this, I was assured by the people at Groupworld that this would be easily done and only require a few lines of code... however I am almost ready to have a nervouse breakdown! Thanks in advance for your kind help (or just reading thus far!), I'm heading back to learn more PHP... Jethro.
  13. First of all I would like to say thank you because I had be a member. However, as for my Affairs. I bought a CMS that I use for funny pictures / videos. I would like to get mobile advertising. But it is such that those who have made the cms, is coming with an update in a few months with mobile advertising. And I get more and more visitors. is there a kind soul can take a look at my page http://www.funnie.dk and see if they can help me. Best regards Matt
  14. Hi all, I am trying to calculate the straight line distance between two points by using their co-ordinates on each row from a mysql db that satisfies the query. It works fine, except the last for loop below calculates $lat[$x+1],$long[$x+1] to have blank fields as they no longer exist in the database therefore i have invalid distances calculated. My goal of this script is to find all the routes a particular day a flight attendant is working, by searching my db, rosters, then gathering the departure and arrival airport from this table. With these airports, I then extract their co-ordinates from the table, airports, and use the function below to calculate the distance. Hope it makes sense what I am trying to do below!! <?php function distance($lat1, $lon1, $lat2, $lon2, $unit) { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; $unit = strtoupper($unit); if ($unit == "K") { return ($miles * 1.609344); } else if ($unit == "N") { return ($miles * 0.8684); } else { return $miles; } } $today = '2016-01-04'; $sql = "SELECT * FROM rosters WHERE Code = 'TESTUSER' AND SectorDate = '$today' ORDER BY BeginTime ASC"; $result = mysqli_query($cxn,$sql) or die ("Cant get rosters distance."); $dep = array(); $arr = array(); $lat = array(); $long = array(); while($row=mysqli_fetch_array($result)) { $dep[] = $row['Dep']; $arr[] = $row['Arr']; } echo 'Number of flights: '.count($dep).'<br />'; foreach($dep as $key => $value) { $sql = "SELECT * FROM airports WHERE IATA = '$value'"; $result = mysqli_query($cxn,$sql) or die ("Cant get airport coordinates."); while($row=mysqli_fetch_array($result)) { $lat[] = $row['Latitude']; $long[] = $row['Longitude']; } } $max = count($dep); for ($x = 0; $x <= $max; $x++) { echo $dep[$x].' - '.$arr[$x].'<br />'; echo floor(distance($lat[$x],$long[$x],$lat[$x+1],$long[$x+1], "N")) . "nm<br />"; } ?>
  15. If I have a php file that generates an html form from another php file which file would be the default file that would try to execute if I leave the action field blank in the html form? The php file that the form sits in or the php file that it's called from? Thanks.
  16. Hello I have wordpress tube template, i want to remove video player in single page and want to use normal post insted, could anyone help me for that. my singlepage php code is <?php get_header(); ?> <div class="wrap grid rStatic player"> <div class="mainw"> <?php setPostViews(get_the_ID()); ?> <?php while ( have_posts() ) : the_post(); ?> <div class="main l200 r300"> <?php $player = get_option('mtn_player'); if ($player == "top") { include (TEMPLATEPATH . '/inc/layout/player2.php'); } elseif ($player == "bottom") { include (TEMPLATEPATH . '/inc/layout/player1.php'); } else { get_template_part( 'inc/layout/player1', get_post_format() ); } if(get_option('mtn_related_title')){ $title = get_option('mtn_related_title'); } else { $title = __('Video Suggestions', 'bestia'); } ?> </div> </div> <?php endwhile; // end of the loop. ?> <div class="main l200" id="suggestions"> <h2><?php echo $title; ?></h2> <?php include (TEMPLATEPATH . '/inc/related-videos.php'); echo '</div></div>'; ?> <div class="right300 rZone"><div class="holder"> <?php if (get_option('mtn_adsright') <> '') { echo stripslashes(get_option('mtn_adsright')); } else { } echo '</div></div>'; get_template_part( 'inc/sidebar/sidebar-video', get_post_format() ); echo '</div></div>'; get_footer(); ?>
  17. Hi I got a column in my database containing profile information in an array form, but I want to select a specific part the gender of the person from the column and count the males and female values My database column contains the value en,ZA,1991-01-30,Male,1 I know I can explode the values like this $str = explode(',', $query); $answ = $str[3]; but I don't know how to implement it for the database to count the amount of values named Male and Female
  18. I am trying to set a column equal to the column in another table where the date matches. I seem to have a problem in my query and I have tried multiple methods. Can someone tell me where the mistake is? $query2 = "UPDATE a SET a.CalDatePrice = b.Close FROM ". $symbol ." b INNER JOIN CleanedCalendar a ON a.BuyDate = b.Date"; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM CLBS b INNER JOIN CleanedCalendar a ON a.BuyDate = b.Dat' at line 3
  19. Hello people, I am writing this post because since last night im getting a really weird problem with a $_POST form. I will not paste the actual form code since the values are generated by a javascript calendar, but I will paste the code where the values are retrieved and the weird problem is found. The $_POST values are properly sent and are correctly viewed in firebug console, with the right names/values. echo $_POST['ordersDateFrom']; if(isset($_POST['ordersDateFrom']) && isset($_POST['ordersDateTo'])){ echo $_POST['ordersDateFrom']; $_SESSION['ordersDateFrom'] = $_POST['ordersDateFrom']; $_SESSION['ordersDateTo'] = $_POST['ordersDateTo']; $results = $mysqli->query("SELECT * FROM orders WHERE (date BETWEEN '{$_POST['ordersDateFrom']}' AND '{$_POST['ordersDateTo']}')"); } else{ echo $_POST['ordersDateFrom']; $today = date("Y-m-d"); $results = $mysqli->query("SELECT * FROM orders WHERE date = '$today'"); } Ok so, the problem is that none of the echo of the $_POST variables are outputted, and the query is always the one with $today so its obvious the variables are not recognized in the If statement, but.....both the $_SESSION variables update with the $_POST values!! This just makes no sense. Any help appreciated.
  20. Hi I have 2 tables I need to update according to the value of the 3rd table field currently I do 2 queries but I'm sure there must be a way to make it 1 query query 1 $sql = "UPDATE Room_users INNER JOIN Users2 u ON u.mxitid = Room_users.mxitid SET Room_users.User = u.Username"; query 2 $sql = "UPDATE Rooms INNER JOIN Users2 u ON u.mxitid = Rooms.mxitid SET Rooms.creator = u.Username"; How can I turn this into 1 query?
  21. hello mate, i need help on creating the json file with data are fetched from mysql database. here will be the result i want to get. { "freebusys":[ { "start":"2012-12-20T16:29:34.000+0000", "end":"2013-02-06T16:44:24.000+0000", "free":true } ], "events":[ { "start":"2013-01-04T03:57:06.000+0000", "end":"2013-02-18T03:57:06.000+0000", "id":2, "title":"A lesson" }, { "start":"2013-01-04T12:43:30.000+0000", "end":"2013-02-18T12:43:30.000+0000", "id":4, "title":"A lesson" } ] } i have a table named "schedules" on my database with the following fields, start, end, id, title, and free, all i need is to do php array "freebusys" and "events" then their values will be fetched from my database. how can i do this. please help. Thank you
  22. I need to integrate my PHP Application to Credit Card and Paypall System. What is the best way of doing this?
  23. I was wondering if anyone could help! I'm pulling my hair out here. Basically I pull some data down from the DB (start & end) which are both datetime columns. What I need it to do is if the start is say 10:00AM and the end is 12:00PM I need it to add the HTML class "y" to 10,10:30, 11, 11:30 & 12. It did work in one instance, then I tested it again on another example and every TD was class "n". Could someone shed some light on what's going wrong here?[/size] -- I would like to point out here my indentation was all perfect but for some reason it's not when I post it lol.[/size] <?php function betweenTime($input, $from, $till) { $fromTime = strtotime($from); $toTime = strtotime($till); $inputTime = strtotime($input); if(($inputTime >= $fromTime && $inputTime <= $toTime)) { return true; } else { return false; } } foreach ($Appts as $APK => $APV) { $StartI = settype(date('i', strtotime($Appts[$APK]['start'])), 'integer'); $EndI = settype(date('i', strtotime($Appts[$APK]['end'])), 'integer'); $Start = date('H:', strtotime($Appts[$APK]['start'])) . ($StartI >= 30 ? '30' : '00') . date(' a', strtotime($Appts[$APK]['start'])); $End = date('H:', strtotime($Appts[$APK]['end'])) . ($EndI >= 30 ? '30' : '00') . date(' a', strtotime($Appts[$APK]['end'])); $Start_ = date('H:i a', strtotime($Appts[$APK]['start'])); $End_ = date('H:i a', strtotime($Appts[$APK]['end'])); echo ' <tr class="participant"> <td class="pname"><div class="pname">James</div></td> <td class="partTableCell' . ($Start === '08:00 am' || $End === '08:00 am' || betweenTime('08:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '08:30 am' || $End === '08:30 am' || betweenTime('08:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:00 am' || $End === '09:00 am' || betweenTime('09:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:30 am' || $End === '09:30 am' || betweenTime('09:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:00 am' || $End === '10:00 am' || betweenTime('10:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:30 am' || $End === '10:30 am' || betweenTime('10:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:00 am' || $End === '11:00 am' || betweenTime('11:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:30 am' || $End === '11:30 am' || betweenTime('11:30 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '12:00 pm' || $End === '12:00 pm' || betweenTime('12:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '12:30 pm' || $End === '12:30 pm' || betweenTime('12:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '01:00 pm' || $End === '01:00 pm' || betweenTime('01:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '01:30 pm' || $End === '01:30 pm' || betweenTime('01:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '02:00 pm' || $End === '02:00 pm' || betweenTime('02:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '02:30 pm' || $End === '02:30 pm' || betweenTime('02:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '03:00 pm' || $End === '03:00 pm' || betweenTime('03:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '03:30 pm' || $End === '03:30 pm' || betweenTime('03:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '04:00 pm' || $End === '04:00 pm' || betweenTime('04:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '04:30 pm' || $End === '04:30 pm' || betweenTime('04:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '05:00 pm' || $End === '05:00 pm' || betweenTime('05:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '05:30 pm' || $End === '05:30 pm' || betweenTime('05:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '06:00 pm' || $End === '06:00 pm' || betweenTime('06:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '06:30 pm' || $End === '06:30 pm' || betweenTime('06:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '07:00 pm' || $End === '07:00 pm' || betweenTime('07:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '07:30 pm' || $End === '07:30 pm' || betweenTime('07:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '08:00 pm' || $End === '08:00 pm' || betweenTime('08:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '08:30 pm' || $End === '08:30 pm' || betweenTime('08:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:00 pm' || $End === '09:00 pm' || betweenTime('09:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '09:30 pm' || $End === '09:30 pm' || betweenTime('09:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:00 pm' || $End === '10:00 pm' || betweenTime('10:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '10:30 pm' || $End === '10:30 pm' || betweenTime('10:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:00 pm' || $End === '11:00 pm' || betweenTime('11:00 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '11:30 pm' || $End === '11:30 pm' || betweenTime('11:30 pm', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell' . ($Start === '12:00 am' || $End === '12:00 am' || betweenTime('12:00 am', $Start_, $End_) ? ' y' : ' n') . ' dsep pok"></td> <td class="partTableCell n dsep pok"><img src="assets/images/delete.png" width="20" height="20" /></td> </tr>'; } ?>
  24. Hi all, I am trying to echo reset($starttimes) to show the first value in my $starttimes array however i it is only showing the second value in the array and skipping the first i want to echo. The statement I have written is inside a while statement however I am not sure if that is where lies the problem. Please take a look at line 29 here: http://pastebin.com/2KQ7kgy9
  25. Hello all, I have a simple PHP page that queries a database and outputs the result set in an HTML table. It works fine. However, the result set is relatively large (2500ish records), so I want to apply a filter. Added an HTML form to the page that lets us filter the criteria. Again, works great. (Used GET method so that the URL could be linked). Here's where my problem comes about. My boss wants the filters to be persistent, both within and between sessions. My first thought was cookies.. so I created a function called Filter() and call it at the top of my PHP document. It reads the cookie and applies the filters into the SQL statement. This works, but is rather kludgy. The problem I have is that when I first access the page, it doesn't seem to see the filters, it displays the full 2500ish record set. However, if I do a CTRL-R to reload the page, it then loads the filters correctly... it's almost like it renders the page before it can read the cookies in the initial pass. Any thoughts on how to improve this, or am I taking a totally wrong approach?
×
×
  • 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.