PHP - Echo A Section Of Another Page
Hi!
I'd like to echo a text section from pageB.php to pageA.php Is it possible to mark it up somehow and tell the browser to echo the variable? I'm thinking something like this should work after some alteration: pageA: <?php echo pageb.php/variable; ?> pageB: <?php $variable = ***the content section I want to be displayed on pageA*** "; ?> I'd be very grateful if someone could help me out. (: Similar TutorialsCan i open a pdf within a page? e.g. within <td> or <table> of htmls so that it appears on a section of a page where someone can just read through and still able to browse the web page. I dont want the PDF downloading or taking the whole page or even opening a new window and filling it. Thanks in advance. hope someone can help me out here, stuck on this page... This page shows the details of the listing they had just clicked on on the previous page. this part works If the person logged in is the person who is looking at the page, the email section does not show. this part works However, the part I cannot get to work, is when the logged in user types their email message and clicks send email. at this point the details of listing stop showing please SOMEONE HELP ME thanks in advance, i hope Code: [Select] <?php // Start the session require_once('startsession.php'); // Insert the page header $page_title = 'Listing Details'; require_once('header.php'); require_once('connectvars.php'); // Show the navigation menu require_once('navmenu.php'); if(isset($_POST['submit'])){ $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the user data from MySQL $query1 = 'SELECT email FROM ob_user WHERE username="' . $user_name . '"'; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_fetch_array($data1); $email = $row1['email']; $to = $email; $subject = 'OurBazzar response to' . $subject . ''; $body = $_POST['email']; $headers = 'From: caleb.jordan.flax@gmail.com'; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } end(); } if (isset($_GET['listing_id']) && isset($_GET['subject']) && isset($_GET['description']) && isset($_GET['price']) && isset($_GET['date']) && isset($_GET['city']) && isset($_GET['state']) && isset($_GET['user_id']) && isset($_GET['category_id'])) { // Grab the score data from the GET $listing_id = $_GET['listing_id']; $title = $_GET['subject']; $description = $_GET['description']; $price = $_GET['price']; $date = $_GET['date']; $city = $_GET['city']; $state = $_GET['state']; $userid = $_GET['user_id']; $categoryid = $_GET['category_id']; } // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the user data from MySQL $query = 'SELECT username FROM ob_user WHERE user_id="' . $userid . '"'; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); $query1 = 'SELECT name FROM ob_category WHERE category_id="' . $categoryid . '"'; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_fetch_array($data1); $user_name = $row['username']; $category_name = $row1['name']; echo '<table>'; echo '<tr><td colspan="2"><strong>' . $title . '</strong></td></tr>'; echo '<tr><td>Created by: </td><td>' . $user_name . '</td></tr>'; echo '<tr><td>Date created: </td><td>' . $date . '</td></tr>'; echo '<tr><td>Location: </td><td>' . $city . ', ' . $state . '</td></tr>'; echo '<tr><td>Category: </td><td>' . $category_name . '</td></tr>'; echo '<tr><td>Description: </td><td>' . $description . '</td></tr>'; echo '</table>'; if ((isset($_SESSION['username'])) && ($_SESSION['username'] != $user_name)) { ?> <br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Send Email to <?php echo $user_name; ?></legend> <label for="email">Message: </label> <input type="text" name="email" /><br /> <input type="submit" value="Send Email" name="submit"> </fieldset> <?php } require_once('footer.php'); ?> This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=318858.0 anyone know how to get rid of an echo when you hit refresh on the browser? My browser is remembering the echo from with in a if statement when refresh is hit even if the if statement remains false on refresh. Hey guys, I m not an expert in PHP but i want to learn php now. So the question is, So i have 2 machines that I want to communicate; let's say 192.168.1.5 and 192.168.1.7 And then, there is a php called test_main.php in 192.168.1.5, then test.php in 192.168.1.7 My goal is to call test.php and then capture the echo result... is it possible? kinda like: in test_main.php Code: [Select] <?php echo file_get_contents("http://192.168.1.7/test.php?test=123123"); ?> in test.php Code: [Select] <?php echo "HELLO WORLD!"; ?> so the output when i call test_main.php is "HELLO WORLD!" Thanks guys! Appreciate it P.S. Maybe the function that I m using is incorrect? Please let me know of another function to use? Hello,
I successfully build a form, and I have a few echo's which will echo out error messages when an input box is left empty. The echo messages used to be on the same page while I was using PHP_SELF, now that I've separated the script from the form it will now be shown on a new empty page and the user has to use the browser's navigators to navigate back. I'd still like to keep my script from the form separated for read-ability reasons, but I'd also like to have the echo messages outputted on the same page as the form. How can I do that? I'm a newbie, so excuse this basic question. P.S. If somebody can give me a tip how to position the echo messages in the design, I'd appreciate it a lot, because it sometimes messes up the design. Need help with some whiles, etc., and .php page refreshes. $num; Comes from mysql_num_rows from a database table's regular 'select'. And gets the row id numbers for every row that the id numbers are listed in order. $totalrows comes from another select but is select * instead. And pulls the total rows in the whole table instead there are 49 rows in the whole table. I'm trying to get the page to show 5 table rows at a time like the following, but then when the page is still open on next page refresh to show the next 5 rows and continue that way. This following: Quote PHP Code: <?php $i=$num; if ($num == 5); {echo "The number is " . $num . "<br />";} do {$i = $i + 5; echo "The number is " . $i . "<br />"; } while ($i<$totalrows); ?> Brings up these results: The row number is 10 The row number is 15 The row number is 20 The row number is 25 The row number is 30 The row number is 35 The row number is 40 The row number is 45 The row number is 50 Shows all these on the page at the same time. I'm trying to get these to only show the 5 rows after every page refresh instead. Please let me know how to do that, and whether it can be done without any cookies. I don't know if there is a better way to show the first 5 separate like I have it. Thank you very much for your help. Hi,
I have this snippet in my page:
<?php echo $EM_Booking->get_price(true) * $EM_Booking->get_spaces(); ?>The page executes with no hitches except the price is not multiplied by the spaces. I get and echo of "0". I'm new to this. Any help would be greatly appreciated and thanks! Hello, I am trying to echo a message before redirecting the visitor to another page. The destination is a variable. This is what i have so far: Code: [Select] <?php if (array_key_exists($_GET[id],$links)) { $red = $links[$_GET[id]]; header("HTTP/1.1 301 Moved Permanently;"); header("Refresh:3; url=$red"); echo "You will be redirected to.."; } else { header("Location: http://www.example.com"); } exit(); ?> The problem is that it works in Firefox, but not IE. In IE it will work if there is no message and no delay, like the code below: Code: [Select] <?php if (array_key_exists($_GET[id],$links)) { $red = $links[$_GET[id]]; header("HTTP/1.1 301 Moved Permanently;"); header("Location: $red"); } else { header("Location: http://www.example.com"); } exit(); ? Does anybody have any idea, what is wrong with this code? Thank you in advance! Hi, I wonder if I somebody can help me I have three drop down lists which are populated from data thats stored in my sql database. I also have a table which is echoed from the database all on the same page. What i want to do is allow users to select values in the drop down lists which will then echo different results below in the table. Is this possible. So on page load it will show all of the info in the html table. Then when the user changes the drop downs and clicks submit it will change the query to something SELECT dropdown1 value FROM users where Dropdown2 = 1 AND Dropdown3 = 2 etc. Is this possible to display this information on the same page using the dropdown list or does it need to load a different page as the client side is trying to edit a server side script? If its possible please can someone give me an example. Thanks in advance Edd i have built pages that paginate with 10 rows per page (some pages show more but for the moment i want to focus on this particular page)
//Define Some Options for Pagination $num_rec_per_page=10; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * $num_rec_per_page; $results = mysql_query("SELECT * FROM `ecmt_memberlist` WHERE toonCategory='Capital' AND oldMember = 0 ORDER BY CONCAT(MainToon, Name) LIMIT $start_from, $num_rec_per_page") or die(mysql_error()); $results_array = array(); while ($row = mysql_fetch_array($results)) { $results_array[$row['characterID']] = $row; }The above sets the variables for the pagination and below the results are echo with 10 rows per page then i show the pagination links: <?php $sql = "SELECT * FROM `ecmt_memberlist` WHERE toonCategory='Capital' AND oldMember = 0 ORDER BY CONCAT(MainToon, Name)"; $rs_result = mysql_query($sql); //run the query $total_records = mysql_num_rows($rs_result); //count number of records $total_pages = ceil($total_records / $num_rec_per_page); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"><div style="width:100%; text-align:center;"> <ul class="pagination"> <li class="selected"> <?php echo "<a href='capitalmember.php?page=1'>".'«'."</a> ";?> </li> <? for ($i=1; $i<=$total_pages; $i++) { echo "<li><a href='capitalmember.php?page=".$i."'>".$i."</a></li> "; }; ?> <li class="selected"> <? echo "<a href='capitalmember.php?page=$total_pages'>".'»'."</a> "; // Goto last page ?></li> </ul></div> <?php $pageNr = $page; // Get Current Page Number $from = $pageNr * $rowsPerPage; // 3 * 10 = 30 // 3 * 10 = 30 $to = $from + $rowsPerPage; // 30 + 10 = 40 echo $pageNr; /* Result: From page 30 to 40 */ ?></td> </tr> </table>this works great and shows me 10 results per page, what i need to work out and work on next is: echo the number of results above the records (for example: "showing records 1 to 10" and then on page 2 "showing records 11 to 21" and page 3 "showing records 22 to 32" how can i work out the maths for this echo? i was thinking along the lines of; <?php $pageNr = $page; // Gets Current Page Number $from = $pageNr * $rowsPerPage; // 3 * 10 = 30 $to = $from + $rowsPerPage; // 30 + 10 = 40 // Now Show Results echo $from; // Echo from echo $to // Echo to ?>but i'm still working on this.. then i need to look at shortening the amount of page links on the page if for example i have 500 records it shows me links 1 to 50 and eats up the page.... Appreciate any help and light onto my problems. Many thanks Edited by jacko_162, 11 January 2015 - 05:43 PM. Here's the code, this is the PHP in my html contacts page (that IS in fact saved with a PHP extension): <div class = "centercontainer"> OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> Hi php freaks I've been learning php, but what confuses me are the arrays. I have ini file, i want to get the data from file and add it to the database. Every section makes a new table and all they keys are added with their values. I figured out how to get the keys and how to see the values, but how can i get the name of the sections. Furthermore, how do i know what keys belong to what section. I am really grateful for person who helps me to realize how to be a good friend with those complicated arrays. Hey guys so I am making an App website and somehow need to make a developer section. So like developers can come and setup their app name,description etc. Then be able to program there own app and use like an API service to get the user username etc. So what would I need to let developers do a such thing like let them make an API key and all that is there some tutorial to make such service. (This will be an important feature to my website so please help, thanks)
I would love to add a comment section to my music blogging site. Does anyone have some simple code that they would not mind sending me? or at least helping me with this situation? Hello. Well I haven't any code for this, but its only a question. Do you think it would be possible for PHP, to make and image or draw one from just a blank JPG. Then placing text on the image. That is possible and quite simple. But do you think it is possible to say. Say if you have 3 different set of texts on the image. Click here for 1 Click here for 2 Click here for 3 And also for the script to link those text to different web addresses. But all still workable with a dynamic signature EG [ img ] [ / img ] Basically its a dynamic signature with links on it is what i am trying to say. Do you think its possible? Or am I thinking to big. I don't even really know how to title it. I have this piece of code, i wrote. it works with wordpress api but honestly i don't think that matters much. what it does, is pick $ci number of categories, and then picks 2 posts from each category. it then assigns the image in/attached to that post to an array, to be used later. this all works fine, the problem is when it picks a post that doesn't have an image. right now, it can't tell that. writing in a bit to be able to tell whether there is an image or not should be easy. i'm thinking it can be as basic as file_exists or as complicated as parsing the post. the part i have the problem with - is how do i make it go back and pick another post/category when it comes up short? more than once? i want it to keep going back until it comes up with an image. i'd rather not expand the search any farther than necessary Code: [Select] <?php if ( false === ( $scroller = get_transient( $stransient ) ) ) { if (!is_array($scroller) || count($scroller)==0) { $args = array( 'type' => 'post', 'parent' => 18, 'exclude' => 63, 149, 278, 62 ); $companies = get_categories( $args ); while (count($companies) > $ci){unset($companies[array_rand($companies)]);} shuffle($companies);$truckco= array(); foreach ($companies as $company){ $argus = array('numberposts' => 2, 'orderby' => 'rand', 'post_type' => 'post', 'category' => $company->cat_ID ); $listings = get_posts($argus); foreach($listings as $tn=>$post) { $truckco[$company->slug]['truck_'. $tn]['image'] = get_the_image( array( 'image_scan' => true, 'format' => 'array', 'width' => '172', 'height' => '129' ) ); $truckco[$company->slug]['truck_'. $tn]['pid'] = $post->ID; } } ?> thank you |