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. The idea is simple. A key you press (a letter) appears in updated page: keyj.php: <input id='k'></input> <script type="text/javascript"> document.getElementById('k').onkeypress=function() { <?php $db=new PDO('mysql:host=localhost;dbname=test;charset=utf8','$us','$ps'); $db->exec("UPDATE TXT SET texts=k.value"); $rl=$db->query("SELECT texts FROM TXT"); print_r($rl->fetchColumn()); ?> } </script> The intention is to have text on the screen via print_r. I successfully used it in another php to exchange information with MySQL and users screen (worked). Here - the more you type and the more k.value is the more text will be on screen (just from server). Unfortunately something went wrong.
  2. Hi I know this is probably a stupid question but I have this error On line 2785 is $combineArr = mysql_num_rows($query); On line 2787 while( $result1 = mysql_fetch_object($query) ){ This is the entire code function putGrid($pageid){ global $_GRID_FRAMES_TABLE, $_GRID_TABLE, $_GRID_CROSS_GRID_FRAMES_TABLE, $_GRID_CROSS_PAGES_TABLE, $_HTTP_ADDRESS; $i=0; $cpt = 1; $str = ''; $whichCount = 1; $query = mysql_query("SELECT * FROM $_GRID_TABLE WHERE id_page='$pageid'"); //return mysql_num_rows($query) or mysql_error(); //return $query; $combineArr = mysql_num_rows($query); while( $result1 = mysql_fetch_object($query) ){ if($whichCount == 1){ $gridClass="grid-active"; $style = "position: absolute; left:0%; top:0; width:100%;"; }else{ $gridClass="grid-inactive"; $style = "position: absolute; left:-100%; top:0; width:100%;"; } if($whichCount == 1){ $str.='<div id="grid-slide'.$i.'" class="grid-slide '.$gridClass.'" style="'.$style.'">'; $str.= '<div class="grid-slide-inner">'; $str.= '<div class="grid-banner-content grid-banner-left">'; $str.= '<div class="grid-banner-header">'; $str.= '</div>'; $str.= '<div class="grid-banner-copy">'; $str.= '<ul id="gallery">'; } $str.= '<li>'; $str.= '<img src="'.$_HTTP_ADDRESS.'products_images/'.$result->image.'">'; $str.= '<span>'; $str.= '<h3>'.$result->name.'</h3>'; $str.= $result->description; $str.= '</span>'; $str.= '</li>'; if($whichCount % 9 == 0 && $whichCount < $combineArr){ $i++; $str.= '</ul>'; $str.= '</div>'; $str.= '</div>'; $str.= '</div>'; $str.='</div>'; $str.='<div id="grid-slide'.$i.'" class="grid-slide '.$gridClass.'" style="'.$style.'">'; $str.= '<div class="grid-slide-inner">'; $str.= '<div class="grid-banner-content grid-banner-left">'; $str.= '<div class="grid-banner-header">'; $str.= '</div>'; $str.= '<div class="grid-banner-copy">'; $str.= '<ul id="gallery">'; } if($whichCount == $combineArr){ $str.= '</ul>'; $str.= '</div>'; $str.= '</div>'; $str.= '</div>'; $str.='</div>'; } $whichCount++; $cpt++; } return $str; }
  3. <?php header("Content_Type: text/xml"); $xmlBody = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $dir = "SOUNDS/"; $xmlBody .= "<XML>"; $dirHandle = opendir($dir); $i = 0; while ($file = readdir($dirHandle)) { if(!is_dir($file) && strpos($file, '.mp3')){ $i++; $myId3 = new ID3($file); $xmlBody .= ' <Song> <songNum>' . $i . '</songNum> <songURL>' . $dir . '' . $file . '</songURL> <songArtist>' . $myId3->getArtist() . '</songArtist> <songTitle>' . $myId3->getTitle() . '</songTitle> </Song>'; } } closedir($dirHandle); $xmlBody .= "</XML>"; echo $xmlBody; ?> Hi there, I have designed a flash mp3 player that reads the id3 tags form the .mp3 file, but wanted to make a XML list generated by PHP & to add the mp3 tags to the XML file so that flash can view all the id3 tag information on the files, and show on the list. I know how to view the XML list in flash I just don't want to type out 500+ tags of XML lol here is something I tried ...
  4. Normally you would add unique meta tags(title, description) for each page of the website. However, what if it's a user based website where a user can add posts with title and description? Is it better to add user's title/post name in the meta tags or keep it as your own?
  5. im having a simple html form that gets variables via 'POST' and passes them to simple.php, the simple.php file constructs a new link with the $_POST[] - and all i want to do is creating a simple iframe (this script is only for internal uses) underneath the form that will open the new link that was created within simple.php to clarify it a bit more here's form.html <form name="Students Management" action="http://myowntest.com/simple.php" method="post" accept-charset="utf-8"> <p> <label>First Name</label> <input type="text" value="" name="firstname" ></input> </p> <p> <label>Phone</label> <input type="text" value="" name="phone" ></input> </p> <p> <label>Last Name</label> <input type="text" value="" name="lastname" required="true"></input> </p> <p> <label>Company</label> <input type="text" value="" name="school" required="true"></input> </p> <p> <label>Email</label> <input type="text" value="" name="email" ></input> </p> <p> <label>Country</label> <input type="text" value="" name="age" ></input> </p> <p> <input type="submit" value="Submit" ></input> </p> </form> and here's simple.php <?php $newUrl = 'http://www.myothertestspace.com/simlpe2.php?name=' . $_POST['name'] . '&surname=' . $_POST['lastname'] . '&phone=' . $_POST['phone']; header(Location: $newUrl); ?> now, all i want is - after the user 'submits' the details on form.html , i'd like a new iframe will be shown up in the same page as the form that will show the user the contents of simple.php (which means - myothertestspace.com with the new parameters). thanks a lot!
  6. All I want to do is simply delete a record/row using ajax. For the life of me, I can't get it to work. I have tried many different methods and played around with them. Here is a basic example. Please do tell me what's wrong with it and how I can fix it. index.php <html> <head> <title>Home page</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(document).ready(function() { $(function() { $(".del-action").click(function() { var commentContainer = $(this).parent(); var id = $(this).attr("id"); var string = 'id='+ id ; $.ajax({ type: "GET", url: "delete.php", data: string, cache: false, }); }); </script> </head> <body> <?php $get = DB::getInstance()->query("SELECT * FROM records WHERE record_id = 28 "); if(!$get->count()) { echo 'no record found!'; } else { foreach($get->results() as $row) { $record_id = $row->record_id; ?> <div class="record"> <a href="#" class="del-action" id="<?php echo $record_id; ?>" >Delete</a> </div> <?php } } ?> </body> </html> delete.php $record_id = intval($_GET['id']); $delete = DB::getInstance()->delete('records', array('record_id', '=', $record_id)); ps. it deletes the records fine without ajax/js. I just need help with the js code so that I can delete the record without redirecting or refreshing the page.
  7. Hello, first I would like to note that I found this-- http://forums.phpfreaks.com/topic/187247-display-results-upon-drop-down-selection-phpmysql/?hl=%2Bdisplay+%2Bresults+%2Bfrom+%2Bdrop+%2Bdown+%2Bmenu&do=findComment&comment=988883 --post very similar to my question but I just could not figure it out. It wouldn't work with my type of code or maybe I simply missed something. Alright, well basicly I have a drop down menu working now all I want to do is to display the description(for now) in the section to the right of my drop down menus. In my database the column is call "description" and it is in my destination table. Here is my code that I have so far... The Javascript <script type="text/javascript"> jQuery(document).ready(function(){ jQuery("#flip").click(function() { jQuery("#panel").slideToggle("slow"); }); jQuery(".wrap").on('change', '#country',function() { var querystr = 'countryid='+jQuery('#country :selected').val(); jQuery.post("<?php echo plugins_url(); ?>/Destination_Drop_Down_Menu/ajax.php", querystr, function(data){ if(data.errorcode == 0){ jQuery('#statecbo').html(data.chtml) }else{ jQuery('#statecbo').html(data.chtml) } }, "json"); }); jQuery(".wrap").on('change', '#states', function() { var querystr1 = 'stateid=' +jQuery('#states :selected').val(); jQuery.post("<?php echo plugins_url(); ?>/Destination_Drop_Down_Menu/ajax.php", querystr1, function(data) { if(data.errorcode ==0){ jQuery('#citycbo').html(data.chtml) }else{ jQuery('#citycbo').html(data.chtml) } }, "json"); }); jQuery(".wrap").on('change', '#city', function() { var querystr2 = 'cityid=' +jQuery('#city :selected').val(); jQuery.post("<?php echo plugins_url(); ?>/Destination_Drop_Down_Menu/ajax.php", querystr2, function(data) { if(data.errorcode ==0){ jQuery('#descbo').html(data.chtml) }else{ jQuery('#descbo').html(data.chtml) } }, "json"); }); }); </script> <html> <head> <title>Dynamic Drop Down Menu</title> </head> <body> <div class="wrap"> <h2> Country</h2> <select id="country" name="country" required> <option value="">--Select Country--</option> <?php $sql=mysql_query("SELECT * from country order by name"); while ($row=mysql_fetch_array($sql)) { $countryID=$row['IDCountry']; $countryname=$row['name']; echo "<option value='$countryID'>$countryname</option>"; } ?> </select> </div> <h2>State</h2> <div class="wrap" id="statecbo"> </div> <h2>City</h2> <div class="wrap" id="citycbo"> </div> <h2>Destination</h2> <div class="wrap" id="descbo"> </div> and here is my ajax.php file $country_id = isset($_POST['countryid']) ? $_POST['countryid'] : 0; if ($country_id <> 0) { $errorcode = 0; $strmsg = ""; $sql="SELECT * from state WHERE IDCountry = ". $country_id . " ORDER BY name;"; $result=mysql_query($sql); $cont=mysql_num_rows($result); if(mysql_num_rows($result)){ $chtml = '<select name="states" id="states"><option value="0">--Select State--</option>'; while($row = mysql_fetch_array($result)){ $chtml .= '<option value="'.$row['IDState'].'">'.$row['name'].'</option>'; } $chtml .= '</select>'; echo json_encode(array("errorcode"=>$errorcode,"chtml"=>$chtml)); }else{ $errorcode = 1; $strmsg = '<font style="color:#F00;">No States available</font>'; echo json_encode(array("errorcode"=>$errorcode,"chtml"=>$strmsg)); } } $state_id = isset($_POST['stateid']) ? $_POST['stateid'] : 0; if ($state_id <> 0) { $errorcodeC = 0; $strmsg = ""; $sqlC="SELECT * from city WHERE IDState = ". $state_id . " ORDER BY name;"; $resultC=mysql_query($sqlC); $contC=mysql_num_rows($resultC); if(mysql_num_rows($resultC)){ $chtmlC = '<select name="city" id="city"><option value="0">--Select city--</option>'; while($row = mysql_fetch_array($resultC)){ $chtmlC .= '<option value="'.$row['IDCity'].'">'.$row['name'].'</option>'; } $chtmlC .= '</select>'; echo json_encode(array("errorcode"=>$errorcodeC,"chtml"=>$chtmlC)); }else{ $errorcodeC = 1; $strmsg = '<font style="color:#F00;">No city available</font>'; echo json_encode(array("errorcode"=>$errorcodeC,"chtml"=>$strmsg)); } } $city_id = isset($_POST['cityid']) ? $_POST['cityid'] : 0; if ($city_id <> 0) { $errorcodeD = 0; $strmsg = ""; $sqlD="SELECT * from destination WHERE IDCity = ". $city_id . " ORDER BY name;"; $resultD=mysql_query($sqlD); $contD=mysql_num_rows($resultD); if(mysql_num_rows($resultD)){ $chtmlD = '<select name="destination" id="destination"><option value="0">--Select Destination--</option>'; while($row = mysql_fetch_array($resultD)){ $chtmlD .= '<option value="'.$row['IDDestination'].'">'.$row['name'].'</option>'; } $chtmlD .= '</select>'; echo json_encode(array("errorcode"=>$errorcodeD,"chtml"=>$chtmlD)); }else{ $errorcodeD = 1; $strmsg = '<font style="color:#F00;">No Destination available</font>'; echo json_encode(array("errorcode"=>$errorcodeD,"chtml"=>$strmsg)); } } Any help would be greatly appreciated. I am also about two weeks into learning how to program so basic explanations would help me learn alot! Thank you!
  8. I have this button for my like system and for some reason i have to refresh after i click it again... i would like it to be that when i click it it changes the class and i can click it again and do the other function... please help thank you... JQUERY: <script type="text/javascript"> $(document).ready(function(){ $('[name="like"]').on("click", function(){ if($(this).attr('title')=='like'){ $.post('/like.php',{imid:$(this).attr('id'),action:'like'}); $(this).removeClass('like').addClass('unlike'); $(this).attr('title','unlike'); $(this).attr('name','unlike'); } }); $('[name="unlike"]').on("click", function(){ if($(this).attr('title')=='unlike'){ $.post('/like.php',{imid:$(this).attr('id'),action:'unlike'}); $(this).removeClass('unlike').addClass('like'); $(this).attr('title','like'); $(this).attr('name','like'); } }); }); </script> PHP: $likes = mysql_query("SELECT lid FROM likes WHERE uid='$id' AND imid='$photoid'"); if(mysql_num_rows($likes)==0){ $likethis = '<div class="like" title="like" id="'.$photoid.'" name="like"></div>'; }else{ $unlikethis = '<div class="unlike" title="unlike" id="'.$photoid.'" name="unlike"></div>'; }
  9. I have this Banner ad rotation script. $banner[1] = '<a href="http://www.facebook.com/mstrgmrs"><img src="/adverts/mstr_gmrs.png" width="900" height="200" border="1"></a>'; $banner[2] = '<a href="http://www.twitter.com/mstrgmrs"><img src="/adverts/banner_ad.png" width="900" height="200" border="1"></a>'; $banner[3] = '<a href="http://www.youtube.com/user/mstrgmrs"><img src="/adverts/banner_ad.png" width="900" height="200" border="1"></a>'; $banner[4] = '<a href="http://mastergmrs.enjin.com/"><img src="/adverts/banner_ad.png" width="900" height="200" border="1"></a>'; $id = rand(1,4); echo $banner[$id]; How can I make it so that code can work with a database?
  10. So I am trying to get this code $banner_ads = mysql_fetch_assoc(mysql_query("SELECT * FROM adverts")); Wait. Would i just do a random number where the highest number is the count of all of those?
  11. ok i have an index.php as so: <?php require 'php/stdlib.php'; $site->page->render(); foreach($page as $var => $value) { echo $var ." is ". $value." <br/>"; } ?> the obj creation for site and page is in the stdlib file and is obviously working cuz the -for each- loop prints out: name is welcome headers is inc/index_h.php footers is inc/index_f.php contents is inc/welcome.php It show that the object is created. I also did a var dump with proper results here is site---page---render: public function render_page(){ $this->page->render(); } here is page---render: public function render(){ include $this->headers; include $this->contents; include $this->footers; } however the result of the script is the following: Undefined variable: and also Trying to get property of non-object: both errors point to my $page object that i used in the include file for the page header: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title><?php echo $page->name; ?></title> <script src="/scripts/jquery.js"></script> </head> <body> The errors actually print out in the html title tag not on the screen meaning i have to use View Source on my browser to see it How do i get the $page object to be visible when using an include Im usually pretty good about finding answers myself but this thing has me stumped for two days now.(I have learned alot about many other things while searching for answer tho so I guess not all is lost) If anyone could help me I would greatly appreciate it. Probably should have added that the page and site object are instantiated in stdlib.php with the following $site = new csite(); site_ini($site); $page = new cpage("welcome"); $site->setPage($page);
  12. Okay, I am having a little trouble with a mysql table. I am trying to make a table. I have a <tr> in a while statement. I am trying to make it so that it will go and display 5 users across the <tr> and then it will close the tr and start a new one and repeat showing the next 5 users. What would the code for this be? Any help would be appreciated
  13. Hello, hope having some help, cant find no place to solve my problem, i have a script that basically what it doest is submit candidates CV forms. When a user fill the form whit his personal information and attached his CV, the form will save the information and the cv path in database and leave the cv in a folder inside of server, than will send a email to the company that post this job. Everything works fine, but only one problem, and this is the CV, this isnt attaching the CV in the email that is sent to the company. Could someone take a look to the code? if(isset($_FILES['files'])){ $errors= array(); foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){ $file_name = $key.$_FILES['files']['name'][$key]; $file_size =$_FILES['files']['size'][$key]; $file_tmp =$_FILES['files']['tmp_name'][$key]; $file_type=$_FILES['files']['type'][$key]; $random_digit=rand(0000,9999); $new_file_name=$random_digit.$file_name; if($file_size > 2097152){ $errors[]='File size must be less than 2 MB'; } $query2="INSERT into candidates (`firstname`,`lastname`,`mobile`,`email`,`message`,`id_company`,`titulo_anuncio`,`job_type`,`data`,ativo) VALUES('$firstname','$lastname','$mobile','$email_candidate','$message','$id_company','$title_en','$job_type','$data','1'); "; mysql_query($query2); $user_id = mysql_insert_id(); $query="INSERT into media (`id_candidate`,`file`,`size`,`type`) VALUES('$user_id','$new_file_name','$file_size','$file_type'); "; $to = $email; $subject = "Domainname.com | Portal of Jobs - New Candidate"; $body = ""; $body .= "Title Job: "; $body .= $title_en; $body .= "\n"; $body .= "Tel: "; $body .= $mobile; $body .= "\n"; $body .= "Email: "; $body .= $email_candidate; $body .= "\n"; $body .= "Message: "; $body .= $message; $body .= "\n"; $body .= "CV: "; $body .= "In Attachement"; $body .= "\n"; $headers = "From:" . $to; if (mail($to, $subject, $body,$headers)) $desired_dir="candidates_cv"; if(empty($errors)==true){ if(is_dir($desired_dir)==false){ mkdir("$desired_dir", 0700); // Create directory if it does not exist } if(is_dir("$desired_dir/".$new_file_name)==false){ move_uploaded_file($file_tmp,"$desired_dir/".$new_file_name); }else{ // rename the file if another one exist $new_dir="$desired_dir/".$new_file_name.time(); rename($file_tmp,$new_dir) ; } mysql_query($query); }else{ print_r($errors); } } if(empty($error)){ echo "<span style=\"color:green;font-weight:bold;\">Submitted whit Sucess Thanks</span>"; } } Regards
  14. I have a php and jquery like system that doesn't work for some reason? When i click on the button to like it does nothing not even gives me an error please help thank you ! Here is my code that I am using and maybe you will see something that I didn't? The first part of the php code works it shows the like button so I know that's right but when you click it, it does nothing ... PHP: $likes = mysql_query("SELECT lid FROM likes WHERE uid='$id' AND imid='$photoid'"); if(mysql_num_rows($likes)==0){ $likethis = '<a href="#" id="'.$photoid.'" title="like"><div class="like"></div></a>'; }else{ $unlikethis = '<a href="#" id="'.$photoid.'" title="unlike"><div class="unlike"></div></a>'; } JQUERY: <script type="text/javascript"> $(document).ready(function(){ $(document).bind('click', '.like', function(){ if($(this).attr('title')=='like'){ $.post('like.php',{imid:$(this).attr('id'),action:'like'},function(){ $(this).text('unlike'); $(this).attr('title','Unlike'); }); }else{ if($(this).attr('title')=='unlike'){ $.post('like.php',{imid:$(this).attr('id'),action:'unlike'},function(){ $(this).text('like'); $(this).attr('title','like'); }); } } }); }); </script> like.php: $imid=$_POST['imid']; $action=$_POST['action']; if ($action=='like'){ $sql= mysql_query("SELECT * FROM likes WHERE imid=$imid and uid=$id"); $matches=$sql->rowCount(); if($matches==0){ $sql= mysql_query("INSERT INTO likes (imid, uid) VALUES($imid, $id)"); $sql= mysql_query("UPDATE photos SET likes=likes+1 WHERE id=$imid"); }else{ die("There is No Image With That ID"); } } if ($action=='unlike'){ $sql= mysql_query("SELECT * FROM likes WHERE imid=$imid and uid=$id"); $matches=$sql->rowCount(); if ($matches!=0){ $sql=mysql_query("DELETE FROM likes WHERE imid=$imid AND uid=$id"); $sql=mysql_query("UPDATE photos SET likes=likes-1 WHERE id=$imid"); } }
  15. Hi Guys I'm in the middle of creating my own website and I'm having trouble with letting users to register I have created the code but when I click on the "submit" button I'm getting a blank white screen config.php <?php //Mysql Connect | mysql_connect("host= 3306","username",""); //Below example to connect in localhost $a=mysql_connect("localhost","root",""); //select your database $b=mysql_select_db("database_name",$a); ?> and this is the submit_form.php ?php $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $username=$_POST['username']; //$confirmusername=$_POST['confirmusername']; $password=$_POST['password']; $confirmpassword=$_POST['confirmpassword']; $email=$_POST['email']; $confirmemail=$_POST['confirmemail']; //Database connection require_once("config.php"); //mysql query to insert value to database $query=mysql_query("INSERT INTO registration (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')"); //if value inserted successyully disply success message if($query) { echo 'Registred successfully..!!</div>'; }else { //error message echo '<unable to registred !!</div>'; } ?> Hope someone can help me and give me some pointers please Richsubmit-form.phpconfig.phpregister.php
  16. Hi all, Can I know how can use SMTP configuration to send a mail in PHP , I tried using mail() class by changing php_ini configuration, but didn't work , I also tried installing php_smtp.dll file, still I get the same error as shown below : Warning: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at "localhost" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() can I know how to resolve this issue, i even tried with port "25", all my changes gave me the same error. If anyone could share the working code , it would be of great help.. Thank you in advance...
  17. I have a fulltext search setup. The issue I have is that I have to add it on every page and do an if statement. The search box is shown fixed position at the top of the website. I was wondering if there is a way I can set it up so that no matter what page I am on, it'll do the search without modifying the selected page? For eg. <html> <head> <title>home page</title> </head> <body> <?php if(isset($_GET['search'])) { echo 'search.php'; } else { // echo rest of the page content. } ?> </body> </html>
  18. Requesting help from anyone who is a geek. My code is checking all of the friends where the logged in user is user_id. It gets all of the values but only displays 1. What am I doing wrong? Then later on I have a while loop getting this information. But it only displays 1 users information. Why won't it show them all? If you could help I would be really happy
  19. Hey, I'm pretty new to this site so I thought I would try it out! You never know!... I am currently building a private messaging system on my website, it's a lot of code so I will try to cut it down, if you require anymore code to help me out, please let me know and I will post it. The problem I am having, in your "inbox" the messages you have sent or received are displayed with the title of (SUBJECT). When you click the subject, you can see all the messages you or the other user have sent to each other. With first and last names. The 2 codes below gather this information from the databases, which is absolutely fine. Although, instead of showing the (SUBJECT) on the inbox page, i would prefer to show the (FIRST NAME + LAST NAME) of who the message is to or from. Just like you can see in the actual message itself. I cannot figure out how to do this. The second code below does this for the view message page, although the top code gathers information for the inbox page, I have tried my best to combine the users info from the 2nd part to the 1st part, but all this does is show every message as the logged in users first and last names, not who the message is sent to or received from, is there a way to do this? Here are the 2 codes: <?php function fetch_conversation_summery(){ $sql = "SELECT `conversations`.`conversation_id`, `conversations`.`conversation_subject`, MAX(`conversations_messages`.`message_date`) AS `conversation_last_reply`, MAX(`conversations_messages`.`message_date`) > `conversations_members`.`conversation_last_view` AS `conversation_unread` FROM `conversations` LEFT JOIN `conversations_messages` ON `conversations`.`conversation_id` = `conversations_messages`.`conversation_id` INNER JOIN `conversations_members` ON `conversations`.`conversation_id` = `conversations_members`.`conversation_id` WHERE `conversations_members`.`userid` = {$_SESSION['userid']} AND `conversations_members`.`conversation_deleted` = 0 GROUP BY `conversations`.`conversation_id` ORDER BY `conversation_last_reply` DESC"; $result = mysql_query($sql); $conversations = array(); while (($row = mysql_fetch_assoc($result)) !== false){ $conversations[] = array( 'id' => $row['conversation_id'], 'subject' => $row['conversation_subject'], 'last_reply' => $row['conversation_last_reply'], 'name' => $row['first_name'], 'unread_messages' => ($row['conversation_unread'] == 1), ); } return $conversations; } function fetch_conversation_messages($conversation_id){ $conversation_id = (int)$conversation_id; $sql = "SELECT `conversations_messages`.`message_date`, `conversations_messages`.`message_date` > `conversations_members`.`conversation_last_view` AS `message_unread`, `conversations_messages`.`message_text`, `users`.`first_name`, `users`.`last_name` FROM `conversations_messages` INNER JOIN `users` ON `conversations_messages`.`userid` = `users`.`userid` INNER JOIN `conversations_members` ON `conversations_messages`.`conversation_id` = `conversations_members`.`conversation_id` WHERE `conversations_messages`.`conversation_id` = {$conversation_id} AND `conversations_members`.`userid` = {$_SESSION['userid']} ORDER BY `conversations_messages`.`message_date` DESC"; $result = mysql_query($sql); $messages = array(); while (($row = mysql_fetch_assoc($result)) !== false){ $messages[] = array( 'date' => $row['message_date'], 'unread' => $row['message_unread'], 'text' => $row['message_text'], 'first_name' => $row['first_name'], 'last_name' => $row['last_name'], ); } return $messages; } I need to be able to recall the information as "$coversation['first_name']; $conversation['last_name']" to show the names, although this information is only available on the messages page as "$messages['first_name'];. I am currently displaying the subject as "$conversation['subject'];". Trying to turn subject into the first and last names. Files have been attached for reference. Thanks pmsettings.php inbox.php viewmessage.php
  20. Hello everyone, I am having a problem with some php code in a webpage. It is not functioning as it should. The basic purpose of the page is to edit a text file stored in the same directory, the text file contains ID numbers in a one per line format (eg attached). The page should allow searching for a ID number, then give the option to delete it if it is found or ADD if it is not in the database using the respective button that should be shown based on the case. The page does not search now and shows a part of the code when opened in a browser. PLEASE HELP ME! editor.php mydata.txt
  21. im trying to check if the account is = to c but its erroring out and displays a blank page. $user = '<script type="text/javascript" src="'.$actual_link.'/js/submenu.js"></script><div class="dropdown"> <a class="account" > <span>'.$username.'</span> </a> <div class="submenu" style="display: none; "> <ul class="root"> '. if ($account == "c") { .' <li> <a href="/stats.php">Dashboard</a> </li> '. } .'
  22. Hi I am trying to create a grid like gallery and for some reason it does not look right? I want it to look like pinterest so I am trying to use wookmark jquery. Here is my code and an image to view. Thank you. Here is the css: #gallerycontainer { display: inline-block; background-color: #f0f0f0; padding: 0px; width:850px; /*border: 1px solid #DBDBDB; -webkit-box-shadow: #E4E4E4 0px 0px 5px; -moz-box-shadow: #E4E4E4 0px 0px 5px; box-shadow:#E4E4E4 0px 0px 5px;*/ position:relative; left:0px; bottom:13px; overflow:inherit; top:0px; float: left; padding-right: 0px; margin-left: 10px; overflow: auto; } #gallery{ } #gallery li img { float: left; border: 5px solid #fff; -webkit-transition: box-shadow 0.5s ease; -moz-transition: box-shadow 0.5s ease; -o-transition: box-shadow 0.5s ease; -ms-transition: box-shadow 0.5s ease; transition: box-shadow 0.5s ease; max-width:250px; max-height:200px; padding:0px; } .galleryinfo{ border: 2px solid #fff; padding-bottom: 40px; float: left; margin:9px; background: white; } #gallery li img:hover { -webkit-box-shadow: 0px 0px 7px rgba(255,255,255,0.9); box-shadow: 0px 0px 7px rgba(255,255,255,0.9); cursor: pointer; } .myaccounttitle{ text-align: center; } And here is the php and html. <script type="text/javascript" src="js/jquery.wookmark.js"></script> <script type="text/javascript">$('#gallery li').wookmark();</script> <div class="myaccounttitle">My Images</div> <div id="gallery"> <?php function pictures($query) { while($row = mysql_fetch_array($query)) { $id = $row['id']; $title = $row['title']; $author = $row['userid']; $date = date("F j, Y, g:i a", $row['date']); $picture = $row['picture']; // $likes = $row['likes']; // $favs = $row['favs']; $unique = mysql_num_rows(mysql_query("SELECT * FROM views WHERE picture='$id' GROUP BY ip")); ?> <div class="galleryinfo"> <li id="<?php print $id?>"> <a class="fancybox" rel="group" href="photos/<?php print $picture?>"><img src="photos/<?php print $picture?>"/></a> </li> Views : <?php print($unique) ?> </div> <?php }}} ?> <div id="gallerycontainer"> <?php if($account == "c") { pictures($query2); }else { pictures($query); } ?> </div> All of your help is greatly appreciated.
  23. Hello! every one. I have my php-mysql codes bellow which gives the error "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\jopasy_community_2.2\includes\view.php on line 28" bellow are the codes <?php include 'connection.php'; $con = mysql_connect($host,$user,$pwd); $db = mysql_select_db($database); include 'create_tables.php'; $sql = 'SELECT name, qntitle, question FROM questions'; $retval = mysql_query( $sql, $con ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { $qnabout=$row['qntitle']; echo "<b>Question: </b>{$row['question']} <br>". "<b>Asked by : </b> {$row['name']} <br> ". "<b>Question about: </b> {$row['qntitle']} <br><br> ". "<b>Answers</b> <br><br> ". $getanswer = ("SELECT answerdby, answer FROM answers WHERE qntitle ='".$qnabout."';"); $answer = mysql_query( $getanswer, $con ); while($ans = mysql_fetch_array($answer, MYSQL_ASSOC)) // THIS IS THE LINE WITH ERROR { echo "Answer : {$ans['answer']} <br> ". "<b>Answered by : </b> {$ans['answerdby']} <br> ". "--------------------------------<br><br><br><hr>"; } } mysql_close($con); ?> I dont know how to solve it. i need help plz
  24. Hi guys. I currently have the following: $UserID1 $TeamID1 $Points1 Where the value goes from 1 to 24, I need to insert all of these in to their own rows in a database how would I be best off doing that? Would I be able to use a foreach statement whereby the number increases? Or is there another way that doesn't involve doing 24 inserts? Thanks in advance!
  25. Hi. I am new. I don't know how to validate certain data like emai, web site and numeric value. Here is my code which is work fine. Below is my code. Pls Help me add.php <?php include_once '../inc/header.php'; ?> <Script Language="javascript"> function change_action() { var frm_obj=document.getElementById("frm"); frm_obj.action="data.php"; } </Script> <form action="" method="POST" id="frm" > <table class="" align="center" cellpadding="4" cellspacing="1"> <tr> <td><label class="lbl">ID </label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="id" id="id" readonly="" class="txt"></td> </tr> <tr> <td><label class="lbl">Name </label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="name" id="name" class="txt"></td> </tr> <tr> <td><label class="lbl">Address </label></td> <td><label class="lbl">: </label></td> <td><textarea name="address" id="address" class="txt" rows="5" cols="40"></textarea></td> </tr> <tr> <td><label class="lbl">Tel</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="tel" id="tel" class="txt"></td> </tr> <tr> <td><label class="lbl">Fax</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="fax" id="fax" class="txt"></td> </tr> <tr> <td><label class="lbl">Email</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="email" id="email" class="txt"></td> </tr> <tr> <td><label class="lbl">Web site</label></td> <td><label class="lbl">: </label></td> <td><input type="text" name="website" id="website" class="txt"></td> </tr> <tr> <td><label class="lbl">Type</label></td> <td><label class="lbl">: </label></td> <!--<td><input type="text" name="type" id="type" class="txt"></td>--> <td> <SELECT NAME=type id="type"> <OPTION VALUE=0>Choose <?php $sql="SELECT * FROM bk_parameter where type='typcs' order by id"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { $typename=$row["name"]; echo "<OPTION VALUE=\"$typename\">".$typename.'</option>'; } ?> </SELECT> </td> </tr> <tr> <td></td> <td></td> <td><input type="submit" value="submit" name="submit" class="btn" onclick="change_action()"> <input type="submit" value="back" name="back" class="btn" onclick="change_action()"></td> </tr> </table> </form> <?php include_once '../inc/footer.php'; ?> data.php <?php include_once '../inc/header.php'; //insert into table if (isset($_POST['submit']) && $_POST['submit'] != "" ) { $name = ($_POST["name"]); $address = ($_POST["address"]); $tel = ($_POST["tel"]); $fax = ($_POST["fax"]); $email = ($_POST["email"]); $website = ($_POST["website"]); $type = ($_POST["type"]); try { $sql="INSERT INTO bk_customer (name,address,tel,fax,email,website,type) VALUES ('$name','$address','$tel','$fax','$email','$website','$type')"; $result = mysqli_query($con,$sql) ; header("Location:index.php"); exit(); } catch (Exception $ex) { echo $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit(); } } //mysqli_close($con); // update table if (isset($_POST['update']) && $_POST['update'] != "" ) { $id= ($_POST["id"]); $name = ($_POST["name"]); $address = ($_POST["address"]); $tel = ($_POST["tel"]); $fax = ($_POST["fax"]); $email = ($_POST["email"]); $website = ($_POST["website"]); $type = ($_POST["type"]); try { $sql="UPDATE bk_customer SET name='$name',address='$address', tel='$tel',fax='$fax'," . "email='$email', website='$website',type='$type' WHERE id='$id'"; $result = mysqli_query($con,$sql) ; header("Location:index.php"); } catch (Exception $ex) { echo $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit(); } } // update record if (isset($_POST['delete']) && $_POST['delete'] != "" ) { $id=$_POST["id"]; try { $sql="DELETE FROM bk_customer WHERE id='$id'"; $result = mysqli_query($con,$sql) ; header("Location:index.php"); } catch (Exception $ex) { echo $e->getMessage() . "\n"; file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND); exit(); } } // back to index.php if (isset($_POST['back']) && $_POST['back'] != "" ) { header("Location:index.php"); }
×
×
  • 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.