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. Hello, Is there any Distinct function for php? an employee can have more than 1 form an employee have one and only one position in a form 1 form have only one and only one Evaluator 1 form include more than 1 questions (in this topic have 4 questions for each form) in this case, the forms, position,score and evaluator repeat 4 times due to there is 4 questions is a form. How to Distinct in to show only one time for forms, position,score and evaluator? Output: $sql = "SELECT EmpID,EmpName,FormName,Scoring,Position,addedBy FROM [Advisory_BoardDB].[dbo].[masterView] WHERE submissionStatus <> 'Draft' ORDER BY EmpName ASC,FormName ASC"; $stmt = sqlsrv_query($conn, $sql); $data = array(); while (list($eid, $ename, $fname,$score,$pos,$ab) = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) { if (!isset($data[$eid])) { // initialize array for employee $data[$eid] = array('emp' => $ename, 'total' => 0, 'items' => array()); } // accumulate item data $data[$eid]['items'][] = array('form' => $fname,'score' => $score,'position'=>$pos,'addby'=>$ab); $data[$eid]['total'] += $score; } $pcent20 = ceil(count($data)*20/100); //$pcent20 = ceil(count($data)*$finalPercentage); //uasort($data, function($a,$b){return $b['total']-$a['total'];}); uasort($data, function($a, $b) { $emp = $b['total'] - $a['total']; if($emp === 0) { return strcmp($a['emp'], $b['emp']); } return $emp; }); $data = array_slice($data, 0, $pcent20, true); //echo '<pre>',print_r($data, true),'</pre>'; // // Now output the array // echo <<<TABLE <table border="1" id="example"> <thead> <tr> <th>Employee ID</th> <th>Employee Name</th> <th>Grand Total</th> <th>Form</th> <th>Score</th> <th>Position</th> <th>Evaluator</th> </tr> <thead> TABLE; echo "<tbody>"; foreach ($data as $eid => $edata) { // how many items $numItems = count($edata['items']); echo "<tr> <td rowspan='$numItems'>$eid</td> <td rowspan='$numItems'>{$edata['emp']}</td> <td rowspan='$numItems'>{$edata['total']}</td>"; foreach ($edata['items'] as $k => $idata) { if ($k > 0) { echo "<tr class='hover-row'>"; } echo "<td>{$idata['form']}</td><td>{$idata['score']}</td><td>{$idata['position']}</td><td>{$idata['addby']}</td></tr>"; } } echo"</tbody>"; echo "</table>"; ?>
  2. I have the following code for my dropbox; <select name="Symptom" id="Symptomid" onchange="LSC(this.value)"> Its options are; <option value="<?php echo $row_RsSymptom['name']?>"><?php echo $row_RsSymptom['name']?></option> i have the script ; <script> function LSC(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET","LoadSymptomDetails.php?q="+str,true); xmlhttp.send(); } } </script> The LoadSymptomDetails.php has the following lines; $sql1 = mysql_query("SELECT name,description , comments FROM symptoms WHERE symptoms.name ='".$q."'") or die(mysql_error()); The q is not being picked. If i remove the where statement it runs and displays the table. Kindly assist. Azhar
  3. Why I start this tread is, Just I need to create a secure user registration system in php including login functionality with remember me option. In the starting point I needed to create user registration script. Here I have include my code so far, and just I need to know , is my script secure to prevent any possible attack? my password hashing method is correct? If not can any profession guys tell me what are the things that I need to do to make this script more secure? This is my PHP so far from user registration script: <?php // Error Flag $error_msg = ""; if (isset($_POST['username'], $_POST['email'], $_POST['password'])) { // Sanitize and validate the data passed in $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING); $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); $email = filter_var($email, FILTER_VALIDATE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error_msg .= 'The email address you entered is not valid'; } $password = filter_input(INPUT_POST, 'ppassword', FILTER_SANITIZE_STRING); $prep_stmt = "SELECT member_id FROM members WHERE email = ? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt) { $stmt->bind_param('s', $email); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { // A user with this email address already exists $error_msg .= 'A user with this email address already exists.'; } } else { $error_msg .= 'Database error'; } if (empty($error_msg)) { // Create a random salt //$random_salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE)); // Did not work $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); // Create salted password $password = hash('sha512', $password . $random_salt); // Insert the new user into the database if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email, password, salt) VALUES (?, ?, ?, ?)")) { $insert_stmt->bind_param('ssss', $username, $email, $password, $random_salt); // Execute the prepared query. if (!$insert_stmt->execute()) { header('Location: ../error.php?err=Registration failure: INSERT'); exit(); } } // Success massege $success = "The account has been created successfully."; // Store success massege in SESSION: $_SESSION['success'] = $success; // Redirect page to same page $url = BASE_URL.BASE_URI.'index.php?p=admin-dashboard'; // Define the URL. header("Location: $url"); exit(); // Quit the script. } } ?> Any comments would be greatly appreciate. Thank you.
  4. I would like to thank everyone helping me on my previous question. This is the last question i have. Currently i have my program running but i just need to figure out how to use the get function on check boxes and text boxes. Here is the code i am using for the php mysql part of it. <?php $con=mysqli_connect("localhost","username","password","dbase"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="SELECT * from table where id = '".$_GET["id"]."' "; $rs=mysql_query($sql,$conn) or die(mysql_error()); ?> I know this is working by echoing what i needed to display. But i am in a situation where the form is extremely large and i need to display it in the what it is setup currently. Here is an example of the form <form name="standard" method="post" action="submit.php"> <table width="100%" height="1295" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" background="../test report page/images/test form standard large2.jpg" ><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="35" height="122"> </td> <td width="920"> </td> <td width="45"> </td> </tr> <tr> <td height="49"> </td> <td valign="top"><table width="100%" height="44" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25%" valign="bottom"> <input name="water-purveyor" type="text" id="water-purveyor" size="25" height="25" value="<?php echo'.$result["water-purveyor"].' ?>" /></td> <td width="20%" valign="bottom"> <input type="text" name="facility-contact" id="facility-contact" height="25" value="<?php echo'.$result["facility-contact"].' ?>" /></td> <td width="55%" valign="bottom"><input type="text" name="facility-address" id="facility-address" size="50" height="25" value="<?php echo'.$result["facility-address"].' ?>" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td width="28%" height="85" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" rowspan="2"> </td> <td width="15%" height="33"><input type="checkbox" name="v1-na" id="v1-na" value="<?php echo'.$result["v1-na"].' ?>" /></td> <td width="14%"><input type="checkbox" name="v1-good" id="v1-good" value="<?php echo'.$result["v1-good"].' ?>" /></td> <td width="15%"><input type="checkbox" name="v1-poor" id="v1-poor" value="<?php echo'.$result["v1-poor"].' ?>" /></td> <td width="15%"><input type="checkbox" name="v1-fail" id="v1-fail" value="<?php echo'.$result["v1-fail"].' ?>" /></td> </tr> <tr> <td height="35" valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-na" id="v2-na" value="<?php echo'.$result["v2-na"].' ?>" /></td> <td valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-good" id="v2-good" value="<?php echo'.$result["v2-good"].' ?>" /></td> <td valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-poor" id="v2-poor" value="<?php echo'.$result["v2-poor"].' ?>" /></td> <td valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-fail" id="v2-fail" value="<?php echo'.$result["v2-fail"].' ?>" /></td> </tr> </table> </form> Can you tell me if this will work or can you give me some helpful ways to make this work. Again thank you for all your help. E
  5. Hello i am working with woocommerce where i have products displayed on shop page now i want that user can purchase product only once. So i am trying to get the orders of user and trying to redirect to the user to my account page so i am using following code in functions.php <?php $user_id = get_current_user_id(); $current_user= wp_get_current_user(); $customer_email = $current_user->email; $args = array( 'post_type' => 'product', 'posts_per_page' => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() and is_page( 1036 )) { echo "has post"; } else { echo do_shortcode('[ recent_products per_page=20" columns="4" orderby="rand" order="rand]'); } ?> but its not working anyone can help.
  6. Hi, Ive got a few records stored in my database and would wish to remove records older than 30 days. The thing is I got a field in my database table called pprofilepic which contains the directory of an image stored on my host. I would like to delete the image before removing the record from the database. Would I need to use the while loop to do so? Here is an example of database records output in php array $Users2 = array( array('ID' => '1','Username' => 'Cobus','mxitid' => 'Debater','mxitlogin' => '','nick' => '','phone' => '','location' => '','rank' => '1','registered' => '1443554980','last_online' => '1446482291','ip1' => '165.255.107.53','ip2' => '165.255.107.53','pprofilepic' => 'uploads/resized_1_1444068533.jpg','aprove' => 'yes','pname' => '','psname' => '','pgender' => '','pmarital' => '','plocation' => '','phobbies' => '','pabout_myself' => '','pdob' => '0000-00-00'), array('ID' => '2','Username' => 'AKA IV LEAGUE','mxitid' => 'm61831903002','mxitlogin' => '1998xtreme25','nick' => 'king"othello','phone' => 'ZTE/V795','location' => 'ZA,,,,,,212881,29608915838,1387f57','rank' => '2','registered' => '1443555418','last_online' => '1446731775','ip1' => '1c6ff112add9dc7a5594dec967be0f7a','ip2' => '196.35.255.31','pprofilepic' => 'images/resized_2_1446642825.jpg','aprove' => 'no','pname' => 'Akaworldwide','psname' => '','pgender' => 'Male','pmarital' => 'Not Saying','plocation' => 'South Africa »»KZN»»Durban','phobbies' => 'Programming - watching & playing soccer ','pabout_myself' => 'Humble guy down to earth- also short tempered - so watch what to say to me:)','pdob' => '1998-03-25'), And here is my Code I put together so far but not sure if im on the right track. <? $result9 = mysql_query("SELECT * FROM Users2 WHERE last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"); while($row = mysql_fetch_array($result9)){ $ppic = $row['pprofilepic']; $id = $row['ID']; $unlink($ppic); $query = "DELETE FROM Users2 WHERE ID ='".$id."'"; mysql_query($query); } ?>
  7. [Linux] PHP Notice: Undefined variable: connection in /var/www/html/popreport/functions.php on line 23 PHP Fatal error: Call to a member function query() on a non-object in /var/www/html/popreport/functions.php on line 23 The fuction output in the following program is called from another file called records records-board.php If you look at the program below you'll see that I did define $connection above line 23 in the file functions.php And for the second error I'm really not getting it because that same foreach loop was working fine with the exact same argument list when it was in the file records-board.php, but now that I've copied most of the code from records-board.php and placed it in functions.php all the sudden my program can't see the variable $connection and has a problem with my foreach loop on line 23. Again, both of those lines worked fine when they were in another file. functions.php <?php //session_start(); // open a DB connectiong $dbn = 'mysql:dbname=popcount;host=127.0.0.1'; $user = 'user'; $password = 'password'; try { $connection = new PDO($dbn, $user, $password); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } $sql = "SELECT full_name, tdoc_number, race, facility FROM inmate_board WHERE type = 'COURT'"; function output() { foreach($connection->query($sql) as $row) { echo "<tr><td>$row[full_name]</td></tr>"; } } ?> records-board.php <? include 'functions.php'; php output(); ?> Any ideas?
  8. hi, guys i'm trying to create a commenting system to posts in a example site. And i can't seem to print the exact comments to its original post. i created two tables updates and comment_update and kept os_id as the common table row, where it is refering to update_id of updates table. everything seems ok except for the loops which is screwing up the output. Any advice on how to rectify it as i tried with while & other loops everything gives the same problem. here is my code for that logic: <?php $status_replies=""; $statusui_edit=""; $status2view=$project->statusView($_SESSION['uname']); foreach($status2view as $row){ $updateid=$row['update_id']; $account_name=$row['account_name']; $os_id=$row['os_id']; $author=$row['author']; $post_date=$row['time']; $title= stripslashes($row['title']); $data= stripslashes($row['update_body']); $statusdeletebutton=''; $sql1="select * from updates,comment_update where comment_update.os_id like updates.update_id and comment_update.type like 'b'"; $sql2="select * from updates left join comment_update using (os_id) where comment_update.os_id=:statusid "; $stmth=$conn->prepare($sql2); // $stmth->bindparam(":either",$_SESSION['uname']); //$stmth->bindparam(":statusid",$updateid); $stmth->execute(array( ":statusid"=>$updateid)); $status_reply= $stmth->fetchAll(PDO::FETCH_ASSOC); foreach ($status_reply as $row) { $status_reply_id=$row['comment_id']; $reply_author=$row['author']; $reply_d=htmlentities($row['comment_body']); $reply_data= stripslashes($reply_d); $reply_osid=$row['os_id']; $reply_date=$row['time']; $reply_delete_button=""; if ($reply_author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) { $reply_delete_button.="<li><span id='$status_reply_id' class='delete_reply_btn glyphicon glyphicon-remove'><a href='#' title='Delete this comment'>Remove X</a></span></li>"; } if ($updateid==$reply_osid) { $status_replies="<div class='replyboxes pull-left reply_".$status_reply_id."'>Reply by:-<a href='search_results.php?u=".$reply_author."'>".$reply_author."</a>" . "<span class='pull-right'>".$reply_date . "<b class='caret'> <small><span class='btn-xs btn-danger dropdown-toggle pull-right' data-toggle='dropdown' aria-expanded='true' ><span class='glyphicon glyphicon-edit'></span> <ul class='dropdown-menu'>".$reply_delete_button . "<li><a href='#' class='hidden_text_area glyphicon glyphicon-pencil reply_".$status_reply_id."' title='Edit this comment' >Edit</a></li>" . "<li><a href='report.php?u='".$reply_author."'>Report</a><li></ul>" . "</span></span></small></b><br><legend>". html_entity_decode($reply_data)."</legend><br></div>"; } else { $status_replies=""; } } //insert_status_ui script to get message. if ($author==$_SESSION['uname'] || $account_name==$_SESSION['uname']) { $statusdeletebutton='<li>' . '<a href="#" type="'.$updateid.'" class="delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_reply_btn" title="Delete this status and its replies">Remove</a></li>'; } $status_list= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">' . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' . '<li><a href="#" attr="'.$updateid.'" type="'.$updateid.'" class="edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'.$statusdeletebutton.'</ul></div></span><br><hr>' . '<legend><span class=" data_s_2copy" type="'.$updateid.'" >' . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br><p>'.$status_replies.'</p><br>'; $status_list.= '<textarea id="reply_textarea_'.$updateid.'" class="status_reply_'.$updateid.' input-custom2" placeholder="comment\'s"></textarea>' . '<button id="reply_btn_'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_btn reply_'.$updateid.'">Reply</button></div>'; echo $status_list; } ?>
  9. hey guys im running a XML HTTP request and i'm getting the error 413 - ie. image too large. I know its js i'm executing but i think its a php problem so i changed some settings in my php.ini post_max_size = 10M upload_max_filesize = 10M here is the js i'm using function upload_image(image){ var data = new FormData(); xhr = new XMLHttpRequest(); data.append('image', image); xhr.open('POST', 'save.php', true); xhr.upload.onprogress = function(e) { if (e.lengthComputable) { var percentComplete = (e.loaded / e.total) * 100; console.log(percentComplete + '% uploaded'); } } xhr.onload = function() { console.log(this.status); if (this.status === 200) { var response = this.response console.log('Server got:', response); } } xhr.send(data); } it works with smaller images but when trying to upload a 4.4 mb image i get the error 413...now i'm a little confused on how i'm getting this error as i've changed my post and upload max sizes is there something obvious i'm missing here please? thank you
  10. Hi I'm trying to recall a list of names of people who posted something according to the StringyChat_time field within the hour. The problem is it doesn't select the latest record, but rather the oldest one within the hour how can I select the latest time record? $galleries = array('ADMIN','Moderator','Global Helper','Helper','!!!ANNOUNCEMENT!!!','!!!TOPIC CHANGE!!!'); $sql = "SELECT * FROM StringyChat WHERE StringyChat_time >= (UNIX_TIMESTAMP() - 3600) AND StringyChat_name NOT IN ( '" . implode($galleries, "', '") . "' ) GROUP BY StringyChat_name ORDER BY StringyChat_time DESC LIMIT $offset, $rowsperpage"; $result1 = mysql_query($sql, $db)or die($sql."<br/><br/>".mysql_error());
  11. First let me start by saying I'm not looking to copy someone else's code but better understand where the line is drawn for people copying my own code. All developers at some point will have used others code in there own work. If you see something that inspires you, you may decided to use that code in your design. In some degree this maybe classed as fair use depending on the quantity of code you copy. Another developer may taken an entire php file, function, class, CSS sheet, HTML file and use this in there work / pass this off as there own work. This is blatant plagiarism. However what is stopping a developer from taking an entire piece of code and editing every aspect of the file to make it his own? For instance a designer my change the names of the styles and perhaps change the order of the properties and there values slightly; He may also move around parts of the html. In doing so causes the design to look different to your own but still the copying your work no the less. Another instance maybe that a PHP developer uses your entire code / software package and change the names of the variables, classes and methods; He may also change the order in which the methods appear and even change some similar functions to use alternatives such as loops. Again this causes the program to do exactly what your intends to do, however the source code will now look different to your own. How far can someone go back doing these actions? Is this legal? How best would you be able to prove it?
  12. Is there an easy way to change dates in a column so that if the date falls on a Saturday or Sunday it changes to the closest business day?
  13. hi guys im actually perplexed with this problem where im not able to read anything from DB, when i var dump the object it just outputs bool(false). dont know where im going wrong, Pl help me here is the code logic for status_list page where status_reply resides which i want to read from DB and display it:- $status2view=$project->statusView($f_uname); foreach($status2view as $row){ //print_r($row); $updateid=$row['update_id']; //gives output on var_dump // print_r($updateid); (gives output) $status_reply_=$project->reply2StatusView($updateid); print_r($status_reply_); foreach ($status_reply_ as $row) { $status_reply_id=$row['update_id']; $reply_author=$row['author']; $reply_d=htmlentities($row['update_body']); $reply_data= stripslashes($reply_d); $reply_t= htmlentities($row['title']); $reply_title= stripslashes($reply_t); $account_name=$row['account_name']; $reply_date=$row['time']; $reply_delete_button=""; if ($reply_author==$session_uname || $account_name==$session_uname) { $reply_delete_button="<li><span id='$status_reply_id' class='delete_reply_btn glyphicon glyphicon-remove'><a href='#' title='Delete this comment'>Remove X</a></span></li>"; } $status_replies="<div class='replyboxes pull-left reply".$status_reply_id."'><b>Reply by<a href='search_results.php?u=".$reply_author."'>".$reply_author."</a><span class='pull-right'>".$reply_date ."</pan><legend>" . "<b class='caret'> <button type='button' class='btn btn-danger dropdown-toggle pull-right' data-toggle='dropdown' aria-expanded='true' ><span class='glyphicon glyphicon-edit'></span> <ul class='dropdown-menu'>".$reply_delete_button . "<li><a href='#' class='hidden_text_area glyphicon glyphicon-pencil reply".$status_reply_id."' title='Edit this comment' >Edit</a></li>" . "<li><a href='report.php?u='".$reply_author."'>Report</a><li></ul>" . "</button></b></legend><br>". html_entity_decode($reply_data).""; } } foreach ($status2view as $row1) { //got values here. $updateid=$row1['update_id']; $account_name=$row1['account_name']; $os_id=$row1['os_id']; $author=$row1['author']; $post_date=$row1['time']; $title= stripslashes($row1['title']); $data= stripslashes($row1['update_body']); $statusdeletebutton=''; //insert_status_ui script to get message. if($isowner=="yes"){ $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_session session_editor".$updateid." jumbotron'>" . "<a href='#' type='".$updateid."' class='pull-right close_edit' title='Close without editing'>Close X</a>" . "<input type='text' class='form-control title_s_edit title_s_".$updateid."' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' >" . "<span> </span>" . "<textarea id='wall_edit_1' type='".$updateid."' rows='5' cols='50' class='session_edit text_value_".$updateid."' wrap='hard' placeholder='whats up ".$session_uname."'> ".html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>" ; } elseif ($is_friend==TRUE&&$session_uname!=$f_uname) { $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_friend friend_editor".$updateid." jumbotron'>" . "<a title='Close without editing' type='".$updateid."' href='#' class='pull-right close_edit_f'>Close X</a>" . "<input type='text' class='form-control title_f_edit title_f_".$updateid."'' name='status_title' value='".html_entity_decode($title)."' placeholder='Title'><br>" . "<div> </div>" . "<textarea id='wall_edit_2' value='' type='".$updateid."' rows='5' cols='50' class='friend_edit update_friend_".$updateid."' placeholder='hi ".$session_uname." want to say something to ".$f_uname.". '>" .html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='c' class='btn btn-warning btn-large btn-lg post-f-edit'>Update</button></form></div>"; } if ($author==$session_uname || $account_name==$session_uname) { $statusdeletebutton='<li>' . '<a href="#" type="'.$updateid.'" class="delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_reply_btn" title="Delete this status and its replies">Remove</a></li>'; } if($isowner=="yes"){ $status_list= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">' . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' . '<li><a href="#" attr="'.$updateid.'" type="'.$updateid.'" class="edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'.$statusdeletebutton.'</ul></div></span><br><hr>' . '<legend><span class=" data_s_2copy" type="'.$updateid.'" value="'.html_entity_decode($data).'">' . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br><p>'.$status_replies.'</p><br>'; if ($is_friend==TRUE||$session_uname==$f_uname) { $status_list.= '<textarea id="'.$updateid.'" class="status_reply_'.$updateid.' input-custom2" placeholder="comment\'s"></textarea>' . '<button id="reply_btn_'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_btn reply_'.$updateid.'">Reply</button></div>'; } }elseif ($is_friend==TRUE&&$session_uname!=$f_uname) { $status_list= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">' . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3><br><hr>' . '<legend><span class=" data_s_2copy" type="'.$updateid.'" value="'.html_entity_decode($data).'">' . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br><p>'.$status_replies.'</p><br>'; $status_list.= '<textarea id="'.$updateid.'" class="status_update input-custom2" placeholder="comment\'s"></textarea>' . '<button id="reply_btn'.$updateid.'" attr="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm reply_btn reply_'.$updateid.'">Reply</button></div>'; } echo $status_list; } the above code is called in home and search results page through include_once function. if you need any details please do ask me for it
  14. Have basic article directory and i'm busy with pagination. And i want to have it shortlinked. Structure of the link looks like this: Without pagination <a href='moving-articles/category/$sublink/'>$sublink</a> rewrite rule in .htaccess look like this RewriteRule moving-articles/(.*)/(.*)/$ /moving-articles.php?$1=$2 That works perfectly fine. So the problem i have here, one i try to add pagination. Link structure is like this for example: <a href='moving-articles/category/$sublink/page/2/'>2</a> rewrite rule in .htaccess: RewriteRule moving-articles/(.*)/(.*)/(.*)/(.*)/$ /moving-articles.php?$1=$2&$3=$4 And piece of php code responsible for calling variables: if(isset($_GET['category']) && isset($_GET['page'])) { $sublink=$_GET['category']; $page=$_GET['page']; ..... } What do i do wrong here? Thanks for your help in advance!
  15. I do have a `.dat` file that contain airports data all around the world. So now I need to insert data into `mysql` from this `.dat` file. This is how I tried it in mysql: LOAD DATA LOCAL INFILE '/tmp/airports.dat' REPLACE INTO TABLE airports FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (apid, name, city, country, iata, icao, y, x, elevation, timezone, dst, tz_id); But its not inserting data into mysql and I can get an error when I run above query. mysql> LOAD DATA LOCAL INFILE '/tmp/airports.dat' REPLACE INTO TABLE airportsFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' ( apid, name, city, country, iata, icao, y, x, elevation, timezone, dst, tz_id); ERROR 1064 (42000): 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 ' TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (apid, nam' at line 1 mysql> This is the data structure of my `.dat` file: 1,"Goroka","Goroka","Papua New Guinea","GKA","AYGA",-6.081689,145.391881,5282,10,"U","Pacific/Port_Moresby" 2,"Madang","Madang","Papua New Guinea","MAG","AYMD",-5.207083,145.7887,20,10,"U","Pacific/Port_Moresby" 3,"Mount Hagen","Mount Hagen","Papua New Guinea","HGU","AYMH",-5.826789,144.295861,5388,10,"U","Pacific/Port_Moresby" 4,"Nadzab","Nadzab","Papua New Guinea","LAE","AYNZ",-6.569828,146.726242,239,10,"U","Pacific/Port_Moresby" 5,"Port Moresby Jacksons Intl","Port Moresby","Papua New Guinea","POM","AYPY",-9.443383,147.22005,146,10,"U","Pacific/Port_Moresby" 6,"Wewak Intl","Wewak","Papua New Guinea","WWK","AYWK",-3.583828,143.669186,19,10,"U","Pacific/Port_Moresby" 7,"Narsarsuaq","Narssarssuaq","Greenland","UAK","BGBW",61.160517,-45.425978,112,-3,"E","America/Godthab" 8,"Nuuk","Godthaab","Greenland","GOH","BGGH",64.190922,-51.678064,283,-3,"E","America/Godthab" 9,"Sondre Stromfjord","Sondrestrom","Greenland","SFJ","BGSF",67.016969,-50.689325,165,-3,"E","America/Godthab" 10,"Thule Air Base","Thule","Greenland","THU","BGTL",76.531203,-68.703161,251,-4,"E","America/Thule" And so on upto 8000 of lines. Hope somebody may help me out. Thank you.
  16. I have a table of prices by date and I am trying to select two rows, the 2nd row and a fixed row. It the below statement I am trying to get the date less than the current date but it is returning mixed results. How can I get just the row for .$Hist['BuyDateSubmit']. and the row with the date which is on the 2nd row from the top? $HistQ = "select * from TABLE where Date = '".$Hist['BuyDateSubmit']. "' AND (Date <'". $XXX . "' OR Date = '" . $Hist['BuyDateSubmit'] ."')";
  17. I have the following query used for a google line chart. The query works and does four different monthly counts for the past 12 months to current date. I need to modify it so it does the same exact thing but weekly for the past 6 month to current date. Week starts Sunday, ends Saturday. No brain food left after this one. Getting weak... * Any improvements to current query are also encouraged. Output Image attached. <?php if (isset($_REQUEST['floor']) || !isset($_REQUEST['specialty'])) { $contract_type_id = 3; $active_column = 'active'; } if (isset($_REQUEST['specialty'])) { $contract_type_id = 2; $active_column = 'active_specialty'; } $sql="SELECT C.month, sum(slab) as slab, sum(dried_in) as dried_in, sum(drywall) as drywall, sum(frame) as frame, C.year_month_number FROM ( (SELECT CASE MONTH (l.frame_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.frame_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.frame_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.frame_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.frame_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.frame_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.frame_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.frame_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.frame_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.frame_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.frame_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.frame_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.frame_date)) ELSE 'Unknown' END as 'month', null as slab, null as drywall, COUNT(IF(l.frame_date is not null, 1, 0)) AS frame, null AS dried_in, CONCAT(Year (l.frame_date),LPAD(MONTH (l.frame_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.frame_date is not null and (frame_date <= CURDATE() and frame_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.frame_date) ORDER BY MONTH (l.frame_date) ASC) UNION ALL (SELECT CASE MONTH (l.drywall_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.drywall_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.drywall_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.drywall_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.drywall_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.drywall_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.drywall_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.drywall_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.drywall_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.drywall_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.drywall_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.drywall_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.drywall_date)) ELSE 'Unknown' END as 'month', null as slab, COUNT(IF(l.drywall_date is not null, 1, 0)) AS drywall, null as frame, null AS dried_in, CONCAT(Year (l.drywall_date),LPAD(MONTH (l.drywall_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.drywall_date is not null and (drywall_date <= CURDATE() and drywall_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.drywall_date) ORDER BY MONTH (l.drywall_date) ASC) UNION ALL (SELECT CASE MONTH (l.slab_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.slab_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.slab_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.slab_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.slab_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.slab_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.slab_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.slab_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.slab_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.slab_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.slab_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.slab_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.slab_date)) ELSE 'Unknown' END as 'month', COUNT(IF(l.slab_date is not null, 1, 0)) AS slab, null as drywall, null as frame, null AS dried_in, CONCAT(Year (l.slab_date),LPAD(MONTH (l.slab_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.slab_date is not null and (slab_date <= CURDATE() and slab_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.slab_date) ORDER BY MONTH (l.slab_date) ASC) UNION ALL (SELECT CASE MONTH (l.dried_in_date) WHEN 1 THEN CONCAT('Jan', '-', Year (l.dried_in_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.dried_in_date)) WHEN 3 THEN CONCAT('Mar', '-', Year (l.dried_in_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.dried_in_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.dried_in_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.dried_in_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.dried_in_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.dried_in_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.dried_in_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.dried_in_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.dried_in_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.dried_in_date)) ELSE 'Unknown' END as 'month', null AS slab, null as drywall, null as frame, Count(IF(l.dried_in_date is not null, 1 , 0)) AS dried_in, CONCAT(Year (l.dried_in_date), LPAD(MONTH (l.dried_in_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and dried_in_date is not null and (dried_in_date <= CURDATE() and dried_in_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.dried_in_date) ORDER BY MONTH (l.dried_in_date) asc) ) as C GROUP BY C.month ORDER BY C.year_month_number asc"; echo $sql; $stmt = $pdo->prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(); $data[] = array( 'month', 'slab', 'dried_in', 'frame', 'drywall' ); foreach ($result as $row) { $data[] = array( $row['month'], (int) $row['slab'], (int) $row['dried_in'], (int) $row['frame'], (int) $row['drywall'] ); } $encoded_data= json_encode($data); ?> <!-- Load Google JSAPI --> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", { packages: ["corechart"] }); google.setOnLoadCallback(drawChart); // draw chart fucntion function drawChart() { /* var jsonData = $.ajax({ url: "./includes/chart_12month_comparison_data.php", dataType: "json", async: false }).responseText; var obj = jQuery.parseJSON(jsonData); */ var data = google.visualization.arrayToDataTable(<?php echo $encoded_data;?>); var currentYear = new Date(); var options = { //title: 'Demo Google LineChart : ' + (new Date(currentYear.setDate(currentYear.getDate() - 365))).yyyymmdd() + ' - ' + (new Date()).yyyymmdd() title: '12 Month Comparison ' + (new Date(currentYear.getFullYear()-1,currentYear.getMonth()+1)).yyyymmdd() + ' - ' + (new Date()).yyyymmdd(), //legend: 'none', hAxis: { minValue: 0, maxValue: 9 }, pointSize: 10, pointShape: 'square' }; var chart = new google.visualization.LineChart( document.getElementById('chart_div')); chart.draw(data, options); } // format date function Date.prototype.yyyymmdd = function() { var yyyy = this.getFullYear().toString(); var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based var dd = this.getDate().toString(); return yyyy + "/" + (mm[1]?mm:"0"+mm[0]) + "/" + (dd[1]?dd:"0"+dd[0]); // padding }; </script> <?php $floor = isset($_GET['floor']) || !isset($_GET['specialty']) ? "style=\"color:#FF0000\"" : ''; $specialty = isset($_GET['specialty']) ? "style=\"color:#FF0000\"" : ''; ?> FILTER: <a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?p=<?php echo $_GET['p'];?>&floor" title="Flooring" <?php echo $floor;?>>Flooring</a> | <a href="<?php echo $_SERVER['SCRIPT_NAME'];?>?p=<?php echo $_GET['p'];?>&specialty" title="Specialty" <?php echo $specialty;?>>Specialty</a><br><br> <div id="chart_div" style="width: 900px; height: 500px;"> </div>
  18. hi, guys im trying to echo out results of a particular variable in my search_results.php file where i want to actually display the status of a friend which isn't showing up but is showing up in home.php page which handles the session user data. though i tried some variations it isn't of any help. The satusui variable which has the same logic works well but not the status_list variable for the friend in search_results page. please, help me to build the conversation system. code in status_list page:- $status2view=$project->statusView($f_uname); foreach($status2view as $row){ //print_r($row); $id=$row['update_id']; //gives output on var_dump $status_replies_=$project->reply2StatusView($id); foreach ($status_replies_ as $row) { $status_reply_id=$row['update_id']; $reply_author=$row['author']; $reply_d=htmlentities($row['update_body']); $reply_data= stripslashes($reply_d); $reply_t= htmlentities($row['title']); $reply_title= stripslashes($reply_t); $account_name=$row['account_name']; $reply_date=$row['time']; $reply_delete_button=""; if ($reply_author==$session_uname || $account_name==$session_uname) { $reply_delete_button="<li><span id='$status_reply_id' class='delete_reply_btn glyphicon glyphicon-remove'><a href='#' title='Delete this comment'>Remove X</a></span></li>"; } $status_replies="<div id='".$status_reply_id."' class='replyboxes'><b>Reply by<a href='search_results.php?u=".$reply_author."'>".$reply_author."</a>".$reply_date ."<legend>" . "<b class='caret'><button type='button' class='btn btn-danger dropdown-toggle pull-right' data-toggle='dropdown' aria-expanded='true' ><span class='glyphicon glyphicon-edit'></span> <ul class='dropdown-menu'>".$reply_delete_button." " . "<li><a href='#' class='hidden_text_area glyphicon glyphicon-pencil' title='Edit this comment' >Edit</a></li>" . "<li><a href='report.php?u='".$reply_author."'>Report</a><li></ul>" . "</button></b></legend><br>". html_entity_decode($reply_data).""; } } foreach ($status2view as $row1) { //got values here. $updateid=$row1['update_id']; $account_name=$row1['account_name']; $os_id=$row1['os_id']; $author=$row1['author']; $post_date=$row1['time']; $title= stripslashes($row1['title']); $data= stripslashes($row1['update_body']); $statusdeletebutton=''; //insert_status_ui script to get message. if($isowner=="yes"){ $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_session session_editor".$updateid." jumbotron'>" . "<a href='#' type='".$updateid."' class='pull-right close_edit' title='Close without editing'>Close X</a>" . "<input type='text' class='form-control title_s_edit title_s_".$updateid."' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' >" . "<div> </div>" . "<textarea id='wall_edit_1' type='".$updateid."' rows='5' cols='50' class='session_edit text_value_".$updateid."' wrap='hard' placeholder='whats up ".$session_uname."'> ".html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>"; } elseif ($is_friend==TRUE&&$session_uname!=$f_uname) { $statusui_edit="<div type='".$updateid."' class='hidden_edit_4_friend friend_editor".$updateid." jumbotron'>" . "<a title='Close without editing' type='".$updateid."' href='#' class='pull-right close_edit_f'>Close X</a>" . "<input type='text' class='form-control title_f_edit title_f_".$updateid."'' name='status_title' value='".html_entity_decode($title)."' placeholder='Title'><br>" . "<div> </div>" . "<textarea id='wall_edit_2' value='' type='".$updateid."' rows='5' cols='50' class='friend_edit update_friend_".$updateid."' placeholder='hi ".$session_uname." want to say something to ".$f_uname.". '>" .html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' value='".$updateid."' type='c' class='btn btn-warning btn-large btn-lg post-f-edit'>Update</button></form>"; } if ($author==$session_uname || $account_name==$session_uname) { $statusdeletebutton='<li>' . '<a href="#" type="'.$updateid.'" class="delete_4_session hidden_text_delete_'.$updateid.' glyphicon glyphicon-trash delete_reply_btn" title="Delete this status and its replies">Remove</a></li>'; } if($isowner=="yes"){ $status_list= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">' . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<span class="pull-right">' . '<div class="dropdown">' . '<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" >' . '<span class="glyphicon glyphicon-edit"></span></button>' . '<ul class="dropdown-menu">' . '<li><a href="#" attr="'.$updateid.'" type="'.$updateid.'" class="edit_4_session hidden_text_edit glyphicon glyphicon-pencil" title="Edit this status" >Edit</a></li>'.$statusdeletebutton.'</ul></div></span><br><hr>' . '<legend><span class=" data_s_2copy" type="'.$updateid.'" value="'.html_entity_decode($data).'" style="font-size:9px; margin-bottom:0px; margin-top:0px; text-align:left; color:black;">' . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br>'.$status_replies.'<br>'; if ($is_friend==TRUE||$session_uname==$f_uname) { $status_list.= '<textarea id="'.$updateid.'" class="status_update input-custom2" placeholder="comment\'s"></textarea>' . '<button id="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm">Reply</button></div>'; } echo $status_list; }elseif ($is_friend==TRUE&&$session_uname!=$f_uname) { $status_list= $statusui_edit.'<div attr="'.$updateid.'" type="'.$updateid.'" class="statusboxes status_'.$updateid.' jumbotron">' . '<h3 style="color:black; margin-bottom:5px; margin-top:5px;" class="pull-left">' . '<div id="'.$updateid.'" class="title_s_2copy" value="'.html_entity_decode($title).'">'.html_entity_decode($title).'</div></h3>' . '<legend><span class=" data_s_2copy" type="'.$updateid.'" value="'.html_entity_decode($data).'" style="font-size:9px; margin-bottom:0px; margin-top:0px; text-align:left; color:black;">' . html_entity_decode($data).'</span><br><br></legend><b style="text-align:right; color:black;"><small>Posted by:- <a href="search_results.php?u='.$author.'">'.$author. '</a> '.$post_date.'</small></b>' . '<br>'.$status_replies.'<br>'; $status_list.= '<textarea id="'.$updateid.'" class="status_update input-custom2" placeholder="comment\'s"></textarea>' . '<button id="'.$updateid.'" type="b" class="btn btn-warning pull-right btn-sm">Reply</button></div></div>'; echo $status_list; } } code for search_results page where the statuslist is included:- if($isowner=="yes"){ $statusui="<div class='jumbotron'><input type='text' class='form-control title_s' name='status_title' placeholder='Title ' ><br>" . "<textarea id='wall_id_1' class='update_session' placeholder='whats up ".$session_uname."'>" . "</textarea>" . "<button style='float:right;' type='a' class='btn btn-warning btn btn-large btn-lg post-s'>Post</button></div>"; $statusui_edit="<div attr='".$updateid."' class='hidden_edit_4_session session_edit".$updateid." jumbotron'>" . "<a href='#' class='pull-right close_edit' title='Close without editing'>Close X</a>" . "<input type='text' class='form-control title_s_edit' name='status_title' value='".html_entity_decode($title)."' placeholder='Title' >" . "<div> </div>" . "<textarea id='wall_edit_1' class='session_edit' placeholder='whats up ".$session_uname."'> ".html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' type='a' class='btn btn-warning btn btn-large btn-lg post-s-edit'>Update</button></div>"; } elseif ($is_friend==TRUE&&$session_uname!=$f_uname) { $statusui="<div class='jumbotron'><input type='text' class='form-control title_f' name='status_title' placeholder='Title'><br>" . "<textarea id='wall_id_2' type='c' class='status_4_friend' style='' placeholder='hi ".$session_uname." want to say something to ".$f_uname.". '>" . "</textarea><br>" . "<button style='float:right;' type='c' class='btn btn-warning btn-large btn-lg post-f'>Post</button></div>"; $statusui_edit="<div attr='".$updateid."' class='hidden_edit_4_friend friend_edit".$updateid." jumbotron'>" . "<a title='Close without editing' href='#' class='pull-right close_edit_f'>Close X</a>" . "<input type='text' class='form-control title_f_edit' name='status_title' value='".html_entity_decode($title)."' placeholder='Title'><br>" . "<textarea id='wall_edit_2' value='' class='update_4_expresspad'placeholder='hi ".$session_uname." want to say something to ".$f_uname.". '>" .html_entity_decode($data)."</textarea><br>" . "<button style='float:right;' type='c' class='btn btn-warning btn-large btn-lg post-f-edit'>Update</button>"; } ?> <div class="container-fluid"> <br><div class="row"> </div><br> <div class="row"> <div class="col-sm-2"> <p>Friends list:</p> <?php include_once 'notification/friend_list.php'; echo $friends_html; ?> </div> <div class="col-lg-8"> <div class="tab-content"> <ul class="nav nav-tabs"> <li class="active"><a href="#tabs-1" data-toggle="tab" class="profile">Profile</a></li> <li><a href="#tabs-2" data-toggle="tab"class="articles">Status</a></li> <li><a href="#tabs-4"data-toggle="tab" class="gallery_photos">Gallery</a></li> <li><a href="#tabs-5" data-toggle="tab" class="videos">Videos</a></li> </ul> <div id="tabs-1" class="tab-pane fade profile1 active in"> <?php echo '<table border="0"><tr width="20%"><td>Profile Photo</td><td>' . $friend_button . '</td></tr> <tr><td></td><td>' . $block_button . '</td></tr> <tr width="100%"><td width="20%"></td><td width="55%"><p>Full Name:' . $fname_s . ' ' . $lname_s . '<br> </td><td width="20%"></td></tr> </table>'; ?> </div> <div id="tabs-2" class="tab-pane fade articles">
  19. Howdy, I am writing a forum from scratch because I like to play with fire. Moving on, I can't think of the best way to store table and column names in either variables or constants. And where to store them? Maybe in a new config.php file? I thought about it and not one sane idea entered my head. I really don't like to write them each time in my DB wrapper methods since if i change the name of a table or a column, the whole thing will fall apart. Currently i have it set like this: <?php class Posts extends DB { public function list_topics_based_on_category() { return $this->select_from_table_condition('posts_id, posts_title, posts_date, author_id', 'posts', 'posts_categories_id = 1'); } public function display_contributor_name_by_id($user_id_array) { $contributor_name = $this->select_from_table_condition_user_input('username', 'users', 'id = ', $user_id_array); return $contributor_name[0]['username']; } public function count_comments($topic_id) { return count($this->select_from_table_condition_user_input('comments_id', 'comments', 'comments_topic_id = ', $topic_id)); } public function select_single_topic($topic_id) { return $this->select_from_table_condition_user_input('*', 'posts', 'posts_id = ', $topic_id)[0]; } } Please help! Thank you very much!
  20. Here is what i need. I have a form with a bunch of text boxes and check box's that i need to submit to mysql database. I know how to submit the text boxes just fine with the insert statment. I have not used check boxes and i need some help on how to insert them into the database. I need them to be enterened in as a 0 or 1. Here is the form <form action="submit.php" method="post"> <table width="1000" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="1400" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="6%" height="168"> </td> <td width="87%"> </td> <td width="7%"> </td> </tr> <tr> <td height="37"> </td> <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="32%" valign="bottom"><input name="water-purveyor" type="text" id="water-purveyor" size="35" /></td> <td width="29%" valign="bottom"><input name="meter-num" type="text" id="meter-num" size="10" /></td> <td width="39%" valign="bottom"><input type="text" name="permit-num" id="permit-num" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="42"> </td> <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="32%" valign="bottom"> <input name="manufacturer" type="text" id="manufacturer" size="20" /></td> <td width="15%" valign="bottom"><input name="meter-size" type="text" id="meter-size" size="10" /></td> <td width="15%" valign="bottom"><input name="model-num" type="text" id="model-num" size="10" /></td> <td width="38%" valign="bottom"><input name="serial-num" type="text" id="serial-num" size="18" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="62"> </td> <td valign="bottom"><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="61%" valign="bottom"><textarea name="mgmt-info" cols="50" rows="1" id="mgmt-info"></textarea></td> <td width="39%" valign="bottom"><textarea name="mgmt-phone-contact" cols="30" rows="1" id="mgmt-phone-contact"></textarea></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="63"> </td> <td><table width="100%" height="57" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="61%" valign="bottom"><textarea name="owner-info" cols="50" rows="1" id="owner-info"></textarea></td> <td width="39%" valign="bottom"><textarea name="owner-phone-contact" cols="30" rows="1" id="owner-phone-contact"></textarea></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="37"> </td> <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="32%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="3%"> </td> <td width="21%"><input type="checkbox" name="sab-owner" id="sab-owner" /></td> <td width="44%"><input type="checkbox" name="sab-management" id="sab-management" /></td> <td width="32%"><input type="checkbox" name="sab-other" id="sab-other" /></td> </tr> </table></td> <td width="29%" valign="bottom"><input name="auth-contact" type="text" id="auth-contact" size="20" /></td> <td width="39%" valign="bottom"><input name="auth-phone" type="text" id="auth-phone" size="15" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="65"> </td> <td><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="32%" valign="bottom"><textarea name="bf-assembly-address" cols="30" rows="1" id="bf-assembly-address"></textarea></td> <td width="29%" valign="bottom"><textarea name="onsite-location" cols="20" rows="1" id="onsite-location"></textarea></td> <td width="39%" valign="bottom"><textarea name="primary-business" cols="20" rows="1" id="primary-business"></textarea></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="63"> </td> <td><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="32%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="62" height="8"> </td> <td width="214" height="8"><input type="checkbox" name="new-assembly-yes" id="new-assembly-yes" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="new-assembly-no" id="new-assembly-no" /></td> </tr> </table></td> <td width="29%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="24%" height="8"> </td> <td width="76%" height="8"><input type="checkbox" name="replacement-assembly-yes" id="replacement-assembly-yes" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="replacement-assembly-no" id="replacement-assembly-no" /></td> </tr> </table></td> <td width="39%"><input type="text" name="new-serial-num" id="new-serial-num" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="42"> </td> <td><table width="100%" height="42" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="7%"> </td> <td width="24%"><div style="padding-top:8px; padding-left:4px;"><input type="checkbox" name="poa-secondary" id="poa-secondary" /></div></td> <td width="21%"><div style="padding-top:8px"><input type="checkbox" name="poa-primary" id="poa-primary" /></div></td> <td width="14%"><div style="padding-top:8px"><input type="checkbox" name="poa-fire-system" id="poa-fire-system" /></div></td> <td width="14%"><div style="padding-top:8px; padding-left:4px;"><input type="checkbox" name="poa-landscape" id="poa-landscape" /></div></td> <td width="20%"><div style="padding-top:8px; padding-left:4px;"><input type="checkbox" name="poa-portable" id="poa-portable" /></div></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="64"> </td> <td><table width="100%" height="58" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="33%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="6%"> </td> <td width="3%"> </td> <td width="26%"><input type="checkbox" name="svb" id="svb" /></td> <td width="23%"><input type="checkbox" name="pvb" id="pvb" /></td> <td width="21%"><input type="checkbox" name="dc" id="dc" /></td> <td width="21%"><input type="checkbox" name="rp" id="rp" /></td> </tr> <tr> <td> </td> <td valign="bottom"> </td> <td colspan="4"><div style="padding-left:20px;"><input name="toa-other-text" type="text" id="toa-other-text" size="30" /></div></td> </tr> </table></td> <td width="35%"> <input type="text" name="line-pressure" id="line-pressure" /></td> <td width="32%"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="19%"> </td> <td width="34%"><input type="checkbox" name="bp-yes" id="bp-yes" /></td> <td width="47%"><input type="checkbox" name="bp-no" id="bp-no" /></td> </tr> </table></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="64"> </td> <td><table width="100%" height="63" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="83%"> </td> <td width="17%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="32" colspan="5" valign="bottom" align="center"><input name="pvb-aioa-psid" type="text" id="pvb-aioa-psid" size="8" /></td> </tr> <tr> <td width="18%" height="25"> </td> <td width="28%"> </td> <td width="26%"><input type="checkbox" name="pvb-leaked-yes" id="pvb-leaked-yes" /></td> <td width="28%" colspan="2"><input type="checkbox" name="pvb-leaked-no" id="pvb-leaked-no" /></td> </tr> </table></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="56"> </td> <td><table width="100%" height="56" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="18%"> </td> <td width="22%" valign="top"><table width="100%" height="54" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="5%" height="6"> </td> <td width="49%"> </td> <td width="18%"><input type="checkbox" name="cv1-ct-yes" id="cv1-ct-yes" /></td> <td width="28%"><input type="checkbox" name="cv1-ct-no" id="cv1-ct-no" /></td> </tr> <tr> <td height="6"> </td> <td colspan="2" align="center"><input type="text" name="cv1-psid" id="cv1-psid" size="6" /></td> <td> </td> </tr> <tr> <td height="6"> </td> <td> </td> <td valign="top"><input type="checkbox" name="cv1-leaked-yes" id="cv1-leaked-yes" /></td> <td valign="top"><input type="checkbox" name="cv1-leaked-no" id="cv1-leaked-no" /></td> </tr> </table></td> <td width="22%"><table width="100%" height="54" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="5%" height="6"> </td> <td width="49%"> </td> <td width="19%"><input type="checkbox" name="cv2-ct-yes" id="cv2-ct-yes" style="background-color:transparent;" /></td> <td width="27%"><input type="checkbox" name="cv2-ct-no" id="cv2-ct-no" /></td> </tr> <tr> <td height="6"> </td> <td colspan="2" align="center"><input type="text" name="cv2-psid" id="cv2-psid" size="6" /></td> <td> </td> </tr> <tr> <td height="6"> </td> <td> </td> <td valign="top"><input type="checkbox" name="cv2-leaked-yes" id="cv2-leaked-yes" /></td> <td valign="top"><input type="checkbox" name="cv2-leaked-no" id="cv2-leaked-no" /></td> </tr> </table></td> <td width="20%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="30" colspan="2" align="center"><input type="text" name="dprv-psid" id="dprv-psid" size="8" /></td> <td width="6%"> </td> <td width="21%"> </td> </tr> <tr> <td width="54%"> </td> <td width="19%"><input type="checkbox" name="dprv-dno-yes" id="dprv-dno-yes" /></td> <td> </td> <td><input type="checkbox" name="dprv-dno-No" id="dprv-dno-No" /></td> </tr> </table></td> <td width="18%" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="32" colspan="5" valign="bottom" align="center"><input name="pvb-cvha-psid" type="text" id="pvb-cvha-psid" size="8" /></td> </tr> <tr> <td width="20%" height="25"> </td> <td width="20%"> </td> <td width="9%"> </td> <td width="24%"><input type="checkbox" name="pvb-cvha-leaked-yes" id="pvb-cvha-leaked-yes" /></td> <td width="27%"><input type="checkbox" name="pvb-cvha-leaked-no" id="pvb-cvha-leaked-no" /></td> </tr> </table></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="145"> </td> <td><table width="100%" height="143" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="18%" height="129"> </td> <td width="22%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="54%"> </td> <td width="18%"><input type="checkbox" name="cv1-cleaned-yes" id="cv1-cleaned-yes" /></td> <td width="28%"><input type="checkbox" name="cv1-cleaned-no" id="cv1-cleaned-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="cv1-replaced-yes" id="cv1-replaced-yes" /></td> <td><input type="checkbox" name="cv1-replaced-no" id="cv1-replaced-no" /></td> </tr> <tr> <td height="40"> </td> <td valign="bottom"><input type="checkbox" name="cv1-rkd-yes" id="cv1-rkd-yes" /></td> <td valign="bottom"><input type="checkbox" name="cv1-rkd-no" id="cv1-rkd-no" /></td> </tr> <tr> <td height="22"> </td> <td><input type="checkbox" name="cv1-springs-yes" id="cv1-springs-yes" /></td> <td><input type="checkbox" name="cv1-springs-no" id="cv1-springs-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="cv1-guide-yes" id="cv1-guide-yes" /></td> <td><input type="checkbox" name="cv1-guide-no" id="cv1-guide-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="cv1-other-yes" id="cv1-other-yes" /></td> <td><input type="checkbox" name="cv1-other-no" id="cv1-other-no" /></td> </tr> </table></td> <td width="22%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="51%" height="22"> </td> <td width="21%"><input type="checkbox" name="cv2-cleaned-yes" id="cv2-cleaned-yes" /></td> <td width="28%"><input type="checkbox" name="cv2-cleaned-no" id="cv2-cleaned-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="cv2-replaced-yes" id="cv2-replaced-yes" /></td> <td><input type="checkbox" name="cv2-replaced-no" id="cv2-replaced-no" /></td> </tr> <tr> <td height="40"> </td> <td valign="bottom"><input type="checkbox" name="cv2-rkd-yes" id="cv2-rkd-yes" /></td> <td valign="bottom"><input type="checkbox" name="cv2-rkd-no" id="cv2-rkd-no" /></td> </tr> <tr> <td height="22"> </td> <td><input type="checkbox" name="cv2-springs-yes" id="cv2-springs-yes" /></td> <td><input type="checkbox" name="cv2-springs-no" id="cv2-springs-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="cv2-guide-yes" id="cv2-guide-yes" /></td> <td><input type="checkbox" name="cv2-guide-no" id="cv2-guide-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="cv2-other-yes" id="cv2-other-yes" /></td> <td><input type="checkbox" name="cv2-other-no" id="cv2-other-no" /></td> </tr> </table></td> <td width="20%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="56%" height="22"> </td> <td width="22%"><input type="checkbox" name="dprv-cleaned-yes" id="dprv-cleaned-yes" /></td> <td width="22%"><input type="checkbox" name="dprv-cleaned-no" id="dprv-cleaned-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="dprv-replaced-yes" id="dprv-replaced-yes" /></td> <td><input type="checkbox" name="dprv-replaced-no" id="dprv-replaced-no" /></td> </tr> <tr> <td height="40"> </td> <td valign="bottom"><input type="checkbox" name="dprv-rkd-yes" id="dprv-rkd-yes" /></td> <td valign="bottom"><input type="checkbox" name="dprv-rkd-no" id="dprv-rkd-no" /></td> </tr> <tr> <td height="22"> </td> <td><input type="checkbox" name="dprv-springs-yes" id="dprv-springs-yes" /></td> <td><input type="checkbox" name="dprv-springs-no" id="dprv-springs-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="dprv-guide-yes" id="dprv-guide-yes" /></td> <td><input type="checkbox" name="dprv-guide-no" id="dprv-guide-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="dprv-other-yes" id="dprv-other-yes" /></td> <td><input type="checkbox" name="dprv-other-no" id="dprv-other-no" /></td> </tr> </table></td> <td width="18%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="48%" height="22"> </td> <td width="28%"><input type="checkbox" name="pvb-cleaned-yes" id="pvb-cleaned-yes" /></td> <td width="24%"><input type="checkbox" name="pvb-cleaned-no" id="pvb-cleaned-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="pvb-replaced-yes" id="pvb-replaced-yes" /></td> <td><input type="checkbox" name="pvb-replaced-no" id="pvb-replaced-no" /></td> </tr> <tr> <td height="40"> </td> <td valign="bottom"><input type="checkbox" name="pvb-rkd-yes" id="pvb-rkd-yes" /></td> <td valign="bottom"><input type="checkbox" name="pvb-rkd-no" id="pvb-rkd-no" /></td> </tr> <tr> <td height="22"> </td> <td><input type="checkbox" name="pvb-springs-yes" id="pvb-springs-yes" /></td> <td><input type="checkbox" name="pvb-springs-no" id="pvb-springs-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="pvb-guide-yes" id="pvb-guide-yes" /></td> <td><input type="checkbox" name="pvb-guide-no" id="pvb-guide-no" /></td> </tr> <tr> <td> </td> <td><input type="checkbox" name="pvb-other-yes" id="pvb-other-yes" /></td> <td><input type="checkbox" name="pvb-other-no" id="pvb-other-no" /></td> </tr> </table></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="29"> </td> <td><table width="100%" height="29" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="18%"> </td> <td width="82%"><table width="100%" height="29" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="29%"> </td> <td width="19%" valign="top"><input name="valve-num" type="text" id="valve-num" size="12" style="height:14px;" /></td> <td width="14%"> <input type="checkbox" name="repaired" id="repaired" /> </td> <td width="15%"> <input type="checkbox" name="replaced" id="replaced" /> </td> <td width="23%"> <input type="checkbox" name="both-ok" id="both-ok" /> </td> </tr> </table></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="62"> </td> <td><table width="100%" height="60" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="18%"> </td> <td width="22%" valign="top"><table width="100%" height="41" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25%" height="19"> </td> <td width="29%"> </td> <td width="20%"><input type="checkbox" name="ft-cv1-ct-yes" id="ft-cv1-ct-yes" /></td> <td width="26%"><input type="checkbox" name="ft-cv1-ct-no" id="ft-cv1-ct-no" /></td> </tr> <tr> <td colspan="3" align="center"><input name="ft-cv1-psid" type="text" id="ft-cv1-psid" size="8" /></td> <td> </td> </tr> </table></td> <td width="22%" valign="top"><table width="100%" height="41" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25%" height="19"> </td> <td width="25%"> </td> <td width="24%" valign="top"><div style="padding-left:4px;"><input type="checkbox" name="ft-cv2-ct-yes" id="ft-cv2-ct-yes" /></div></td> <td width="26%"><input type="checkbox" name="ft-cv-ct-no" id="ft-cv2-ct-no" /></td> </tr> <tr> <td colspan="3" align="center"><input type="text" name="ft-cv2-psid" id="ft-cv2-psid" size="8" /></td> <td> </td> </tr> </table></td> <td width="20%" align="center"><input name="ft-dprv-psid" type="text" id="ft-dprv-psid" size="8" /></td> <td width="18%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="36%" height="22"> </td> <td colspan="2" align="center"><input name="ft-ai-psid" type="text" id="ft-ai-psid" size="4" /></td> <td width="3%"> </td> <td width="20%"> </td> </tr> <tr> <td height="25"> </td> <td width="14%"> </td> <td colspan="2" align="center"><input name="ft-cv-psid" type="text" id="ft-cv-psid" size="3" /></td> <td> </td> </tr> </table></td> </tr> </table></td> <td> </td> </tr> <tr> <td colspan="3" height="32"></td> </tr> <tr> <td height="54"> </td> <td valign="bottom"><table width="100%" height="" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="49%" rowspan="2" valign="bottom"><textarea name="tc-info" cols="45" rows="1" id="tc-info"></textarea></td> <td width="51%" rowspan="2" valign="bottom"><textarea name="tc-info2" cols="40" rows="1" id="tc-info2"></textarea></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="37"> </td> <td valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-bottom:4px;"> <tr> <td width="23%"><input name="itb" type="text" id="itb" size="20" /></td> <td width="26%"><input name="certified-tester-num2" type="text" id="certified-tester-num2" size="15" /></td> <td width="26%"><input name="date-failed" type="text" id="date-failed" size="15" /></td> <td width="25%"><input name="tk-serial-num" type="text" id="tk-serial-num" size="20" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="39"> </td> <td valign="bottom"><table width="100%" height="33" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="23%"> </td> <td width="52%"> </td> <td width="25%"> </td> </tr> </table></td> <td> </td> </tr> <tr> <td height="38"> </td> <td valign="bottom"><table width="100%" height="32" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="23%"><input name="ftb" type="text" id="ftb" size="20" /></td> <td width="26%"><input name="ftb-certified-tester-num" type="text" id="ftb-certified-tester-num" size="20" /></td> <td width="26%"><input name="date-passed" type="text" id="date-passed" size="15" /></td> <td width="25%"><input name="ftb-tk-serial-num" type="text" id="ftb-tk-serial-num" size="20" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td height="123"> </td> <td><textarea name="comments" id="comments" cols="105" rows="3"></textarea></td> <td> </td> </tr> </table></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> </form> Here is just a sample of the insert code that i have: <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; $table = "sysform"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $water-purveyor = $_POST['water-purveyor']; $meter-num = $_POST['meter-num']; $permit-num = $_POST['permit-num']; $svb = $_POST['svb']; $pvb = $_POST['pvb']; $dc = $_POST['dc']; $rp = $_POST['rp']; $sql = "INSERT INTO $table ('water-purveyor', 'meter-num', 'permit-num','...', 'svb', 'pvb', 'dc', 'rp') VALUES ('$water-purveyor', '$meter-num', '$permit-num','$...', '$svb', '$pvb', '$dc', '$rp')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> Can anyone help me on how to under stand how to sumbit the check box's to where i have a 1 or 0. Also i need to use the get function to pull the data back to the form. Here is the statment i have for that just as an example: <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; $table = "sysform"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $water-purveyor = $_POST['water-purveyor']; $meter-num = $_POST['meter-num']; $permit-num = $_POST['permit-num']; $svb = $_POST['svb']; $pvb = $_POST['pvb']; $dc = $_POST['dc']; $rp = $_POST['rp']; $sql="SELECT * from $table where sequence = '".$_GET["sequence"]."' "; $rs=mysql_query($sql,$conn) or die(mysql_error()); $result=mysql_fetch_array($rs); ?> <form action="" method="get"> <table width="1000" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="1400" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="6%" height="168"> </td> <td width="87%"> </td> <td width="7%"> </td> </tr> <tr> <td height="37"> </td> <td><table width="100%" height="37" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="32%" valign="bottom"><input name="water-purveyor" type="text" id="water-purveyor" size="35" value="<?php echo '$water-purveyor'?>" /></td> <td width="29%" valign="bottom"><input name="meter-num" type="text" id="meter-num" size="10" value="<?php echo '$meter-num'?>" /></td> <td width="39%" valign="bottom"><input type="text" name="permit-num" id="permit-num" value="<?php echo '$permit-num'?>" /></td> </tr> </table> </form>
  21. I am trying to calculate the difference in the previous row using the following query. $query2 = "select * from " . $wsym .",CleanedCalendar where '" . $wsym ."' = CleanedCalendar.Symbol AND " . $wsym .".Close - LAG(" . $wsym .".Close) OVER (ORDER BY " . $wsym .".Date) AS difference FROM " . $wsym .""; I am trying to open two tables and populate a new field called difference. The query works until I add the AND portion of the statement. Is my formatting wrong or am I not allowed to do this? Print: select * from AMDA,CleanedCalendar where 'AMDA' = CleanedCalendar.Symbol AND AMDA.Close - LAG(AMDA.Close) OVER (ORDER BY AMDA.Date) AS difference FROM AMDA 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 'OVER (ORDER BY AMDA.Date) AS difference FROM AMDA' at line 1
  22. Hi everyone, Anyone recommended me to learn how to set up the login system, it is most advanced system, even longer work. Anyone know link to website that can help me learning about login system? Video will be very appreciate... Thanks, Gary
  23. This is my first oop php library and wanted to get advice on how I can improve what I wrote. This is what I needed to do: I'm also not sure on what it meant by "proportionally resize the shape up or down, given a floating-point scale factor" I think what I did might be right but I could be wrong. Also am I supposed to have a new class for each shape or is there a better solution? Any help is much appreciated. <?PHP echo "Circle (r=5) <br/>"; $circle = new circle(5); $circle->getArea(); $circle->getPerimiter(); $circle->scale(up, .5); echo "Scaled up .5<br/>"; $circle->getArea(); $circle->getPerimiter(); echo "<br/>Right Triangle (a=4, b=5) <br/>"; $rt = new RightTriangle(4, 5); $rt->getArea(); $rt->getPerimiter(); $rt->scale(down, .5); echo "Scaled down .5<br/>"; $rt->getArea(); $rt->getPerimiter(); echo "<br/>Equilateral Triangle <br/>"; $et = new EquilateralTriangle(6); $et->getArea(); $et->getPerimiter(); $et->scale(up, .; echo "Scaled Up .8<br/>"; $et->getArea(); $et->getPerimiter(); echo "<br/>Rectangle<br/>"; $r = new Rectangle(8, 7); $r->getArea(); $r->getPerimiter(); $r->scale(down, .; echo "Scaled Down .8<br/>"; $r->getArea(); $r->getPerimiter(); echo "<br/>Square<br/>"; $s = new Square(25); $s->getArea(); $s->getPerimiter(); $s->scale(up, 2.5); echo "Scaled Up 2.5<br/>"; $s->getArea(); $s->getPerimiter(); echo "<br/>Parallelogram<br/>"; $p = new Parallelogram(5.7, 6.; $p->getArea(); $p->getPerimiter(); $p->scale(up, 1); echo "Scaled Up 1<br/>"; $p->getArea(); $p->getPerimiter(); class Circle { public function __construct( $radius ) { $this->radius = $radius; } public function getArea() { echo number_format(pow($this->radius, 2) * M_PI, 2)."<br/>"; } public function getPerimiter() { echo number_format(2 * M_PI * $this->radius, 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->radius = $this->radius + ($this->radius * $scale); } else { $this->radius = $this->radius - ($this->radius * $scale); } } } class RightTriangle { public function __construct( $a, $b ) { $this->a = $a; $this->b = $b; } public function getArea() { echo number_format(($this->a*$this->b/2), 2)."<br/>"; } public function getPerimiter() { echo number_format($this->a + $this->b + sqrt(pow($this->a, 2) + pow($this->b, 2)), 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); $this->b = $this->b + ($this->b * $scale); } else { $this->a = $this->a - ($this->a * $scale); $this->b = $this->b + ($this->b * $scale); } } } class EquilateralTriangle { public function __construct( $a ) { $this->a = $a; } public function getArea() { echo number_format((sqrt(3)/4)*pow($this->a,2),2)."<br/>"; } public function getPerimiter() { echo number_format(3 * $this->a, 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); } else { $this->a = $this->a - ($this->a * $scale); } } } class Rectangle { public function __construct( $w, $l ) { $this->w = $w; $this->l = $l; } public function getArea() { echo number_format($this->w * $this->l,2)."<br/>"; } public function getPerimiter() { echo number_format(2 * ($this->w + $this->l), 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->w = $this->w + ($this->w * $scale); $this->l = $this->l + ($this->l * $scale); } else { $this->w = $this->w - ($this->w * $scale); $this->l = $this->l - ($this->l * $scale); } } } class Square { public function __construct( $a ) { $this->a = $a; } public function getArea() { echo number_format(pow($this->a,2),2)."<br/>"; } public function getPerimiter() { echo number_format(4 * $this->a, 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); } else { $this->a = $this->a - ($this->a * $scale); } } } class Parallelogram { public function __construct( $a, $b ) { $this->a = $a; $this->b = $b; $this->h = $a/$b; } public function getArea() { echo number_format($this->b * $this->h,2)."<br/>"; } public function getPerimiter() { echo number_format(2 * ($this->a + $this->b), 2)."<br/>"; } public function scale($direction, $scale) { if($direction == 'up') { $this->a = $this->a + ($this->a * $scale); $this->b = $this->b + ($this->b * $scale); } else { $this->a = $this->a - ($this->a * $scale); $this->b = $this->b - ($this->b * $scale); } } } ?>
  24. Hi guys am having difficulties getting lightbox effect to work in php.The images don't get the lightbox effect here is my code <!DOCTYPE html> <html> <head> <script type="text/javascript" src="lightbox.js"></script> <link rel="stylesheet" href="css/lightbox.css"> </head> <body> <?php $page = $_SERVER['PHP_SELF']; //settings $column =5; //dir $base ="data"; $thumbs ="thumbnails"; // get album $get_album =$_GET['album']; if(!$get_album){ echo "<b>Select an Album:</b><p/>"; $handle = opendir($base); while(($file = readdir($handle)) !==FALSE) { if(is_dir($base."/".$file) && $file != "." && $file != ".." && $file != $thumbs) { echo "<a href='$page?album=$file'>$file</a><br>"; } } closedir($handle); } else{ // check security if(!is_dir($base."/". $get_album) || strstr($get_album,".")!=NULL || strstr($get_album,"/")!=NULL || strstr($get_album,"\\")!=NULL) { echo "Album doesn't exist."; } else{ $x=0; echo "<b>$get_album</b><p/>"; $handle =opendir($base."/".$get_album); while(($file =readdir($handle)) !== FALSE) { if($file !="." && $file !="..") { echo "<table style='display:inline-block;'><tr><td><a href='$base/$get_album/$file' rel='lightbox'><img src='$base/$thumbs/$file' height='100' width='100'></a></td></tr></table><br/>"; $x++; if($x==$column){ echo "<br/>"; $x=0; } } } closedir($handle); } echo "<p/><a href='album.php'>Back to albums</a>"; } ?> </body> </html>
  25. Can I know from the professionals here, what is the best method to write this kind of logic? And also I would like to know is there other way to write this in a best way. Method 01: if ($emission <= 100 ) { $cssClass = "emission_a"; } elseif ($emission <= 120 ) { $cssClass = "emission_b"; } elseif ($emission <= 150 ) { $cssClass = "emission_c"; } elseif ($emission <= 165 ) { $cssClass = "emission_d"; } elseif ($emission <= 185 ) { $cssClass = "emission_e"; } else { $cssClass = "emission_g"; } Method 02: $mapping = array( 100 => 'emission_a', 120 => 'emission_b', 150 => 'emission_c', 165 => 'emission_d', 185 => 'emission_e', 225 => 'emission_f' ); $cssClass = 'emission_g'; // default class if $emission is > 225 foreach ($mapping as $limit => $class) { if ($emission <= $limit) { $cssClass = $class; break; } } Thank you.
×
×
  • 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.