Jump to content

Search the Community

Showing results for tags 'mysql'.



More search options

  • 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 (Dreamweaver, Zend, 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

Found 728 results

  1. Hi guys, Whats the best way of sending mails from multiple table? This is what i did, but i feel there should be a better way of doing it cos sometime it delivers and sometimes it doesn't (don't know why though). Thanks $subj="New Sign up Notification"; $header="MIME-Version: 1.0" . "\r\n"; $header .="Content-type:text/html;charset=UTF-8" . "\r\n"; $header .="From: GOODGUYS<noreply@yoyo.com>"; //TABLE 1 $t1 = "table1"; $stmt = $pdo->query(" SELECT t1_email, t1_name FROM $t1 "); while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ $t1_name = $rows['t1_name']; $t1_email = $rows['t1_email']; $t1_msg =" <html> <body> <h3>Subject: News</h3> <p> Hi $t1_name, <br> This is a message to you blah blah blah </p> <p> Thank you.<br> </p> </body> </html> "; mail($t1_email,$subj,$t1_msg,$header); } //TABLE 2 $t2 = "table2"; $stmt = $pdo->query(" SELECT t2_email, t2_name FROM $t2 "); while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ $t2_name = $rows['t2_name']; $t2_email = $rows['t2_email']; $t2_msg =" <html> <body> <h3>Subject: News</h3> <p> Hi $t2_name, <br> This is a message to you blah blah blah </p> <p> Thank you.<br> </p> </body> </html> "; mail($t2_email,$subj,$t2_msg,$header); } //TABLE 3 $t3 = "table3"; $stmt = $pdo->query(" SELECT t3_email, t3_name FROM $t3 "); while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ $t3_name = $rows['t3_name']; $t3_email = $rows['t3_email']; $t2_msg =" <html> <body> <h3>Subject: News</h3> <p> Hi $t3_name, <br> This is a message to you blah blah blah </p> <p> Thank you.<br> </p> </body> </html> "; mail($t3_email,$subj,$t3_msg,$header); }
  2. ttsprez

    Query Statement Help

    I'm having an issue with a query statement pulling info: This link carries customers to a "document gateway" where they are required to enter a reference code. https://pdforms.losttitleconnection.net/TX Title App Gate.php Use this Reference Code for test purpose: QKEX49MKDE On submit the PHP code is to take the reference code from the Post function of the gateway form and convert it to a variable $refcode This variable is then used in the query statement to pull 'name' and 'data' from the form_data table and use it to replace form field names with data in an html template. Then it is to present the new form in a pdf format to the browser for download or printing. I'm using the dompdf library to do this, but for now, am only using a short query test code to ensure I'm pulling the correct data by having the code display results. Currently, on submit, the browser is presenting the following: SELECT name,data FROM thetitl1_livesite754.form_data WHERE form_id IN(SELECT id FROM thetitl1_livesite754.forms WHERE reference_code = '') The following is the code as it appears in my PHP file. Help to get this figured out would be greatly appreciated. <?php //create a connection to MySQL require 'dogs.php'; //query for reference_code from 'forms' table $refcode = filter_input(INPUT_POST,'reference_code'); $mysqli = new mysqli($server, $username, $password, $dbase); $query = "SELECT name,data FROM thetitl1_livesite754.form_data WHERE form_id IN(SELECT id FROM thetitl1_livesite754.forms WHERE reference_code = '" . $refcode . "')"; die($query); $results = $mysqli->query($query); $new_form = file_get_contents("TX_Title_App.html"); //Replaces form_fields in html temp with "data" if ($results) { //below is the line referenced in error message above while ($row = mysqli_fetch_fields($results)) { echo $row["name"] . ":" . $row["data"] . "<br>"; $new_form = str_replace($row["name"], $row["data"], $new_form); } } ?>
  3. shan2batman

    notifications system not working

    Hi, guys i’m trying to create a notification alert for private message section in my project. The problem is everytime when the sender is sending message the notification bar shows new msg’s in sender profile and not in receivers profile. I don’t know where i’m going wrong so can any of you experts solve it. i’ll post the code here The private message page code: The db from where the queries are called from: CREATE TABLE IF NOT EXISTS `private_message` ( `pm_id` int(255) NOT NULL AUTO_INCREMENT, `r_seen` enum('0','1') NOT NULL, `receiver` varchar(255) NOT NULL, `sender` varchar(255) NOT NULL, `sent_time` datetime NOT NULL, `subject` varchar(255) NOT NULL, `message` text NOT NULL, `sdelete` enum('0','1') NOT NULL, `rdelete` enum('0','1') NOT NULL, `parent` varchar(255) NOT NULL, `has_replies` enum('0','1') NOT NULL, `rread` enum('0','1') NOT NULL, `sread` enum('0','1') NOT NULL, `receiver_uid` int(255) NOT NULL, `sender_uid` int(255) NOT NULL, `os_id` int(255) DEFAULT NULL, UNIQUE KEY `pm_id_2` (`pm_id`), KEY `pm_id` (`pm_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=95 ; The private message page code: <?php //error_reporting(0); include 'includes/header.php'; if (!isset($_SESSION['app'])) { header("location: index.php?usernotfound?id=017"); } $updateid=""; $title=""; $data=""; $sess_id=(int)$_SESSION['id']; $sess_uname = htmlentities($_SESSION['uname']); $session_uname = stripslashes($sess_uname); $f_uname0 = htmlentities($_GET['u']); $f_uname = stripslashes($f_uname0); $sql = "select * from user where uname=:uname and activated='1' limit 1"; $stmt = $conn->prepare($sql); $stmt->bindparam(":uname", $f_uname); $stmt->execute(); $row = $stmt->fetchAll(PDO::FETCH_ASSOC); $_SESSION['f_pm']=$f_uname; $f_uid=$row[0]['user_id']; $fname_s = $row[0]['fname']; $lname_s = $row[0]['lname']; $uname_s = $row[0]['uname']; $pmid= htmlentities($_GET['pmid']); if(isset($pmid)){ $updatedelete="update private_message set sread='1', r_seen='1' where pm_id=:pmid "; $stmt_r=$conn->prepare($updatedelete); //$stmt->bindValue(":originator",$originator); $stmt_r->bindValue(":pmid",$pmid); $stmt_r->execute(); } $is_friend=FALSE; $ownerblockviewer=FALSE; $viewerblockowner=FALSE; $isowner="no"; if($f_uid==(int)$_SESSION['id']&&isset($_SESSION['app'])){ $isowner="yes"; } if ($f_uname != $session_uname &&$_SESSION['app']==TRUE) { $freind_check = "select friend_id from friends where friend_one_uid=:session and friend_two_uid=:f_name and accepted='1' or friend_one_uid=:f_name and friend_two_uid=:session and accepted='1' limit 1"; $stmt = $conn->prepare($freind_check); $stmt->bindparam(":session", $sess_id); $stmt->bindparam(":f_name", $f_uid); $stmt->execute(); $isfriend=$stmt->rowCount(); if ($isfriend>0) { $is_friend = TRUE; } $blockcheck0 = "select blocked_id from blockedusers where blocker_uid=:f_name and blockee_uid=:session limit 1"; $stmt1 = $conn->prepare($blockcheck0); $stmt1->bindValue(":session", $sess_id); $stmt1->bindValue(":f_name", $f_uid); $stmt1->execute(); $owner= $stmt1->rowCount(); if ( $stmt1->rowCount()>0) { $ownerblockviewer = TRUE; } $blockcheck2 = "select blocked_id from blockedusers where blocker_uid=:session and blockee_uid=:f_name limit 1"; $stmt2 = $conn->prepare($blockcheck2); $stmt2->bindparam(":session", $sess_id); $stmt2->bindparam(":f_name", $f_uid); $stmt2->execute(); $viewer=$stmt2->rowCount(); if ($stmt2->rowCount() > 0) { $viewerblockowner = TRUE; } } $pm_ui=""; ?> <div class="container-fluid"> <br><div class="row"> </div><br> <div class="row"> <div class="col-sm-2 col-md-3 col-xs-4"> <div class="friend_pm"> <?php include 'notification/friend_pm.php'; ?> </div> </div> <div class="col-lg-8 col-xs-8 col-md-9"> <?php #if visitor to profile is friend and is not the owner, can send private message. #build ui carry the profile id, visitorname,pm subject and comments. if($is_friend==TRUE && $isowner=="no"){ $sql1="select * from private_message where(receiver=:u and sender=:sess and rdelete='0') " . "or " . "(sender=:u and receiver=:sess and sdelete='0' ) order by sent_time desc "; $stmt1=$conn->prepare($sql1); $stmt1->bindValue(":u",$f_uname); $stmt1->bindValue(":sess",$_SESSION['uname']); $stmt1->execute(); $fetch=$stmt1->fetchAll(PDO::FETCH_ASSOC); foreach ( $fetch as $row1) $pmid=$row1['pm_id']; $pm_ui='<hr><br><br>' . '<a class="btn mark-all mark_all_as_read" value="mark_all" originator="'. htmlentities($_SESSION['uname']).'" id="'.$pmid.'">Mark All as read</a><br>' . '<textarea id="pmtext" class="pm_message input-custom2" placeholder="Send a message"></textarea>' . '<br>' . '<button class="btn btn-warning pm_btn" attr="'.$row1['sender'].'" id="'.$f_uname.'" value="'.$pmid.'" type="new_pm" name="'.$session_uname.'">' . 'Send</button>'; } ?> <div id="status_ui"> <?php echo "<br><br><br><br><br><br><div class='jumbotron scroll-custom'>" . "<div class='pm_post'>"; include "notification/pm_inbox.php"; echo "</div></div>"; ?> <?php if($is_friend==TRUE&& $isowner=="no"){ echo $pm_ui; } ?> </div> <div class="col-sm-2 hidden-xs hidden-md"> </div> </div> </div> <script type="text/javascript"> var spinner="<img src='img/spinner.gif'>"; $(".pm_btn").click(function(){ var f_uname=$(this).attr('id'); var action=$(this).attr('type'); var s_uname=$(this).attr('name'); var pm_message=$(".pm_message").val(); var os_id=$(this).attr("value"); if(pm_message==""){alert("Please write something to send"); }else{ $.post("parser/pm_system.php", {"f_uname":f_uname,"action":action,"sess_uname":s_uname,"pm_message":pm_message,"os_id":os_id}, function(data){ $(".pm_message").val(""); // alert(data); // $(".jumbotron").prepend("<small>Reply from:-"+s_uname+" right now </small><br><p>"+pm_message+"</p>"); //lets the script scroll down to the bottom of the chat class automatically $(".scroll-custom").scrollTop($(".scroll-custom")[0].scrollHeight); });} }); $(".mark_as_read").click(function(){ var action=$(this).attr("value"); var id=$(this).attr("id"); var originator=$(this).attr("originator"); $.post("parser/pm_system.php", {"action":action,"pmid":id,"originator":originator}, function(data){ alert(data); }); }); $(".mark-all").click(function(){ var action=$(this).attr("value"); var id=$(this).attr("id"); var originator=$(this).attr("originator"); //alert(action+""+id+""+); $.post("parser/pm_system.php", {"action":action,"pmid":id,"originator":originator}, function(data){ alert(data); }); }); //logic for search box $(".search").keyup(function(){ var input=$(".search").val(); var length=input.length; $("#result").html(spinner).show(); var check=$(".checkbox-search").prop('checked'); if(check!=true){ $.post("search.php",({"(un|fn|ln)":input}),function(result){ $("#result").html(result).show(); }); }else if(check==true){ var input=$(".search").val(); $("#result").html(spinner).show(); $.post("search_group.php",({"group_name":input}),function(result){ $("#result").html(result).show(); }); } }); $(document).click(function(){ $("#result").hide(); }); function load_stuff(){ $(".pm_post").load("notification/pm_inbox.php"); } //loads friends who have sent messages function load_names(){ $(".friend_pm").load("notification/friend_pm.php"); } setInterval(function(){ load_stuff(); load_names(); },3000); $(document).click(function(){ $("#result").hide(); }); $("button.friend-add-btn").click(function(){ var id=$(this).attr('id'); var name=$(this).attr('name'); $(".spinner-friend-add"+id).html(spinner).show(); $.post( "parser/friend_sys.php", ({"user": name,"friend_one_uid":id}), function (data) { alert(data); $(".spinner-friend-add"+id).html(spinner).hide(); $(".friend_fade_"+id).fadeOut(); } ); }); $('[data-toggle="popover"]').popover(); //logic to accept fried request $(document).on("click", "button.accept_btn" ,function(){ var accept_id=$(this).attr('id'); var sess=$(this).attr('sess'); var name=$(this).attr('name'); $(".show-spinner").html(spinner).show(); $.post("notification/friend_req_accept.php",({"reqid":accept_id,"friend_two_uid":sess,"friend_two":name}),function(data){ $(".show-spinner").hide(); alert(data); }); }); //logic to reject friend request $(document).on("click", "button.reject_btn" ,function(){ var accept_id=$(this).attr('id'); $(".show-spinner").html(spinner).show(); $.post("notification/friend_req_reject.php",({"reqid":accept_id}),function(data){ $(".show-spinner").hide(); alert(data); }); }); //logic for sending friend requests // $("button.friend_btn").click(function () { $(document).on("click", "button.friend_btn",function(){ alert("see"); $(".friend").html(spinner).show(); var user_f = $(this).attr('user'); var id = $(this).attr('sess'); var name=$(this).attr('name'); $.post( "parser/friend_sys.php", ({"user": user_f,"friend_one_uid":id}), function (data) { alert(data); $(".friend").html(spinner).hide(); } ); //$(".friend").html(spinner).fadeOut(250); }); //logic to like this person button. $(document).on("click", "button.like_person_btn",function(){ $(".friend").html(spinner).show(); var user_f = $(this).attr('user'); var userid=$(this).attr('userid'); var id = $(this).attr('sess'); var name=$(this).attr('name'); $.post( "parser/like_this_person_parser.php", ({"user": user_f,"like_person_one_uid":id,"like_person_two_uid":userid}), function (data) { alert(data); $(".friend").html(spinner).hide(); } ); //$(".friend").html(spinner).fadeOut(250); }); //logic for blocking friends $(document).on("click", "button.block_btn",function(){ $(".show-spinner").html(spinner).show(); var user_f = $(this).attr('user'); $.post( "parser/block_system.php", ({"user": user_f}), function (data) { alert(data); } ); $(".show-spinner").html(spinner).fadeOut(250); }); $(document).on("click", "button.unfreind_btn",function(){ $(".show-spinner").html(spinner).show(); var user_f = $(this).attr('user'); $.post( "parser/unfriend_sys.php", {"user": user_f}, function (data) { alert(data); } ); $(".show-spinner").html(spinner).fadeOut(250); }); //logic for unblocking users whom were blocked $(document).on("click", "button.unblock_btn",function(){ $(".show-spinner").html(spinner).show(); var user_f = $(this).attr('user'); $.post( "parser/unblock_sys.php", ({"user": user_f}), function (data) { alert("You have unblocked this user"); $("button.unblock_btn").hide(); $("button.block_btn").show(); } ); $(".show-spinner").html(spinner).fadeOut(250); }); //to load notifications dynamically i used the set interval method. function load_notifications(thisview=''){ var theData = { view: thisview } $.ajax({ url: "notification/new_friends.php", method: "POST", data:theData, dataType:"json", success: function(data){ // alert(data); $(".drop-menu").html(data.notification); if(data.unseen_notification>0){ $(".badge1").html(data.unseen_notification); }else{ //alert(data); $(".drop-menu").html("No Notifications"); $(".badge1").html(data.unseen_notification);} } }); }; function notification(thisview=''){ var theData= { view: thisview } $.ajax({ url:"notification/ajax_notifications.php", method: "POST", data:theData, dataType: "json", success: function(data){ $(".notify-menu").html(data.notifications); if(data.unseen_notifications>0){ $(".badge3").html(data.unseen_notifications); } } }); } function notification_pm(thisview=''){ var theData= { view: thisview } var f_uname=$(".badge_pm").attr("type"); var sender=$(".badge_pm").attr("attr"); var sess=$(".badge_pm").attr("name"); var rcvr =$(".badge_pm").attr("id"); $.ajax({ url:"notification/ajax-pm-notification.php", method: "POST", data:{"theData":theData, "f_uname": f_uname}, dataType: "html", success: function(data){ if(data>0){ // alert(data); $(".badge_pm").html("New Msg's"); }else{ // alert(data); $(".badge_pm").html("No Msg's"); } } }); } //clicking on notification icon in header does this $(document).on("click", ".count_notification", function(){ var id=''; $.post("notification/count_notifications.php", {id:id}, function(data){ }); }); //load_notifications(); $(document).on("click",".count_friend", function(){ load_notifications('yes'); }); //loads every 2 seconds for chat setInterval(function(){ load_notifications(); notification(); notification_pm(); },5000); </script> </body> </html> the ajax notification page: <?php include '../includes/dbconfig.inc.php'; $f_uname= htmlentities($_POST['f_uname']); $mark="select parent,r_seen,rread,sread,receiver,sender from private_message where (receiver=:sess1 or sender=:sess2) and (r_seen='1' or r_seen='0') and (sread='1' or sread='0')"; $stmt_m=$conn->prepare($mark); $stmt_m->bindValue(":sess1", $_SESSION['uname']); $stmt_m->bindValue(":sess2", $_SESSION['uname']); //$stmt_m->bindValue(":f_uname", $f_uname); $stmt_m->execute(); $column=$stmt_m->fetch(); if ($column['r_seen']=='0'&&$column['parent']==$_SESSION['uname']) { echo'1'; // print_r($column); } elseif ($column['r_seen']=='1'&&$column['parent']==$_SESSION['uname']) { echo '0'; // echo 'old'; }elseif ($column['r_seen']=='0'&&$column['parent']!=$_SESSION['uname']) { echo '1'; //echo'new'; }elseif ($column['r_seen']=='1'&&$column['parent']!=$_SESSION['uname']) { echo '0'; // echo'new11'; } else { echo '0'; //print_r($f_uname); } logic for notifications in header: $mark="select rread,sread,receiver,sender from private_message where (receiver=:sess or sender=:sess) and has_replies='1' and rread='1' and sread='0'"; $stmt_m=$conn->prepare($mark); $stmt_m->bindValue(":sess", $_SESSION['uname']); //$stmt_m->bindValue(":f_uname", $f_uname); $stmt_m->execute(); $column=$stmt_m->fetch(); if($column['receiver']==$_SESSION['uname']&&$column['rread']>0&&$column['sread']==0) { if ($column['sender']!=$_SESSION['uname']) { print_r($column); $pm_n="<span class='badge_pm label label-pill label-success' type='".$f_uname."'>New Msg's</span><a href='private_message.php?u=".$_SESSION['uname']."'><img src='img/logo/message-white.png' alt='private_message'></a>"; } else { $pm_n="<span class='badge_pm label label-pill label-success' type='".$f_uname."'></span><a href='private_message.php?u=".$_SESSION['uname']."'><img src='img/logo/message-black.png' alt='private_message_alert'></a>"; } }elseif ($column['sender']==$_SESSION['uname']&&$column['rread']==1&&$column['sread']==0) { if ($column['receiver']!=$_SESSION['uname']) { $pm_n="<span class='badge_pm label label-pill label-success' type='".$f_uname."'></span><a href='private_message.php?u=".$_SESSION['uname']."'><img src='img/logo/message-black.png' alt='private_message_alert'></a>"; } else { print_r($f_uname); $pm_n="<span class='badge_pm label label-pill label-success' type='".$f_uname."'>New Msg's</span><a href='private_message.php?u=".$_SESSION['uname']."'><img src='img/logo/message-white.png' alt='private_message'></a>"; } }else { $pm_n="<span class='badge_pm label label-pill label-success' type='".$f_uname."'></span><a href='private_message.php?u=".$_SESSION['uname']."'><img src='img/logo/message-black.png' alt='private_message_alert'></a>"; }
  4. I'm working with a relationship table: id (AI), user_id, friend_id, status, type. The current behavior is that the Logged In user can send friendship requests to X user but if there is already a friendship request coming from the X user to the Logged In user; the logged in user instead of sending a new request to X user, he/she should accept the one that is already in the database(which is coming from the X-user). Here is an image of what I'm talking about(in the image, the status column displays 'accepted' but try to imagine it as it was 'pending', please) : So I currently have a function for adding friends for the current Logged-In user and it goes like this: public function follow($username){ // Check Login if(!$this->session->userdata('user_id')){ // Redirect to page redirect('users/login'); } // Get item $item = $this->User_model->get_username($username); // Already friends? $friendship = $this->User_model->the_relationship($item->id); if ($friendship->status == 'accepted' || $friendship->status == 'pending') { // Create Message $this->session->set_flashdata('error', 'You are already following this user.'); // Redirect to pages redirect('users/profile/'.$item->username); // BEGINNING OF - HERE IS WHERE THE PROBLEM IS } elseif($friendship->status == 'pending'){ // Get item $item = $this->User_model->get_username($username); // Page Data $data = array( 'user_id' => $item->id, 'friend_id' => $this->session->userdata('user_id'), 'status' => 'accepted', ); $this->User_model->updateFriendship($item->id, $data); /// END OF - HERE IS WHERE THE PROBLEM IS } else { // Get item $item = $this->User_model->get_username($username); // Page Data $data = array( 'user_id' => $this->session->userdata('user_id'), 'friend_id' => $item->id, 'status' => 'pending', 'type' => 'friendship', ); $this->Relationship_model->add($data); // Activity Array $data = array( 'resource_id' => $this->db->insert_id(), 'type' => 'friendship', 'action' => 'sent', 'user_id' => $this->session->userdata('user_id'), 'message' => '(' . $this->session->userdata('username') . ') sent a friend request to ('.$item->username.') ', ); // Insert Activity $this->Activity_model->add($data); // Set Message $this->session->set_flashdata('success', 'Friend request has been sent'); // Redirect redirect('users/profile/'.$item->username); } } and here are the two functions in the model which check the current status of the relationship between the current logged in user and the X user; the second function should update the status of the friendship if there is already one: LEGEND: $this->relationship: ci_relationship table $this->type: friendship type // Relationship for single public function the_relationship($id){ $this->db->select('*'); $this->db->from($this->relationship); $this->db->where('user_id', $this->session->userdata('user_id')); $this->db->where('friend_id', $id); $this->db->where('type', $this->type); $query = $this->db->get(); if($query->num_rows() >= 1){ return $query->row(); } else { return false; } } // Update Friendship Status public function updateFriendship($id, $data){ $this->db->where('user_id', $id); $this->db->where('friend_id', $this->session->userdata('user_id')); //$this->db->where('status', 'pending'); $this->db->where('type', $this->type); $this->db->update($this->relationship, $data); } I hope I could make myself clear. Thanks in advance.
  5. Hi I have a table that is filled with values already and now i want to add another column associate_id How can i update the columns with a random number? What i have is giving all the columns same number thanks $associates_id = mt_rand(10000, 99999); $stmt = $pdo->prepare("UPDATE associates SET associates_id= $associates_id "); $stmt->execute(); $affected_rows = $stmt->rowCount(); if ($affected_rows){ echo "DONE"; }else{ echo "NOT DONE"; }
  6. Hi all ! The following query gave no error earlier in version 5.6 SELECT mr.xid, fd.fname, fd.lname, fd.cell, fd.email, a.country_id, a.state_id, a.city_id, a.pin_id, sd.center_No, count(sd.fid) total, sum(case when sd.member_center_status='R' then 1 else 0 end) Acticount FROM master_recruitment as mr JOIN user_details as fd ON fd.user_id = mr.xid JOIN addresses as a ON a.fid = mr.xid JOIN member_details as sd ON sd.fid = mr.xid WHERE mr.mid = 6 GROUP by sd.fid, sd.center_No LIMIT 1, 10; gives the error : Expression #6 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mytestdb.a.country_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by; in version 5.7 of mysql. I have googled but could not really understand the reason the problem is occuring. Please help Thanks.
  7. Hi there. I got a table named `area` that has a POLYGON field. There are some rows with specified area in table. Now i want to check if a point ("59.5594597, 36.3556769" for example) is within the polygons or not. searched a lot and none works. my polygon has 102 points in case of need. Thanks.
  8. talmik

    Code for Year Count

    Hello all This bit of code is supposed to count the number of years between a creation date and the current date then place that number of years in the database. I seem to be missing something or have done something wrong. Can anyone see where it all went wrong?
  9. Hi All, I have 4 tables each with only 2 columns (except for one that has 3) and they all have in common a date/time field. I am trying to export all 4 tables together as one CSV file and to have the records matched together where they have the same date/time. My tables are structured like so (which originally came from 4 individual CSV files): So as an exported CSV I would want the matching records (based on the date/time) to be part of the same record like so: Time, heartrateValue, Intensity, minutesleepValue, minutesleepLogId, steps 3/01/2018 0:01, 45, 0, 1, 17396451215, 0 3/01/2018 0:02, 45, 0, 1, 17396451215, 0 etc. A secondary issue is changing the date format to D/MM/YYYY from M/DD/YYYY. However, if I can get this CSV file export I can probably just loop through it in PHP and fix up the date format. Thank you kindly for your assistance
  10. I have a table full of mac addresses in this format 80828704B0EE I need a method to run a query that will output this format 80:82:87:04:B0:EE I either need to insert the result of the some query that is formatting the existing mac addresses to another field or use a query to format the mac addresses on the fly. I need to create a csv file from this query. I have all that code it is just making the query to format it the way I need it. Here is a query I found that does the trick except that I get two columns, the original and the formatted one. How can I remove the mac column that this outputs? SELECT mac, concat(left(mac,2), ":",substring(mac,3,2), ":" , substring(mac,5,2), ":",substring(mac,7,2), ":",substring(mac,9,2), ":", right(mac,2)) as mac_formatted FROM phones Thanks
  11. I have a page that I use to scan (with a barcode scanner) a series of barcodes for mac addresses. The page is this code <form action="insert.php" method="post" id="phoneEntry"> <fieldset> <legend><h3>Phone MAC Entry:</h3></legend> <label for="phoneEntry_dealerName">Select Dealer</label> <select name="id" id="phoneEntry_dealerName">'; while ($dealer = $dealers->fetch_assoc()) echo ' <option value="', $dealer['id'], '">', $dealer['dealername'], '</option>'; echo ' </select> <label for="macEntry_hostedLocation">Enter the Location IP:</label> <input type="text" name="location"><br> <label for="macEntry_address">Input the MAC address:</label> <textarea name="mac" id="macEntry_address"> </textarea> <button>Save</button> </fieldset> </form>'; I scan into the text area and the MAC is much like this : 80828704B0EE I scanned in 14 different barcodes and in the database they were all shortened on the back bu 4 digits. Here is the insert.php code: Scanning the same barcode it is formatted and of the correct length in notepad+ $dealerid= "$_POST[id]"; $location= "$_POST[location]"; include('/var/www/html/hosted/index.html'); require('/var/www/html/hosted/utils/connect.php'); $stmt1 = $link->prepare(' INSERT INTO phones ( dealerid, location, mac ) VALUES ( ?, ?, ? ) '); $macList = preg_split('/[\s,]+/', $_POST['mac']); $stmt1->bind_param('iss', $dealerid, $location, $mac); foreach ($macList as $mac) $stmt1->execute(); So I am thinking that the issue is somewhere in the preg_split but I don't see it. I also need to save the same MAC address into the same table (different field) in this format 80:82:87:04:B0:EE I need to eventually run a report on both formats of each MAC entry. Thanks for any insight anyone might be able to give.
  12. I-AM-OBODO

    PHP Gallery

    Hi all, I don't know if there's a gallery for this already or the right place to ask the question. User uploads multiple images. Images are store in a different folder and a unique name stored on the database. All images have a unique group for referencing purpose . When a user clicks on a link in his table he can view all images pertaining to a group. How can i go about that? What i want to achieve is for example SELECT ALL FROM IMAGE_TABLE WHERE USERNAME = USERNAME AND GROUP_ID = GROUP_ID Thanks
  13. EmmanuelCorrea

    Resource id#51

    Good day community. With a doubt that I could not find a solution. I'm trying to log in, I have my user and my password registered (so the user does exist), but at the time of entering, he only sends me a Resource id # 51, I clarify that this is under a server, I have my bd too hosted on host, all right. Also, I do this function in localhost and I login correctly. I came across this "error" or result already when it was on the host of the server to which I do not know what is due. This is my code. $sql = sprintf("SELECT * FROM usuario WHERE usuario = '%s' AND contrasena = '%s' ", mysql_real_escape_string($usuario), mysql_real_escape_string($contrasena)); $query=mysql_query($sql); //echo mysql_errno().":".mysql_error(); echo $query; $verificar=mysql_num_rows($query); echo $verificar; if($verificar==1){ //El logueo es exitoso y se crea la sesion if($valores = mysql_fetch_assoc($query)){ if($valores['puesto'] == 'A'){ $_SESSION['usuario'] = $usuario; //header("HTTP/1.1 302 Moved Temporarily"); //header("Location: ../indexMenu.php"); }else if($valores['puesto'] == 'B'){ $_SESSION['alumno'] = $usuario; header("HTTP/1.1 302 Moved Temporarily"); header("Location: ../../../alumnos/php/indexMenu.php"); } }else{ echo 'No se ha podido iniciar sesion, por favor vuelva a intentarlo.'; }
  14. EmmanuelCorrea

    Resource id #51

    Buen día comunidad. Con una duda que no he podido encontrar una solución. Estoy intentando hacer un logueo, tengo mi usuario y mi contraseña dada de alta (osea que el usuario si existe), pero al momento de ingresar solamente me manda un Resource id #51, aclaro que esto es bajo un servidor, tengo mi bd tambien alojada en host, todo correcto. También que hago esta función en localhost y me hace el login correctamente. Me tope con este "error" o resultado ya cuando se encontraba en el host del servidor a lo cual no se a que se deba. Este es mi código. $sql = sprintf("SELECT * FROM usuario WHERE usuario = '%s' AND contrasena = '%s' ", mysql_real_escape_string($usuario), mysql_real_escape_string($contrasena)); $query=mysql_query($sql); //echo mysql_errno().":".mysql_error(); echo $query; $verificar=mysql_num_rows($query); echo $verificar; if($verificar==1){ //El logueo es exitoso y se crea la sesion if($valores = mysql_fetch_assoc($query)){ if($valores['puesto'] == 'A'){ $_SESSION['usuario'] = $usuario; //header("HTTP/1.1 302 Moved Temporarily"); //header("Location: ../indexMenu.php"); }else if($valores['puesto'] == 'B'){ $_SESSION['alumno'] = $usuario; header("HTTP/1.1 302 Moved Temporarily"); header("Location: ../../../alumnos/php/indexMenu.php"); } }else{ echo 'No se ha podido iniciar sesion, por favor vuelva a intentarlo.'; } Espero puedan ayudarme, ya que es mi proyecto de Titulación!
  15. I have a mySQL database with some of the tables and fields being: CLIENT - clientid, client MATTERS - matterid, clientid, refno, nickname MATTERJUNACTIONS - matterid, notes, fee, actiondate EXPENSES - expensid, matterid, expensedate, amount A client can have many matters and each matter can have many actions and a number of expenses. I want to produce a report which has a separate row for each action or expense together with matter and client details. The report column headers would be: clientid | client | refno | nickname | actiondate | note | fee | expensedate | amount | I have a query: SELECT client.clientid, client.client, matters.refno, matters.nickname, matterjuncactions. actiondate, matterjuncactions.notes, matterjuncactions.fee FROM client INNER JOIN matters ON client.clientid=matters.clientid LEFT JOIN matterjuncactions ON matters.matterid=matterjuncactions.matterid LEFT JOIN expenses ON matters.matterid=expenses.matterid WHERE client.clientid = 238 This produces a report with a number of rows but doesn't separate the rows with expenses on a different row to the actions. I get something like: 238 | ABC Ltd | 1245 | matternickname | 2018/4/1 | this is the action note | 50 | 2018/4/15 | 25 | Rather than 238 | ABC Ltd | 1245 | matternickname | 2018/4/1 | this is the action note | | | | 238 | ABC Ltd | 1245 | matternickname | | | 50 | 2018/4/15 | 25 | What am I doing wrong?
  16. So, I currently have a script (in beta mode, only works when the sun shines), that can upload an image and store directly in a mysql database (using the BLOB data type); the script is also able to retrieve the BLOB data and display them vertically on the page; I actually need to dsiplay them horizontally across the page instead. So currently the retrieved images are printed in this format: 1 2 3 4 5 6 7 8 and I need it to print this way: 1 2 3 4 5 6 7 8 sounds like a for loop somewhere... any takers on how to implement the feature?
  17. Landslyde

    MySQL Create Database Failing

    After all the fields have been confirmed on my Registration Form, just before the confirmation email is sent out to the user, I have this code to create a MySQL db from their unique username: require_once 'login.php'; echo $uname; try{ $stmt = $db->prepare("CREATE DATABASE IF NOT EXISTS :dbname"); $stmt->bindValue(':dbname', $uname, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $ex){ echo 'Error creating database: '.$ex; } My apache error log is clear. Same for MySQL eorror log. No errors reported. I have even commented out the bindValue $stmt and put a name in place of :dbname in the prepare $stmt, but I still get nothing. Anyone see what I'm doing wrong?
  18. I'm currently making use of arrays to modify my font colors in my chat script for example $admin = array('m70141099002' , 'Debater', '27765238453', ''); $moderator = array('m52626156002', 'm57010835002' , 'm50079252002', '27723289551', 'm38565659002'); $testip = $_SERVER["HTTP_X_MXIT_USERID_R"]; if(!isset($name)) { $name = "Debater"; } if(!isset($testip)) { $testip = "Debater"; } ////////////////This is for Admin Permission Users////////////// if (in_array($testip, $admin)) { if (in_array($list['StringyChat_ip'], $admin)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . $form . ' ' . '</span>'. '<span style="color:red">' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords(wordwrap($list['StringyChat_message'], $line_length,"<br>\n")) . '</span>' . '<span style="color:#d8d8d8">' . " - " . $ipi . '</span>' . '<br />'; } elseif (in_array($list['StringyChat_ip'], $moderator)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . $form . ' ' . '<span style="color:green">' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords(wordwrap($list['StringyChat_message'], $line_length,"<br>\n")) . '</span>' . '<span style="color:#d8d8d8">' . " - " . $ipi . '</span>' . '<br />'; } elseif (in_array($list['StringyChat_ip'], $pc)) { print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . $form . ' ' . '<span style="color:purple">' . '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords(wordwrap($list['StringyChat_message'], $line_length,"<br>\n")) . '</span>' . '<span style="color:#d8d8d8">' . " - " . $ipi . '</span>' . '<br />'; } elseif (in_array($list['StringyChat_ip'], $helper)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . $form . ' ' . '<span style="color:blue">' . '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords(wordwrap($list['StringyChat_message'], $line_length,"<br>\n")) . '</span>' . '<span style="color:#d8d8d8">' . " - " . $ipi . '</span>' . '<br />'; } elseif (in_array($list['StringyChat_ip'], $globalhelper)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . $form . ' ' . '<span style="color:blue">' . '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords(wordwrap($list['StringyChat_message'], $line_length,"<br>\n")) . '</span>' . '<span style="color:#d8d8d8">' . " - " . $ipi . '</span>' . '<br />'; } else { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . $form . ' ' . '<span style="color:#0365B8">' . '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords(wordwrap($list['StringyChat_message'], $line_length,"<br>\n")) . '<span style="color:#d8d8d8">' . " - " . $ipi . '</span>' . '<br />'; } } This printout will show all the users matching the testip within the admin array, I got the same printout for moderators as well. Well the real problem I'm experiencing right now is to use my database to calculate the color it should display. I got 3 tables at this stage Table 1: Users2 Layout ID, Username, mxitid, nick, phone and rank This table is where I store the usernames of people if they register and give them the rank value of 6 Table 2: ranks_colors Layout Type, rank, color1, color2, color3, color4 Admin, 1, red, blue, orange, purple Mod, 2, green, pink, yellow, black etc... upto 6 wich is Normal This table is where I specify Type like Administrator rank 1 and 4 colors he can use within hes text printout Table 3: StringyChat Layout id, ip, name, message, time, device, rank This is basically where the messages that is being send will be stored each in its own row with the specified rank number. The problem I'm currently struggling with is the ranks I want each rank type font to be different for example in the above Table 2. If admin all the messages send by admin must be red. All the mod messages must be green etc. How can I change from the array way to mysql by using the ranks system?
  19. 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());
  20. I have a problem . I 've been trying for a long time to make an update for php mysql to change the data. but every time I do not manage to make it work with a form. but it works if I only if I put this ($ sql = "UPDATE users SET username = 'value' WHERE id = 10 " ; ) so it only works when I put the value of the id. but I want in an html form to indicate what I want to change and what id goes. but I have tried so long that I do not feel like I so want someone help me. make the same database and same as my records and make the code and test it if it works show me please my database name : web test my table called : users my records are called : id int ( 11) AUTO_INNCREMENT username , varchar ( 255 ) password , varchar ( 255 ) first_name , varchar ( 255 ) last_name , varchar ( 255 ) email, varchar ( 255 ) Age, int ( 11) Look, my update.php is like this now <?php $servername = "localhost"; $username = "root"; $password = "....."; $dbname = "webtest"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE users SET password='cotton candy' WHERE id=10"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?> but now i have still have to go into the php file to change the valeu or the id but i looked on site and youtube how to put it in a simple html form but it still does not work. i want it in a html from. I want that when I enter the ID that the data of the user appears and that I can change any valeu separately. please help me out!!
  21. Hi everyone, I'm trying to get my head around blending in and out of php and html. I've seen some simple examples which work great but now I have this variable that comes from the database and I would like to style the variable in-line with html markup. Here's what I'm trying to do: <?php echo "Price : ",'<Font size="100"> $tournament["pricePerPlayer"] </font>'; ....more of the same code goes here... ?> I can't get $tournament["pricePerPlayer"] to be controlled by the font tag. How do I do this? Any help would be greatly appreciated. Thanks,
  22. shaddf

    making unique keys in mysql

    I have this table: CREATE TABLE _HRatortbl ( Hor_id INT unsigned NOT NULL auto_increment, Hicator_title longtext NOT NULL, Primary KEY(HRindicator_id), UNIQUE KEY ix_length_HRindicator_title (HRindicator_title(255)) )ENGINE=InnoDB DEFAULT CHARSET=utf8 why is it that it cannot differentiate between: Legally stipulated Age for marriage and legally stipulated age for mariage I found them both iniside the table .Is there another way to do this on text fields
  23. Sfrius

    php and mysql

    Hey, I'm trying to build a simple form with post back that is using a mysql database. I wanted to do a sticky post but the main file includes db creation commands. So I setup a process file to show the table I created and show the form below it so that I can keep adding additional records to the table. I'm currently running php v5.2.6. Posting code: Notice how I made an insert string with $tmpvariables, does this work? I would think that it should. My main problem came about when I tried to store the $_POST variables in temporary variables and then use an insert string as it is shown in the following code. Any help is welcome and any additional comments are appreciated. Thank you. <?php $dbName = "airline"; $DBConnect = mysql_connect("127.0.0.1", "******", "*********************"); $createTable = "CREATE TABLE `surveys` ( `f_date` VARCHAR( 30 ) NOT NULL , `f_time` VARCHAR( 30 ) NOT NULL , `f_number` VARCHAR( 30 ) NOT NULL , `f_destination` VARCHAR( 30 ) NOT NULL , `f_friend` VARCHAR( 30 ) NOT NULL , `f_space` VARCHAR( 30 ) NOT NULL , `f_comfort` VARCHAR( 30 ) NOT NULL , `f_clean` VARCHAR( 30 ) NOT NULL , `f_noise` VARCHAR( 50 ) NOT NULL );"; if($DBConnect == FALSE){ echo "<p>Connection Error: " . mysql_error() . "</p>\n"; }else { echo "<p>Connection Successful.</p>"; $dropDB = "DROP DATABASE $dbName"; $noDB = mysql_query($dropDB); $newDB = "CREATE DATABASE $dbName"; $newResults = mysql_query($newDB); if($newResults == FALSE){ echo "<p>Could not create the database. You don't have the required permissions or the database already exists." . mysql_error($DBConnect) . "</p>"; } else{ echo "<p>The database was created successfully.</p>"; if (mysql_select_db ("$dbName",$DBConnect) === FALSE){ echo "<p>Could not select the database ", $dbName, ".", mysql_error($DBConnect), "</p>"; } else{ echo "<p>The ", $dbName, " database has been selected."; $QueryResult = mysql_query($createTable, $DBConnect); if($QueryResult === FALSE) echo "<p>There was an error or the table already exists in the database</p>"; else{ echo "<p>The table was created now to insert some data</p>"; echo "<h2>Survey</h2>"; echo "<FORM action=\"Surveyprocess.php\" method=\"post\">"; echo "<P>"; echo "Flight Time: <INPUT type=\"text\" name=\"f_time\"><BR>"; echo "Flight Date: <INPUT type=\"text\" name=\"f_date\"><BR>"; echo "Flight Number: <INPUT type=\"text\" name=\"f_number\"><BR>"; echo "Destination: <INPUT type=\"text\" name=\"f_destination\"><BR>"; echo "<p>How would you rate the friendliness of the staff?</p>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the storage space on the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the comfort on the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the cleanliness of the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the noise level on the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Excellent\"> Excellent<BR>"; echo "<INPUT type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">"; echo "</P>"; echo "</FORM>"; // if(isset($_POST['Send'])){ // $tmpVar1 = $_POST['f_time']; //$tmpVar2 = $_POST['f_date']; // $tmpVar3 = $_POST['f_number']; // $tmpVar4 = $_POST['f_destination']; // $tmpVar5 = $_POST['f_friend']; // $tmpVar6 = $_POST['f_space']; // $tmpVar7 = $_POST['f_comfort']; // $tmpVar8 = $_POST['f_clean']; // $tmpVar9 = $_POST['f_noise']; // $insert = "INSERT INTO `airline`.`surveys` ( // `f_date` , //`f_time` , //`f_number` , //`f_destination` , //`f_friend` , //`f_space` , //`f_comfort` , //`f_clean` , //`f_noise` //) //VALUES ($tmpVar1, $tmpVar2, $tmpVar3, $tmpVar4, $tmpVar5, $tmpVar6, $tmpVar7, $tmpVar8, $tmpVar9);"; //$insertQuery = mysql_query($insert, $DBConnect); // if($insertQuery === FALSE){ // echo "<p>Survey failed to save to the database.</p>"; // } //else{ // echo "<p>Survey Complete!</p>"; // } // $SQLSelect = "SELECT * FROM surveys"; // $QueryResult = mysql_query($SQLSelect, $DBConnect); // echo "<table width='100' border='1'>\n"; // echo "<tr><th>Flight Date</th><th>Flight Time</th><th>Flight //Number</th><th>Destination</th><th>Friendliness</th><th>Storage Space</th><th>Comfort</th><th>Cleanliness</th><th>Noise</th></tr>\n"; // while (($Row = mysql_fetch_row($QueryResult)) !== FALSE) { //count $row array //for loop to iterate rows // echo "<tr><td>{$Row[0]}</td>"; // echo "<td>{$Row[1]}</td>"; // echo "<td>{$Row[2]}</td>"; // echo "<td align='right'>{$Row[3]}</td>"; // echo "<td>{$Row[4]}</td></tr>"; // } // echo "</table>\n"; //Sorry for this mess. was trying to post into the middle of my code thinking it would work. If I set it up to start with isset, it would be false initially //The database would create, then everytime after isset would be true....maybe ill repost ina little while } } } } } //mysql_close($DBConnet); ?> action file. <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); if(isset($_POST['Send'])){ $tmpVar1 = $_POST['f_time']; $tmpVar2 = $_POST['f_date']; $tmpVar3 = $_POST['f_number']; $tmpVar4 = $_POST['f_destination']; $tmpVar5 = $_POST['f_friend']; $tmpVar6 = $_POST['f_space']; $tmpVar7 = $_POST['f_comfort']; $tmpVar8 = $_POST['f_clean']; $tmpVar9 = $_POST['f_noise']; $insert = "INSERT INTO `airline`.`surveys` ( `f_date` , `f_time` , `f_number` , `f_destination` , `f_friend` , `f_space` , `f_comfort` , `f_clean` , `f_noise` ) VALUES ($tmpVar1, $tmpVar2, $tmpVar3, $tmpVar4, $tmpVar5, $tmpVar6, $tmpVar7, $tmpVar8, $tmpVar9);"; $createTable = "CREATE TABLE `surveys` ( `f_date` VARCHAR( 30 ) NOT NULL , `f_time` VARCHAR( 30 ) NOT NULL , `f_number` VARCHAR( 30 ) NOT NULL , `f_destination` VARCHAR( 30 ) NOT NULL , `f_friend` VARCHAR( 30 ) NOT NULL , `f_space` VARCHAR( 30 ) NOT NULL , `f_comfort` VARCHAR( 30 ) NOT NULL , `f_clean` VARCHAR( 30 ) NOT NULL , `f_noise` VARCHAR( 50 ) NOT NULL );"; $DBConnect = mysql_connect("127.0.0.1", "root", "noonan79"); if($DBConnect == FALSE){ echo "<p>Connection Error: " . mysql_error() . "</p>\n"; }else { $insertQuery = mysql_query($insert, $DBConnect); if($insertQuery === FALSE){ echo "<p>Survey failed to save to the database.</p>"; } else{ echo "<p>Survey Complete!</p>"; $SQLSelect = "SELECT * FROM surveys"; $QueryResult = mysql_query($SQLSelect, $DBConnect); echo "<table width='100' border='1'>\n"; echo "<tr><th>Flight Date</th><th>Flight Time</th><th>Flight Number</th><th>Destination</th><th>Friendliness</th><th>Storage Space</th><th>Comfort</th><th>Cleanliness</th><th>Noise</th></tr>\n"; //while (($Row = mysql_fetch_row($QueryResult)) !== FALSE) { //count $row array //for loop to iterate rows // echo "<tr><td>{$Row[0]}</td>"; // echo "<td>{$Row[1]}</td>"; // echo "<td>{$Row[2]}</td>"; // echo "<td align='right'>{$Row[3]}</td>"; // echo "<td>{$Row[4]}</td></tr>"; //} echo "</table>\n"; echo "<h2>Survey</h2>"; echo "<FORM action=\"Surveyprocess.php\" method=\"post\">"; echo "<P>"; echo "Flight Time: <INPUT type=\"text\" name=\"f_time\"><BR>"; echo "Flight Date: <INPUT type=\"text\" name=\"f_date\"><BR>"; echo "Flight Number: <INPUT type=\"text\" name=\"f_number\"><BR>"; echo "Destination: <INPUT type=\"text\" name=\"f_destination\"><BR>"; echo "<p>How would you rate the friendliness of the staff?</p>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_friend\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the storage space on the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_space\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the comfort on the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_comfort\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the cleanliness of the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_clean\" value=\"Excellent\"> Excellent<BR>"; echo "<p>How would you rate the noise level on the plane?</p>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"No Opinion\"> No Opinion<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Poor\"> Poor<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Fair\"> Fair<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Good\"> Good<BR>"; echo "<INPUT type=\"radio\" name=\"f_noise\" value=\"Excellent\"> Excellent<BR>"; echo "<INPUT type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">"; echo "</P>"; echo "</FORM>"; } } } ?>
  24. Hi, I'd get to do a join query with 3 (sometimes 2). Here is the structure of my 3 tables in question: items> id, cat, subcategory, created status> itemId, level Modify> id, itemId, date, type Here's my query so far: SELECT i.id, i.userId FROM items i LEFT OUTER JOIN statut s ON i.id = s.itemId WHERE CASE WHEN ( SELECT m.date FROM modification m WHERE m.itemId = i.id ORDER BY m.date DESC LIMIT 1 ) IS NULL THEN i.created END > DATE_SUB(NOW(), INTERVAL 90 DAY) AND s. LEVEL = 1 I would like to get a look at what the last change add and see if it has been over 90 days. In case no change was made compared with the creation date of the item. He that can strongly that there are several changes to a single item so it should really checked with the last added in case there. Thank you for your help!
  25. Okay so i have a file that i need some php variables from. This is the code that i am using. please help ! This is the ajax that i am trying to use to get the variable and then set it to a php variable. $.ajax({ url : 'pagination_data.php?page=1', type : 'POST', data : data, dataType : 'json', success : function (result) { var k=result; <?php $next ?>=var k; }, error : function () { alert("error"); } }); Now here i am setting the varialbes in the other file. $next = $page+1; $prev = $page-1; echo json_encode($next); echo json_encode($prev); and this is where i need the variables... <?php echo "<div class='controls' id='$prev'></div><div class='controls' id='$next'>"; ?>
×

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.