PHP - Echo A Data As It Loads
Let's say I'm requesting a 5 megabyte data file with cURL. I want to echo it for the user as it gets downloaded with cURL. Is there any way to do this?
I'm also just using cURL as an example, it could be file_get_contents(), or something else as well. Thanks! Similar TutorialsHi 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']}; ?> Hello. I have some "finish" time in ms. (for example 14000 [14s]). Also I have others guy time like 16789ms. I have made function to math difference between times. Code: [Select] function format_time($t) // t = miliseconds { $t1 = 16789; $t2 = 14000; $t = $t1 - $t2; $minutes = floor($t / 60000); $seconds = sprintf('%02d',floor(($t / 1000) % 60)); $ms = sprintf('%03d', $t % 1000); return $minutes . ":" . $seconds . "." . $ms; } echo "+ "; echo format_time($t); So it will be "+ 0:02.789" I still have a problem yet. I need to make this script mathing more than 1 time. I need around 20 other times to be mathed with 1st finish time and the difference to be displayed. And that's my problem. Can you give me examples or clues how can I give this script values in ms? Then, it should math every value and echo it somewhere. Can you help me in it, please? Hello I Have a few problems understanding what to do with this Arrays So if i have a string that echo's : Array ( [TEST1] => Tested 1 [TEST2] => Tested 2 [TEST3] => Tested 3 ) How may i echo the middle line from the array ?? Hi. I have form data being echoed in several date fields on a form. As soon as the form is submitted and the page refreshes, any field i have set as date datatypes, automatically put 0000-00-00. i have every form field echo so that the data is visible after submission but i do not want any date field to display 0000-00-00. i'm currently using this code on a date of birth field, but it still doesnt prevent 0000-00-00 from being displayed. i'd appreciate any assistance you may offer. thanks Code: [Select] <?php if ($DateOfBirth != "0000-00-00"); echo $DateOfBirth ?> I want to print data from response json? I was debug with firebug and show this :
{"umumu":"","levelu":1,"nameu":""}How to echo data array just levelu. But i don't know how to make it? thanks Hi There, I'm feeling really dumb but i can't figure out how to get the data from an array that has been converted from xml so I can put it into a table. I've tried looping through based on simple array code but i just get array to string errors. my code looks like this $projects = array(); $xml=simplexml_load_string($response) or die("Error: Cannot create object"); foreach($xml->Jobs->Job as $item) { $projects[] = array( 'job_no' => (string)$item->ID, 'job_name' => (string)$item->Name, 'job_due' => (string)$item->DueDate, ); //array_sort_by_column($projects, 'job_due'); print_r($projects); print_r just dumps the whole lot on the page. Id like to grab each of those items and put them in a table cell then sort them by the due date etc. $job_no =""; $job_name =""; $job_due =""; //$item1 = $item->Client->Name; //$job_no = "$item->ID"; //$job_name = "$item->Name"; // $job_client = "$item1"; //$job_start = "$item->StartDate"; //$job_due = "$item->DueDate"; //$job_status = "$item->State"; $date = new DateTime($job_due); $due_date = $date->format('d-m-Y'); echo "<tr>"; echo "<td><a href='managejob.php?job_id=$job_no'><strong>$job_no</strong></td>"; echo "<td>$job_name</a></td>"; echo "<td>$job_priority</td>"; echo "<td>$job_status_1</td>"; echo "<td>$job_status_2</td>"; echo "<td>$job_status_3</td>"; echo "<td>$job_status_4</td>"; echo "<td>$job_status_5</td>"; echo "<td>$job_status_6</td>"; echo "<td>$job_status_7</td>"; echo "<td>$due_date</td>"; echo "</tr>"; } } Any help on this would be much appreciated. Thanks in advance. I have an array ( $exifdata ) which contains the relevant bits that I require, read from exif data, as in the var_dump below. array 0 => string 'Caption' (length=7) 1 => string 'Copy' (length=4) 2 => string 'Camera' (length=6) 3 => string 'Shutter' (length=7) 4 => string 'fNo' (length=3) 5 => string 'ISO' (length=3) 6 => string 'Date' (length=4) 7 => string 'Time' (length=4) 'copy' => string 'Alf Thomas' (length=10) 'caption' => string 'Blue Sky over Auld Reekie' (length=25) 'camera' => string 'Canon PowerShot G9' (length=18) 'shutter' => string '1/800' (length=5) 'fNo' => string 'f/5.6' (length=5) 'iso' => int 200 'date' => string '07:10:2011' (length=10) 'time' => string '09:05:26' (length=8 What I am trying to do is echo each key followed by its relevant data, and thought something like this would work:- Code: [Select] foreach( $exifdata as $key => $value){ echo "$key :, $value <br />"; } The output I get from the above is as below:- 0 :, Caption 1 :, Copy 2 :, Camera 3 :, Shutter 4 :, fNo 5 :, ISO 6 :, Date 7 :, Time copy :, Foucquet caption :, Blue Sky over Auld Reekie camera :, Canon PowerShot G9 shutter :, 1/800 fNo :, f/5.6 iso :, 200 date :, 07:10:2011 time :, 09:05:26 Which more or less does what I want except that what I actually would like is this:- Copy - Foucquet Caption - Blue Sky over Auld Reekie Camera - Canon PowerShot G9 Shutter - 1/800 fNo - f/5.6 ISO - 200 Date - 07:10:2011 Time - 09:05:26 What I can't quite understand is why I am getting the two lists as an output, which simply seems to be identical to the output of the var_dump. To anyone, Apache 2.2.21/PHP5.3.5/MySQL 5.2.36. The following code returns the below errors. I am trying to get the POSTed values into MySQL. There are no other errors. It's like the code stopped at the ?> closing statement. Why would the code not return the 'echo' statements? Any ideas????? Much appreciated....Buchberg Notice: Use of undefined constant id - assumed 'id' in C:\website\do_addrecord_auth_users.php on line 2 Notice: Undefined index: id in C:\website\do_addrecord_auth_users.php on line 2 <? if ((!$_POST[id]) || (!$_POST[f_name]) || (!$_POST[l_name]) || (!$_POST[username]) || (!$_POST[password]) || (!$_POST[firm]) || (!$_POST[email])) { ("Location: /show_addrecord_auth_users.html"); exit; } $db_name="booster"; $table_name="auth_users"; $connection=mysql_connect("localhost", "username", "password") or die (mysql_error()); $db=mysql_select_db($db_name, $connection) or die (mysql_error()); $sql="INSERT INTO $table_name (id, f_name, l_name, username, password, firm, email) VALUES ('$_POST[id]', '$_POST[f_name]', '$_POST[l_name]', '$_POST[username]', '$_POST[password]', '$_POST[firm]', '$_POST[email]')"; $result=mysql_query($sql, $connection) or die (mysql_error()); ?> <HTML> <HEAD> <TITLE>Add a record to Auth Users</TITLE> </HEAD> <BODY> <H1>Adding a record to <? echo "$table_name"; ?></H1> <TABLE CELLSPACING=3 CELLPADDING=3> <TR> <TD VALIGN=TOP> <P>id<BR> <? echo "$_POST[id]"; ?></P> </TD> <TD VALIGN=TOP> <P>First Name<BR> <? echo "$_POST[f_name]"; ?></P> </TD> <TD VALIGN=TOP> <P>Last Name<BR> <? echo "$_POST[l_name]"; ?></P> </TD> <TD VALIGN=TOP> <P>Username<BR> <? echo "$_POST[username]"; ?></P> </TD> <TD VALIGN=TOP> <P>Password<BR> <? echo "$_POST[password]"; ?></P> </TD> <TD VALIGN=TOP> <P>Firm<BR> <? echo "$_POST[firm]"; ?></P> </TD> <TD VALIGN=TOP> <P>email<BR> <? echo "$_POST[email]"; ?></P> </TD> <P><a href="show_addrecord_auth_users.html">Add Another</a></P> </TD> </TR> </TABLE> </BODY> </HTML> Hi all new to php and this forum i have been looking around and im very impressed most questions get answered not like on some of the forums around.
Is there any one kind enough to help me out i have an api call via php and would like to output the results to owlcarousel where do i start with this.
Code i have is:
<?php error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging // API request variables $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; // URL to call $version = '1.0.0'; // API version supported by your application $appid = 'YourAppID'; // Replace with your own AppID $globalid = 'EBAY-GB'; // Global ID of the eBay site you want to search (e.g., EBAY-DE) $query = 'tools'; // You may want to supply your own query $safequery = urlencode($query); // Make the query URL-friendly // Construct the findItemsByKeywords HTTP GET call $apicall = "$endpoint?"; $apicall .= "OPERATION-NAME=findItemsIneBayStores"; $apicall .= "&SERVICE-VERSION=$version"; $apicall .= "&SECURITY-APPNAME=$appid"; $apicall .= "&GLOBAL-ID=$globalid"; $apicall .= "&keywords=$safequery"; $apicall .= "&storeName=yourstorename"; $apicall .= "&paginationInput.entriesPerPage=6"; $apicall .= "&paginationInput.pageNumber=1"; // Load the call and capture the document returned by eBay API $resp = simplexml_load_file($apicall); // Check to see if the request was successful, else print an error if ($resp->ack == "Success") { $results = ''; // If the response was loaded, parse it and build links foreach ($resp->searchResult->item as $item) { $pic = $item->galleryURL; $link = $item->viewItemURL; $title = $item->title; $price = $item->currentPrice; // For each SearchResultItem node, build a link and append it to $results $results .= "<div id='item'><div class='img-wrap' align='center'><img src=\"$pic\" class='itemimg'></div> <div class='itemtxt' align='center'><a href=\"$link\">$title</a>$price</div></div>"; } } // If the response does not indicate 'Success,' print an error else { $results = "<h3>Oops! The request was not successful. Make sure you are using a valid "; $results .= "AppID for the Production environment.</h3>"; } ?> <html> <head> <body> <table> <tr> <td> <div id="result"> <?php echo $results;?> </div> </td> </tr> </table> </body> </html>Im sure is pretty basic but being new to this i have no idea where to start, any advice would be much appreciated. thanks Edited by didz666, 25 January 2015 - 02:22 PM. good evening folks, i have a question regarding the foreach syntax when needing to access something say 3 levels deep into the json architecture here's the example I'm trying to accomplish but when echoing it's not returning the value i need from 3 levels deep. I believe i just don't understand the correct syntax so here's the example any help would he sincerely appreciated.
https://pastebin.com/mEBiMUW5 hi all i am having a big problem that i have been trying to find out what is going on for weeks. i have a echo script that echos data that is in my database, and if i have to refresh the page it will add blank data in my database and the top echo info is blank as well. how can i fix this, and i was wanting to know how do i echo out my info in a textarea. i added a jepg to show you what i mean. here is my code echoforms.php <?php error_reporting(0); require_once('demo.php'); /*Open the connection to our database use the info from the config file.*/ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); $sql = "SELECT company_name, contact_name, address, street_number, postcode, contact_number, contact_email, budget, description FROM 3dartactforms"; $results = mysql_query($sql); if (!$results) { die('Invalid query: ' . mysql_error()); } while($result = mysql_fetch_array( $results )){ echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;">'; echo date("d/m/y"); echo '<p>Company Name: ' . $_POST['company_name'] . '</p>'; echo '<p>Contact Name: ' . $_POST['contact_name'] . '</p>'; echo '<p>Address: ' . $_POST['address'] . '</p>'; echo '<p>Street Number: ' . $_POST['street_number'] . '</p>'; echo '<p>Postcode: ' . $_POST['postcode'] . '</p>'; echo '<p>Contact Number: ' . $_POST['contact_number'] . '</p>'; echo '<p>Contact Email: ' . $_POST['contact_email'] . '</p>'; echo '<p>Budget: ' . $_POST['budget'] . '</p>'; echo '<p>Description: ' . $_POST['description'] . '</p>'; echo '</div>'; } ?> Hello there, I have a problem with this project I'm working on, everything is working fine except for one last thing. it goes as you go to the website, search for a city, choose a hotel from a list in that city, then book a room in that hotel, go to confirmation page then to paypal. everything is fine except after the booking when you go to the confirmation page, it shows correctly the number of nights you booked and everything, all except the rooms, it shows 0 rooms selected, and it doesn't give any price at all. here is the code Code: [Select] <?php include("db.class.php"); class hotelManager { public function getHotel($where) { $where = isset($_POST['where']) ? $_POST['where'] : ""; $dbObj = new DB(); $where = $_POST['where']; $sql = "select * from hotels where city_id IN (select id from cities where name = '$where') or country_id IN (select id from countries where name = '$where')"; $result = mysql_query($sql); $arr = array(); echo "<table>"; while($row = mysql_fetch_array($result) or die(mysql_error())) { echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid'"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\"> <a href=\"hotels.php?id=".$row['id']."\" class=\"titleslink\">".$row['name']."</a> </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> </table>"; echo "</td>"; echo "</tr>"; } echo "</table>"; //return $arr; // array of arrays } /*************************** GET ONE HOTEL *****************************/ public function getHotelbyID($hotelID) { $dbObj = new DB(); $result = mysql_query("select * from hotels where id = '$hotelID'"); return $result; } public function HotelDatatabel($result) { $row = @mysql_fetch_array($result); echo "<table width=98%>"; echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\" class=\"searchtitle\"> ".$row['name']." </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> <tr> <td> ".$row['details']." </td> </tr> <tr> <td> <a href=\"http://".$row['website']."\" class=\"link\">".$row['website']."</a> </td> </tr> </table>"; echo "</td>"; echo "</tr>"; echo "</table>"; } /************************************ GET ROOMS **************************************/ public function getHotelRooms($hotelID) { $result = mysql_query("select * from rooms where hotel_id = '$hotelID'"); echo "<form name='bookingform' id='bookingform' method='post' action='book.php'>"; echo "<input name=\"roomid\" id=\"roomid\" type=\"hidden\" />"; echo "<input name=\"roomnum\" id=\"roomnum\" type=\"hidden\" />"; echo "<input name=\"hotelid\" id=\"hotelid\" type=\"hidden\" value=\"$hotelID\"/>"; echo "<table width=80% >"; echo"<tr>"; echo "<td>Check-in date</td>"; echo "<td>"; echo "<input type=\"text\" name=\"datein\" class=\"date_input\" />"; echo "</td>"; echo "<td>Check-out date</td>"; echo "<td>"; echo "<input type=\"text\" name=\"dateout\" class=\"date_input\" />"; echo "</td>"; echo"</tr>"; echo "<table>"; echo "<table class=\"rooms\" width=100% cellspacing=\"1\" >"; echo "<tr> <th class=\"rooms\">Room Type</th> <th class=\"rooms\">Rate for night</th> <th class=\"rooms\">MAX</th> <th class=\"rooms\">Nr.rooms</th> <th class=\"rooms\">Book</th> </tr>"; while($row = @mysql_fetch_array($result)) { echo "<tr>"; echo "<td class=\"text\" align=center>".$row['room_type']."</td>"; echo "<td class=\"text\" align=center>".$row['price_per_day']."</td>"; echo "<td class=\"text\" align=center>".$row['people']." People</td>"; echo "<td class=\"text\" align=center>"; ?> <select name="nrooms" id="nrooms" onchange=" //alert('<?php echo $row['id'] ; ?>'); //alert(this.value); var exist = 0; if(roomids.length > 0) { for(var hh = 0;hh < roomids.length; hh++) { if(roomids[hh] == <?php echo $row['id'] ; ?>) { exist = 1; //alert(hh); roomnumar[hh] = this.value; } } if(exist == 0) { roomids.push(<?php echo $row['id'] ; ?>); roomnumar.push(this.value); } } else { roomids.push(<?php echo $row['id'] ; ?>); roomnumar.push(this.value); } document.bookingform.roomid.value = roomids; document.bookingform.roomnum.value = roomnumar; "> <option value=0> 0 </option> <?php for($i = 0; $i < $row['available_rooms']; $i++) { $nr = $i+1; $pr=$nr * $row['price_per_day']; echo "<option value=$nr>$nr ($pr\$)</option>"; } echo "</select> </td>"; echo "<td align=center> </td>"; echo "</tr>"; echo "<tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>"; } echo "<tr class=\"rooms\"> <td colspan=\"4\"> </td> <td align=center><input type=\"submit\" value=\"book\" id=\"bookroom\" name=\"bookroom\"/></td> </tr>"; echo "</table>"; echo "</form>"; print_r($_SESSION['order']); $_SESSION['order']=0; unset($_SESSION['order']); } } ?> BookinManager.php Code: [Select] <?php include("hotelsManager.php"); ?> <?php include("config.php"); ?> <?php include("textManager.php"); ?> <?php function echoPostedData() { $dbo = new DB(); $hotelObj = new hotelManager(); $hotelID = $_POST['hotelid']; $datein = $_POST['datein']; $dateout = $_POST['dateout']; $roomid = $_POST['roomid']; $pr = $_POST['pr']; $_SESSION['hotelID'] = isset($_POST['hotelid']) ? $_POST['hotelid'] : $_SESSION['hotelID']; $_SESSION['datein'] = isset($_POST['datein']) ? $_POST['datein'] : $_SESSION['datein']; $_SESSION['dateout'] = isset($_POST['dateout']) ? $_POST['dateout'] : $_SESSION['dateout']; $_SESSION['roomid'] = isset($_POST['roomid']) ? $_POST['roomid'] : $_SESSION['roomid']; $roomsarray = explode(",",$_POST['roomid']); $_SESSION['roomsarray'] = isset($_POST['roomid']) ? explode(",",$_POST['roomid']) : $_SESSION['roomsarray']; $roonsNo = $_POST['nrooms']; $_SESSION['nrooms'] = isset($_POST['roomnum']) ? explode(",",$_POST['roomnum']) : $_SESSION['nrooms']; /********************** hotels ************************/ /******************************************************/ echo "<table width=95% border=0 align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td valign=\"top\">"; echo "<table>"; echo "<tr>"; echo "<td valign=top>"; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='".$_SESSION['hotelID']."' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td>"; $result=$hotelObj->getHotelbyID($_SESSION['hotelID']); $row = mysql_fetch_array($result); echo "<table>"; echo "<tr><td valign=top><strong class=subtitle3>".$row['name']."</strong></td></tr>"; echo "<tr><td class=text valign=top>".$row['location']."</td></tr>"; echo "<tr><td class=text valign=top>check-in Date: ".$_SESSION['datein']."</td></tr>"; echo "<tr><td class=text valign=top>check-out Date: ".$_SESSION['dateout']."</td></tr>"; echo "<tr><td class=text valign=top>"; $newdate = $_SESSION['dateout'] - $_SESSION['datein']; $totalprice = array_sum($_SESSION['totalprice']) echo "</td></tr>"; echo "<tr><td class=text valign=top>Total Price: ".$totalprice."</td></tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td></tr></table>"; } function echoForm2() { ?> <form id="userDetails" name="userDetails" action="" method="post"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top" class="subtitle3"><strong>Your Name</strong><br /> <input type="text" name="name" size="50" /></td> </tr> <tr> <td valign="top" class="subtitle3"><strong>Email address</strong><br /> <input type="text" name="email" size="50" /> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td valign="top" class="subtitle3"> <?php $roomsarray = explode(",",$_POST['roomid']); $roonsNo = explode(",",$_POST['roomnum']); for($i = 0;$i<count($roomsarray);$i++) { if($roonsNo[$i] > 1) { for($j = 0;$j<$roonsNo[$i];$j++) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name </strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } else { if($roonsNo[$i] != 0) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name</strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } } ?> <hr> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit" id="submit" value="Make the reservation" /> </td> </tr> </table> </form> <?php } ?> Code: [Select] <?php include("includes/bookinManager.php"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <th align="left" valign="top" class="formtable"> Booking Data </th> </tr> <tr> <td valign="top"> </td> </tr> <tr> <td valign="top"> <?php echoPostedData(); ?> </td> </tr> <tr> <td valign="top"> </td> </tr> </table> </td> </tr> <tr> <td valign="top"><img src="images/spacer.gif" width="28" height="10" /></td> </tr> <tr> <td valign="top"> <?php if(isset($_POST['bookroom'])) {?> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <th align="left" valign="top" class="formtable"> Your Details </th> </tr> <tr> <td valign="top" > <form action="book.php" method="post" id="payPalForm"> <table width="60%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <td>First name :</td> <td><input type="text" name="first_name" /></td> </tr> <tr> <td>Last name :</td> <td><input type="text" name="last_name" /></td> </tr> <tr> <td>Email address :</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Full guest name :</td> <td><input type="text" name="full" /></td> </tr> <tr> <td>Address :</td> <td><INPUT type="text" NAME="address1" VALUE=""/></td> </tr> <tr> <td>Special Requests :</td> <td><input type="text" name="special" /></td> </tr> </table> </td> </tr> <tr> <td valign="top"> <?php //echoForm2(); ?> <input type="hidden" name="item_number" value="<?php echo $row['id']; ?>"> <input type="hidden" name="cmd" value="_ext-enter"> <input type="hidden" name="redirect_cmd" value="_xclick"> <input type="hidden" name="business" value="tarek_1305896294_biz@gotharious.com"> <input type="hidden" name="item_name" value="Standard Room: Dar El Masyaf Hotel : 2 nights : 9th, july, 2011"> <input type="hidden" name="currency_code" value="USD"> <INPUT TYPE="hidden" NAME="first_name" VALUE="Tarek"> <INPUT TYPE="hidden" NAME="last_name" VALUE="Sabrouty"> <INPUT TYPE="hidden" NAME="address1" VALUE="9th Popastes St."> <INPUT TYPE="hidden" NAME="address2" VALUE="Cleopatra Hamamat"> <INPUT TYPE="hidden" NAME="city" VALUE="Alexandria"> <INPUT TYPE="hidden" NAME="Country" VALUE="Egypt"> <INPUT TYPE="hidden" NAME="lc" VALUE="US"> <INPUT TYPE="hidden" NAME="email" VALUE="tarek@gotharious.com"> <INPUT TYPE="hidden" NAME="night_phone_a" VALUE="+20166005733"> <INPUT TYPE="hidden" NAME="amount" VALUE="100.00"> <?php $roomsarray = explode(",",$_POST['roomid']); $roonsNo = explode(",",$_POST['roomnum']); for($i = 0;$i<count($roomsarray);$i++) { if($roonsNo[$i] > 1) { for($j = 0;$j<$roonsNo[$i];$j++) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name </strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } else { if($roonsNo[$i] != 0) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name</strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } } ?> <input type="submit" name="Submit" value="Submit"> </form> <tr> <td valign="top"> </td> </tr> </table> <?php } ?> I have a navigation list displaying which is a mix of html and php, everything is working fine however now I want to convert this block of code into a function but am having major problems with quotes. The line of code I currently have is $data = $db->query("SELECT * FROM menu")->fetchAll(PDO::FETCH_ASSOC); foreach ($data as $row) { ?> <li><a href="<?php echo $row['url']; ?>" title="<?php echo $row['title']; ?>"><?php echo $row['icon'] . ' ' . $row['header']; ?></a></li> <?php } ?> As I say everything works using the above but now I am trying to echo the full li out and am having major issues with single and double quotes. I currently have echo "<li><a href='#' title='the title'><i class='fas fa-user site-nav--icon'></i> Help</a></li>"; Now I am trying to use the $row['url'], $row['title'], $row['icon'] & $row['header'] as per the top example but I cannot get the combination of quote marks correct, whether to use double, single or a combination. I would be grateful if someone could suggest the correct syntax for the a tag then I can work through the rest. Thanks This portion is kind of stumping me. Basically, I have a two tables in this DB: users and users_access_level (Separated for DB normalization) users: id / username / password / realname / access_level users_access_level: access_level / access_name What I'm trying to do, is echo the data onto an HTML table that displays users.username in one table data and then uses the users.access_level to find users_access_level.access_name and echo into the following table data, I would prefer not to use multiple queries if possible or nested queries. Example row for users: 1234 / tmac / password / tmac / 99 Example row for users_access_level: 99 / Admin Using the examples above, I would want the output to appear as such: Username: Access Name: Tmac Admin I am not 100% sure where to start with this, but I pick up quickly, I just need a nudge in the right direction. The code I attempted to create just shows my lack of knowledge of joining tables, but I'll post it if you want to see that I did at least make an effort to code this myself. Thanks for reading! 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; ?> Heya guys The other day i got the error: [28-Jan-2011 12:07:40] PHP Warning: POST Content-Length of 16970062 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 Basically this means my server provider doesn't allow the total $_POST data on one page to be above 8MB, and being on shared hosting i cannot fix this So, whats the best way to get around this? Ajax? Options and code samples please I think this will help a lot of people as i haven't seen many answers after lots of research on the web. Thanks Danny. This is my code [Page where user uploads files -Edit-Page.php] <?php session_start(); if ($_SESSION['adminlogin'] == 1){ //Run } else { header('Location: Log-In.php'); exit; } $url = $_POST['url']; ?> <!DOCTYPE HTML> <html lang="en-GB"> <head> <meta charset="utf-8"> <!--Search Engine Meta Tags--> <meta name="author" content="Worldwide Lighthouses"> <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel"> <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships"> <!--Stylesheets/Javascript--> <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)"> <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)"> <!--Mobile Browser Support--> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <!--IE Support--> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]--> <meta name="application-name" content="Worldwide Lighthouses"> <meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> <meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> <meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> <meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> <meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> <meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico"> <title>Edit Page | Worldwide Lighthouses</title> <script> <!-- function fixForm(select) { var inputCount = parseInt(select); var newHTML = ''; for(i=1; i<=inputCount; i++) { newHTML += '<label>Thumbnail '+i+' | Size: 200px x 430px | Format: PNG</label>\n'+ '<input type="file" name="thumbnail'+i+'" size="100" accept="image/x-png" class="File">\n'+ '<label>Accompanying Large Image | Size : Large | Format: PNG</label>\n'+ '<input type="file" name="large'+i+'" size="100000000" accept="image/x-png" class="File"><br><br>\n' ; if(i < inputCount) { newHTML += '<br>\n\n'; } else { newHTML += '\n\n'; } } document.getElementById('formInputs').innerHTML=newHTML; } //--> function setVisibility(id, visibility) { document.getElementById(id).style.display = visibility; } </script> <style> input:focus, textarea:focus { background:#9CDCCB; } form#Page { width:80%; margin-top:10px; margin-bottom:10px; margin-left:auto; margin-right:auto; background-colour: rgb(33, 33, 33); /* The Fallback */ background: rgba(33, 33, 33, 0.8); border-radius:10px; padding:20px; } label { display:block; width:100%; color:#FFF; } .TitleInput { width:660px; } .info { width:260px; height:80px; } .url { width:660px; } #IntroParagraph{ width:660px; height:120px; } #MainParagraph{ width:660px; height:240px; } .File { width:660px; } #loading { position: fixed; top: 25%; left: 25%; width: 50%; height: 50%; background:url(../../layout-resources/article-background.jpg); border:3px #333 solid; border-radius:10px; text-align:center; color:#1D5A4B; display:none; } #loadinginfo { position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; } </style> </head> <body> <div id="loading"><div id="loadinginfo"><img src="upload.gif" width="128" height="15" alt="Uploading"><br><h1>Uploading images...</h1><p>Please Wait, this could take a while.</p></div></div> <header> <h1 id="WWLH">Worldwide Lighthouses</h1> <form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box"> <input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off"> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> </header> <nav> <ul id="Nav"> <li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li> <li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li> <li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li> <li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li> <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li> <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li> <li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li> </ul> </nav> <?php if ($_SESSION['adminlogin']==1) { echo '<div id="logout"> <div style="float:left; width:30%; text-align:left;!important"> <a href="Log-In-Accept-Deny.php">Back to Admin Home</a> </div> <div style="float:right; width:70%;"> <a href="Logout.php">Log Out of Admin</a> <p style="font-size:10px;">Always Sign Out when Finished!</p> </div></div>';} ?> <article> <h1 class="Title">Enter Page Information</h1> <div class="Textbox"> <form action="Preview-and-Confirm-Page-Changes.php" enctype="multipart/form-data" method="post" id="Page"> <input type="hidden" value="<?php echo $url ?>" name="url"> <label>Type of Page</label> <br> <input type="radio" name="typeofpage" value="englandtrinityhouse" checked> English - Trinity House <br> <input type="radio" name="typeofpage" value="englandprivate"> English - Privately Owned <br> <input type="radio" name="typeofpage" value="welshtrinityhouse"> Welsh - Trinity House <br> <input type="radio" name="typeofpage" value="welshprivate"> Welsh - Privately Owned <br> <input type="radio" name="typeofpage" value="northernlighthouseboard"> Scottish - Northern Lighthouse Board <br> <input type="radio" name="typeofpage" value="scottishprivate"> Scottish - Privately Owned <br> <input type="radio" name="typeofpage" value="channelislandstrinityhouse"> Channel Islands - Trinity House <br> <input type="radio" name="typeofpage" value="channelislandsprivate"> Channel Islands - Privately Owned <br> <input type="radio" name="typeofpage" value="francelb"> French - Lighthouse Board <br> <input type="radio" name="typeofpage" value="franceprivate"> French - Privately Owned <br> <input type="radio" name="typeofpage" value="switzerland"> Switzerland <br> <input type="radio" name="typeofpage" value="norway"> Norway <br> <input type="radio" name="typeofpage" value="lightshiptrinityhouse"> Lightship - Trinity House <br> <input type="radio" name="typeofpage" value="lightshipprivate"> Lightship - Private <br> <br> <label>Folder Name (Usually title of page with hyphens eg. Beachy-Head) Just provide the last section</label> <input type="text" name="foldername"> <label>Title of Page<br>(eg.Beachy Head Lighthouse. Dont Include | Worldwide Lighthouses, this is automatically added)</label><input type="text" placeholder="Title of Page" name="title" class="TitleInput"><br><br> <input type="hidden" name="MAX_FILE_SIZE" value="100000000000000000000000000000" /> <label>Main Page Image | Size: 170x170px Format:PNG</label><input type="file" name="mainpageimage" size="100" accept="image/x-png" class="File"><br><br> <h2>Information</h2> <label>Date Established:</label><input type="text" placeholder="Date Established" name="established" required="true" class="TitleInput"><br> <label>Current Lighthouse Built:</label><input type="text" placeholder="Date Current Lighthouse Established" name="currentlighthousebuilt" required="true" class="TitleInput"><br> <label>Height (In Metres, Will automatically convert to show feet and metres on same page)</label><input type="number" placeholder="Heigtht in metres" name="height" required="true" class="TitleInput"><br> <label>Date Automated:</label><input type="text" placeholder="Date Automated" name="automated" required="true" class="TitleInput"><br> <label>Date Electrified:</label><input type="text" placeholder="Date Electrified" name="electrified" required="true" class="TitleInput"><br> <label>Range (In Nautical Miles):</label><input type="number" placeholder="Range in Nautical Miles" name="range" required="true" class="TitleInput"><br> <label>Operator:</label><input type="text" placeholder="Operator" name="operator" required="true" class="TitleInput"><br><br> <h2>Media</h2> <label>Link to Video Page: (if none leave blank)</label><input type="url" name="video"> <label>Link to Audio Page: (if none leave blank)</label><input type="url" name="audio"> <h2>Write up</h2> <label>Paragraph:</label><textarea id="MainParagraph" name="paragraph"></textarea> <h2>Thumbnails</h2> <label> Number of Thumbnails </label> <select name="numberofthumbnails" onChange="fixForm(this.options[selectedIndex].text);"> <option value="0">0</option> <option value="2">2</option> <option value="4">4</option> <option value="6">6</option> <option value="8">8</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="16">16</option> <option value="18">18</option> <option value="20">20</option> <option value="22">22</option> <option value="24">24</option> </select> <br><br> <span id="formInputs"> </span> <input type="submit" value="Preview Page" onClick="setVisibility('loading', 'block');"> </form> <?php if ($_SESSION['adminlogin'] == 1){ echo "<br>Logged in on server side."; }?> </div> </article> <footer> <ul> <li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li> <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li> <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li> <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li> <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li> <li><a href="#Top">Back to top</a></li> </ul> <br> <br> &#169; Worldwide Lighthouses <?php echo date("Y"); ?> </footer> </body> Code: [Select] <!-- The Input Form --> <form action="changemail_script.php" method="POST" > <input type="text" name="new_email" /> <input type="submit" name="submit_new_email" value="Submit" /> </form> When I have it as above, and I click submit, then the form loads the script itself and since the database connection variables are included into the header it will not work anymore. Any ideas why it does that? Should rather just include the script file and simply leave the action field empty, or do you have a better suggestion? Hi there, I have a HUGE list of inappropriate words in plain text, but the thing is, I want to use these bad words in an array. But I can't just copy and paste the bad words into the array, as each bad word needs to have two apostraphes aside one another. E.g the array should be: Code: [Select] $bad_words = array('badword1','badword2','badword3'); but my text document just has: badword1 badword2 badword3 How do I format the bad words to have apostraphes aside each other? I don't want to manually go through each word. Thanks Hi All. I have been really struggling with this for a while! When a URL loads I wish to load with parameters entered & those parameters entered on a page but cannot get my head round it. Any help will be much appretiated... So when a user navigates to www.test.com/page.php I wish to to actually pull back www.test.com/page.php?term=&submit=Go Any help will be really really appretiated. Hello,
I've made a function that contains the html header (<head>). When I call that function in a other file, with the header file included, it puts the header function in the body. So all the meta tags are in the body, instead of the head.
Would it be possible to load this all in the head?
The head function does contain the html and head tags. However, without them, it still doesn't want to go to the head.
|