PHP - Hello And Combining Php Terms On Wordpress
Similar TutorialsHi I want to reduce the size of an image. Using Pascal this takes one line of code. However in php so far my research shows me that I need to use a library. (JQuery with a plug-in) Is this normal. To get the real power out of php will I need to use libraries.. I am happy with php. I just need to know how best to use this language.. Thank you.. Hello, I am looking for an event manager that I can put into my site...............I search on google and cant find anything besides for event sites.........does anyone have any suggestion scripts or searches to help me? I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. Dear forum, I`m always trying hard, but after 5 hours I really need some help in php coding. My problem deals with my checkout page for woocommerce. At the moment, my legal terms are above the total-order-table where u can find the booked product, order-subtotal, order-total and tex-total. But I need to display the legal terms under my total-order table. I need the terms directly above the "Buy now" button. Do you guys know which file to modify ? I tried everything. Nothing worked for me. You will find a picture in this post. There you can see my problem. Would be pretty nice if you can give me some information. Kind regards,
Not sure if I'm trying to achieve something totally crazy here, or if this is something pretty standard. Didn't have much luck with searching as I'm not fully down with all the terms. (A) I have one site providing an RSS feed. (B) I have one site I want to search, once for each of the items in the feed A. (C) I want the results of the search in (B) to be displayed on page (C). So for example, the feed on (A) says; apples bananas oranges cheese I want site (B) to search for each of those terms (by passing the item in the feed (A) to the ?search= part of the URL of that page) and then show the results from THAT search on page C. Bit of a complex one, let me know if you need me to clarify. Thanks for any help! Hello, I'm developing a website that asks the user to submit a keyword for a search. The results should display matches for this keyword, but also show matches for related keywords (in order of relevenace!). I'm planning on building up a library of which search terms users use in the same sessions (e.g. if someone searches for "it jobs" and "php jobs", I'll know the terms are correlated), and I'll also measure the click-through rates of the items on the results list. I've been spending all weekend trying to map out the design for this but it's proving incredibly complicated and I think the solution is likely to be on the internet somewhere already?! Please could someone point me in the right direction if you've come accross this problem before? Thanks a million, Stu Hi , im completely new to php and mysql. I have 2 websites running on the same server and im just wondering if there is a way that when someone logs into one of the websites that it will automatically log them in the other website as well so that they don't have to log in again. Maybe if you can point to some good beginner reading material or something that would be great.
Hi, I'm so close to having this work how I want but one last thing! I have a form with a drop down box with the numbers 1 - 60 in. I have created a view that returns any numbers people have submitted with their login names, e.g. 1 - Laurie 4 - Craig What I need to happen is it to list all the empty numbers too, so like this: 1 - Laurie 2 - 3 - 4 - Craig 5 - etc This code removes numbers that have already been selected from the drop down box (so after Laurie and Craig had chosen 1 & 4 the drop down box would now show 2, 3, 5, 6 etc) https://pastebin.com/dAps0kqJ and this code subtotals the rider numbers (I was just trying to get a custom view to work so am pleased this returns something) https://pastebin.com/A7MwSQ2S Using the first code how do I edit the second code so that it displays every number whether a user has chosen it or not? Thank you!!
i'm having trouble in combining the 2 preg_replace into 1. basically i have a string witch strange chars, first i remove all except alphanumeric chars and the remaining string has 1 or 2 spaces and i replace them with dash. Code: [Select] strtolower(preg_replace('/\s+/', '-', preg_replace("/[^0-9a-zA-Z]/i", ' ',$a['item']))); Hi there, I'm a beginner at php and mysql. I know a few basics, but i'm stuck. I'm trying to make something for my wifes company that will be as simple as i can make it. The files i have: login/register script (register.php / regcheck.php) member / profile script and a image upload script. (upload.php: which is now in register.php and process.php) What i want to do is: at register i've added a file upload form, but the reg.php points to regcheck.php and the upload.php points to process.php I want to combine those 2 files: regcheck.php and process.php to one file. Now i've been breakin my head over this for 2 day's and i cant find a solution and i'm not that experienced. what i've done so far is the following, but it does'nt fill my database: databas.sql: CREATE TABLE `klanten` ( `id` int(4) unsigned NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `level` int(4) default '1', `filename` varchar(255) not null, `mime_type` varchar(255) not null, `file_size` int not null, `file_data` mediumblob not null, primary key (image_id), index (filename) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; <?php ob_start(); function assertValidUpload($code) { if ($code == UPLOAD_ERR_OK) { return; } switch ($code) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $msg = 'Image is too large'; break; case UPLOAD_ERR_PARTIAL: $msg = 'Image was only partially uploaded'; break; case UPLOAD_ERR_NO_FILE: $msg = 'No image was uploaded'; break; case UPLOAD_ERR_NO_TMP_DIR: $msg = 'Upload folder not found'; break; case UPLOAD_ERR_CANT_WRITE: $msg = 'Unable to write uploaded file'; break; case UPLOAD_ERR_EXTENSION: $msg = 'Upload failed due to extension'; break; default: $msg = 'Unknown error'; } throw new Exception($msg); } $errors = array(); try { if (!array_key_exists('image', $_FILES)) { throw new Exception('Image not found in uploaded data'); } $image = $_FILES['image']; // ensure the file was successfully uploaded assertValidUpload($image['error']); if (!is_uploaded_file($image['tmp_name'])) { throw new Exception('File is not an uploaded file'); } $info = getImageSize($image['tmp_name']); if (!$info) { throw new Exception('File is not an image'); } } catch (Exception $ex) { $errors[] = $ex->getMessage(); } if( isset( $_POST['user'] ) && isset( $_POST['pass'] ) ) { if( strlen( $_POST['user'] ) < 4 ) { echo "Username Must Be More Than 4 Characters."; } elseif( strlen( $_POST['pass'] ) < 4 ) { echo "Passwrod Must Be More Than 4 Characters."; } elseif( $_POST['pass'] == $_POST['user'] ) { echo"Username And Password Can Not Be The Same."; } else { include( 'database.php' ); $username = mysql_real_escape_string( $_POST['user'] ); $password = md5( $_POST['pass'] ); $filename = mysql_real_escape_string($image['name']); $mime_type = mysql_real_escape_string($info['mime']); $file_size = $image['size']; $file_data = mysql_real_escape_string(file_get_contents($image['tmp_name']) $sqlCheckForDuplicate = "SELECT username FROM klanten WHERE username = '". $username ."'"; if (count($errors) == 0) { // no errors, so insert the image if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 ) { $sqlRegUser = "INSERT INTO klanten( username, password, filename, mime_type, file_size, file_data ) VALUES( '". $username ."', '". $password ."', '". $filename ."', '". $mime_type ."', '". $file_size ."', '". $file_data ."', )"; if( !mysql_query( $sqlRegUser ) ) { echo "You Could Not Register Because Of An Unexpected Error."; } else { echo "You Are Registered And Can Now Login"; $formUsername = $username; header('Location: view.php?id=' . $id); } } else { echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One."; $formUsername = $username; } } } else { echo "You Could Not Be Registered Because Of Missing Data."; } ob_end_clean(); ?> <html> <head> <title>Error</title> </head> <body> <div> <p> The following errors occurred: </p> <ul> <?php foreach ($errors as $error) { ?> <li> <?php echo htmlSpecialChars($error) ?> </li> <?php } ?> </ul> <p> <a href="upload.php">Try again</a> </p> </div> </body> </html> I guess i've mixed up things pretty badly right? This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=310184.0 Hello all, I have a simple form which ends in header( "Location: thankyou.php" ); What I have done on the site so far is to use Ajax to load content into a specific Div which uses the following code <a href="javascript:ajaxpage('home.php', 'content-index');"></a> Is there a way to effectively combine the two together to load the thankyou page (upon pressing submit) into the content-index div? Thank you in advance Hi there everyone! I've got a problem combining two queries. The situation is this. I've got a list of links and I want to allow the user to get a result list of all, only unread, all in a particular category and then only unread in a particular category. My query for all: /* No filtering and no unread */ $q_urls = "SELECT * FROM shortenified_urls WHERE is_social = '1' AND active = '1' ORDER BY date_added DESC"; My query for in a particular category: /* All links in a particular category */ $q_urls = " SELECT * FROM shortenified_urls WHERE shortenified_urls.primary_cat = $vu_cat_view OR EXISTS ( SELECT link_id FROM linkcats WHERE link_id = shortenified_urls.id AND cat_id = $vu_cat_view ) AND shortenified_urls.is_social = '1' AND shortenified_urls.active = '1' ORDER BY date_added DESC" ;My query for Unread in all cats: /* Unread only for all categories */ $q_urls = "SELECT * FROM shortenified_urls WHERE shortenified_urls.date_added > $vu_mark_as_read AND NOT EXISTS ( SELECT lid FROM linkviews WHERE lid = shortenified_urls.id AND uid = $viewing_user_id ) AND shortenified_urls.is_social = '1' AND shortenified_urls.active = '1' ORDER BY date_added DESC" ; These seem to be working well. It's the next one that isn't working for me. I tried to combine the "All in a particular category" and "Unread in all categories" using the two above as starting points. The result, however, seems to be that I'm getting all in a particular category. It seems to be ignoring the unread status. /* Unread links in a particular category */ $q_urls = " SELECT * FROM shortenified_urls WHERE shortenified_urls.primary_cat = $vu_cat_view AND shortenified_urls.date_added > $vu_mark_as_read OR EXISTS ( SELECT link_id FROM linkcats WHERE link_id = shortenified_urls.id AND cat_id = $vu_cat_view ) AND NOT EXISTS ( SELECT lid FROM linkviews WHERE lid = shortenified_urls.id AND uid = $viewing_user_id ) AND shortenified_urls.is_social = '1' AND shortenified_urls.active = '1' ORDER BY date_added DESC" ;I'm not smart enough to know why it's not working, but it seems to me like I need to somehow bracket the first two parts containing the category retrieval to make this work right. The only problem is I don't know how to do that. Any help on how to get this to work would be greatly appreciated! I am trying to combine two tables into one query. This is what I tried but it wont work: Code: [Select] <?php include ('includes/db.php'); include ('includes/functions.php'); include ('includes/global.php'); session_start(); echo '<table width="100%">'; $statsql="SELECT * from `wall`,`feed` WHERE ORDER BY `id` DESC LIMIT 0,10"; $statres=mysql_query($statsql) or die(mysql_error()); while($statrow=mysql_fetch_array($statres)){ $vmessage=clean_up($statrow[message]); $date=clean_up($statrow[date]); $time=clean_up($statrow[time]); $by=clean_up($statrow[by]); $type=clean_up($statrow[type]); if($vmessage){ $usersql="SELECT * from `users` WHERE `id`='$by'"; $useres=mysql_query($usersql) or die(mysql_error()); while($row=mysql_fetch_array($useres)){ $avatar=clean_up($row[avatar]); $first=clean_up($row[first]); echo "<tr class='content'><td valign='top'> <img src='pic.php?w=50&h=50&constrain=1&img=photos/$avatar' /><br>$first"; } echo "</td><td valign='top'> $vmessage</td></tr>"; }else{ echo "$type<br>"; } } echo "</table>"; ?> Could someone help me out? Thanks! Hello all, I have an online script that counts the online registered users, guests and bots. The script displays the users names that are online, and the bots names that are online. Since a user can only be logged in at one time on one machine, I have no issues with duplicates here. My issue is that bots appear depending how many are online, it'll say for example: Users Online Matt, Frank, Taylor, Google[bot], Google[bot], Google[bot]. I want to combine the bots, so it'll say: Matt, Frank, Taylor, Google[bot][3]. I've tried doing this with if statements alone, but it seems maybe I'll need a php function to do this with, how would I go about doing this? Thanks in advance, Matt. I need some help please. I have a project that has a login script that is required before moving to a shopping cart and each use a session. I have a login script that i know works separate of the cart and vice versa. The problem is that when i access the cart i get the session errors and it quits working. So i need help with getting the 2 combined so i can run the cart script while a user is logged in. Here is the code i have. This is the login script session: <? ob_start(); session_start();include_once"config.php"; if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){ header("Location: login.php"); }else{ $user_data = "".$_SESSION['username'].""; $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `members` WHERE `username`='".$user_data."'")); } ?> This is the script session for the shopping cart: <?php require_once 'library/config.php'; require_once 'library/category-functions.php'; require_once 'library/product-functions.php'; require_once 'library/cart-functions.php'; $_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI']; $catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0; $pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0; require_once 'include/header.php'; ?> and any help is very much appreciated. In a simple text field in a form.... the browser automatically offers a list, when either when you click in or start typing in the field, of previous entries. My question is: Does anyone know how to control this? Is it possible to give a list of values to the browser, sort of like a ajax search, but all sent before. For example; in one field the user must enter a name, i want the text box to offer name possibilities even before the user has entered any on the form previously... sort of combining the <text> with a <select> menu... with all the name possibilities coming from a mysql table Hey, I have the following two arrays, of which I want to use bits of each from to get another array. Array 1: Array ( [0] => Array ( [shop_id] => 1 [shop_name] => Aldi [shop_district] => 6 ) [1] => Array ( [shop_id] => 2 [shop_name] => Greggs [shop_district] => 6 ) [2] => Array ( [shop_id] => 3 [shop_name] => Tesco [shop_district] => 6 ) [3] => Array ( [shop_id] => 4 [shop_name] => Morrisons [shop_district] => 6 ) [4] => Array ( [shop_id] => 5 [shop_name] => Ryman [shop_district] => 6 ) [5] => Array ( [shop_id] => 6 [shop_name] => Boots [shop_district] => 6 ) [6] => Array ( [shop_id] => 7 [shop_name] => Superdrug [shop_district] => 6 ) [7] => Array ( [shop_id] => 8 [shop_name] => City [shop_district] => 2 ) [8] => Array ( [shop_id] => 9 [shop_name] => Lizard [shop_district] => 6 ) [9] => Array ( [shop_id] => 10 [shop_name] => Asda [shop_district] => 8 ) [10] => Array ( [shop_id] => 11 [shop_name] => Tesco [shop_district] => 2 ) [11] => Array ( [shop_id] => 12 [shop_name] => Tesco [shop_district] => 8 ) ) Array ( [0] => Array ( [shop_id] => 1 [shop_name] => Aldi [shop_district] => 6 ) [1] => Array ( [shop_id] => 2 [shop_name] => Greggs [shop_district] => 6 ) [2] => Array ( [shop_id] => 3 [shop_name] => Tesco [shop_district] => 6 ) [3] => Array ( [shop_id] => 4 [shop_name] => Morrisons [shop_district] => 6 ) [4] => Array ( [shop_id] => 5 [shop_name] => Ryman [shop_district] => 6 ) [5] => Array ( [shop_id] => 6 [shop_name] => Boots [shop_district] => 6 ) [6] => Array ( [shop_id] => 7 [shop_name] => Superdrug [shop_district] => 6 ) [7] => Array ( [shop_id] => 8 [shop_name] => City [shop_district] => 2 ) [8] => Array ( [shop_id] => 9 [shop_name] => Lizard [shop_district] => 6 ) [9] => Array ( [shop_id] => 10 [shop_name] => Asda [shop_district] => 8 ) [10] => Array ( [shop_id] => 11 [shop_name] => Tesco [shop_district] => 2 ) [11] => Array ( [shop_id] => 12 [shop_name] => Tesco [shop_district] => 8 ) ) Array 2: Array ( [0] => Array ( [SUM(item_price)] => 31.23 [item_shop] => 1 ) [1] => Array ( [SUM(item_price)] => 1.65 [item_shop] => 2 ) [2] => Array ( [SUM(item_price)] => 41.23 [item_shop] => 3 ) [3] => Array ( [SUM(item_price)] => 7.98 [item_shop] => 4 ) [4] => Array ( [SUM(item_price)] => 4.49 [item_shop] => 7 ) ) I'd love if anyone could tell me how I can generate an array that will combine bits of these two arrays, so that using the first array I can get a shop_name and shop_district for each item_shop (aka shop_id). Then I want to get an array with entries that look something like this: [0] => Array ( [SUM(item_price)] => 31.23 [shop_name] => Aldi [shop_district] => 6 ) Thanks so much for your help, it means a lot to me. I'm trying to combine 3 tables (attacks, spells, skills) where it brings in all the information from attacks and spells into the table skills. The common row between all 3 is "name". Here is what I have so far. $query = "SELECT * FROM `skills`,`attacks`,`spells` WHERE (`attacks.name`=`skills.name` OR `spells.name`=`skills.name`) AND `user_id`='".$_SESSION['userid']."'"; Thanks! Hi everyone I have 2 queries which are pulling out results into arrays I think they are right I then insert a new column into each array one with [typeofdonation] as "cash" and one as "card" this is to be used later when outputting the results I then need to combine the 2 arrays into 1 array and then sort the combined array by date showing the latest ones first I then need to output the top 3 results The way the results are outputted is dependant on what [typeofdonation] is as they are outputting and styled differently Here is my code below I have got upto the combining the 2 arrays but am having difficulty doing this Once I have done this I then need to sort the results but I think my code I have tested on each array works ok and so will work once I have the combined array. Final part I am not sure on how to find and use what is in [typeofdonation] to determine the styling and way each of the 3 results is outputted Thankyou in advance for everyone who can hopefully help me in the right direction Peter Code: [Select] <b>Card Donations</b><br><br> <?php $getcarddonations = $wpdb->get_results("SELECT wp_supporters_donations.SFMemberNumber, wp_supporters_donations.KickbackAmount, wp_supporters_donations.MerchantName, wp_supporters_donations.SpendDate from supporter_2_cause RIGHT JOIN wp_supporters_donations ON supporter_2_cause.supp_id=wp_supporters_donations.SFMemberNumber WHERE supporter_2_cause.caus_id = '54' ORDER BY wp_supporters_donations.SpendDate"); //UNION SELECT id, amout, cause, date FROM cashdepo WHERE cause='Lisas charity' AND status='2' ORDER BY id DESC foreach($getcarddonations as $getcarddonations){ $i = 0; while($i < 100) { $data[$i]['member'] = $getcarddonations->SFMemberNumber; $data[$i]['ammount'] = $getcarddonations->KickbackAmount; $data[$i]['merchant'] = $getcarddonations->MerchantName; $data[$i]['date'] = $getcarddonations->SpendDate; $data[$i]['typeofdonation'] = 'card'; $i++; } } function compareItems($a, $b) { if ( $a->date < $b->date ) return -1; if ( $a->date > $b->date ) return 1; return 0; // equality } uasort($data, "compareItems"); print_r( $data ); ?> <br><br><br><b>Cash Donations</b><br><br> <?php $getcashdonationsdb = $wpdb->get_results("SELECT * FROM cashdepo WHERE cause='Lisas charity' AND status='2' ORDER BY id DESC"); foreach($getcashdonationsdb as $getcashdonationsdb){ $i = 0; while($i < 11) { $dataa[$i]['member'] = $getcashdonationsdb->id; $dataa[$i]['ammount'] = $getcashdonationsdb->amout; $dataa[$i]['merchant'] = $getcashdonationsdb->cause; $dataa[$i]['date'] = $getcashdonationsdb->date; $dataa[$i]['typeofdonation'] = 'cash'; $i++; } } uasort($dataa, "compareItems"); print_r( $dataa ); ?> <br><br><br> <b>Combined</b><br><br> <?php $datar1 = ($data); $datar2 = ($dataa); $finalarray = array_combine($datar1, $datar2); //sort uasort($finalarray, "date"); //Print the output print_r($finalarray); ?> |