PHP - Concatenation
How do I add a space in my concatenation? What I have down below doesn't work.
$result[0] .$result[1] Similar Tutorialsproblem is when i select unpaid in drop down box it not show the expected result. I dont know wats wrong here I doubt $reg .=" AND status=0 "; find wats wrong Thanks a lot Code: [Select] <?php include("connection.php"); $reg=""; if(isset($_POST['filter'])) { if($_POST['sel'] == "0") { $reg .=" AND status=0 "; } elseif($_POST['sel'] == "1") { $reg .=" AND status=1 "; } elseif($_POST['sel'] == "3") { $reg .=" AND (status=0 OR status=1) "; // echo "<a href='vudetails.php?regno=".$qry2['reg_no']."'>".$qry2['name']."</a>"; } $filter=mysql_query("SELECT * FROM stu_details WHERE dept LIKE '%".$_POST['dept']."%' OR course LIKE '%".$_POST['cors']."%' OR YEAR LIKE '%".$_POST['year']."%' OR room_no LIKE '%".$_POST['dept']."%' OR reg_no LIKE '%".$_POST['dept']."%' OR doj BETWEEN '".$_POST['dept']."' AND '".$_POST['dept']."'".$reg); while($f2=mysql_fetch_array($filter)) { echo "<a href='vudetails.php?regno=".$f2['reg_no']."' >".$f2['name']."</a> <br />"; } } ?> <html><head><title>Filter</title></head> <script type="text/javascript" src="datetimepicker.js"> </script> <script type="text/javascript"> function validate() { var a=document.forms['form']['dept'].value; if (a==null || a=="") { alert("Please enter a search."); return false; } /*else { return true; }*/ } </script> <form name="form" action="" method="post"> <table border="0"> <tr><td> <select name="sel"> <option value="3">All </option> <option value="0">Unpaid </option> <option value="1">Paid </option> </select> <tr><td> Department: <input type="text" name="dept"> <tr><td> Course: <input type="text" name="cors"> <tr><td> Year: <input type="text" name="year"> <tr><td> Room No: <input type="text" name="roomno"> <tr><td> Register No: <input type="text" name="regno"> <tr><td> Date of Join: <input type="text" name="doj" id="from"> <a href="javascript:NewCal('from','ddmmyyyy')"> <img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> To: <input type="text" name="datto" id="todat"> <!--<tr><td>Date: <input text="text" id="dp" name="dp" size="25">--> <a href="javascript:NewCal('todat','ddmmyyyy')"> <img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> <tr><td> <!--<input type="submit" name="filter" value="Filter" onclick="return validate()">--> <input type="submit" name="filter" value="Filter" onclick="validate()"> </table> </form> </html> I have a table (applicants) which has a number of fields including 5 for potential 'parties' - these are party1, party2, party3, party4 and party5. Any particular applicant will always have two parties but could have any number up to 5. I need to export a pdf (which I can do) but I need it to include data drawn from the applicants table in the format: party1, party2 and party3 OR party1 and party2 etc that is, each party has a comma after it except the last but one, which has no comma but an 'and'. (I hope this is clear enough!) I can't work out how to do this for a varying number of 'parties'. Any suggestions/answers gratefully received. I am currently learning Zend/PHP on the fly. I've gone from 0 to 40 in about 2 months, as far as savviness is concerned. I am working on a form that I want to display array information of two things (shortname and fullname) in a drop-down list. I am thinking I need to do some sort of concatenation to achieve this, or would I do an array within an array? The array is defined in a value object and that draws the id, shortname and fullname. Shortname is the defined label in that file. In the form page, i have the LO ['full_name'] => LO ['label']... this inputs the right information into the database, but shows the full name. I want the drop-down to show it as following: Shortname|Fullname. This will be used in a couple of places once I get on the right track on how to accomplish this. I would be accepting of any help, as well as any resourced that could answer my question and help me finish this form. Cheers, ESK I am using the code posted here to do something with a third party software
http://www.interwork...trusted-tickets
however its utterly frutrating that something as simple as
$fullUrl = "http://{$server}/trusted/{$ticket}/{$url}";
returns me the following
moOaH6BAKFMGGszd_IQHTvpAhttp://<server>/trusted/1/views/<dashboard>?format=png
instead of
http://<server>/trusted/moOaH6BAKFMGGszd_IQHTvpA/views/<dashboard>?format=png
completely beats me. Any idea why ? Is it something to do with the variable $ticket which has the value of moOaH6BAKFMGGszd_IQHTvpA in this case ?
I can successfully concatenate strings and vars to assemble a php var using an echo statement like this: Code: [Select] echo "<input type='radio' id='radio_btn_" . $Row['question_number'] . "_0' name='question[question_" . $Row['question_number'] . "]' value='0' checked='checked' />"; However, when attempting to reference the same var in an IF statement, I can't seem to get the syntax right. I know this syntax is wrong, but I list it for reference to describe the issue I am trying to solve. Code: [Select] if ($_POST['radio_btn_' . $Row['question_number'] . '_0'] == '0'){ I also tried curly braces but can't arrive at a solution. Any advise would be appreciated.
Is there a subtle difference between Thank you. I am trying to figure out how to have an if statement in the middle of strings I am trying to concatenate. I have a from that has a address1 and address2, where address2 often does not exist. So I want to only add that line if there is actually content. I was trying something like the following, but that is giving me an error. I am pretty new to php, so I can't seem figure it out. Any help would be greatly appreciated. Code: [Select] "<p><strong>Address 1: </strong><br>" . $address1 . "<br>" if ( isset($address2) ) { echo . $address2 . "<br>" } . $city . ", " . $state . " " . $zip . "</p>" i want to do it with cURL-Multi since this is the most pretty way to do it! Well i am not sure bout the string concatenation. How to do it - Note i want to fetch several hundred pages: see the some details for this target-server sites - /(i have to create a loop over several hundred sites) siteone_dot_com?show_subsite=9009 siteone_dot_com?show_subsite=9742 siteone_dot_com?show_subsite=9871 and so on and so fort how to appy this loop into the array of the curl-multi <?php /************************************\ * Multi interface in PHP with curl * * Requires PHP 5.0, Apache 2.0 and * * Curl * ************************************* * Writen By Cyborg 19671897 * * Bugfixed by Jeremy Ellman * \***********************************/ $urls = array( "siteone", "sitetwo ", "sitethree" ); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $conn[$i]=curl_init($url); curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { $res[$i]=curl_multi_getcontent($conn[$i]); curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> I'm wondering if this is at all possible:- Code: [Select] $i = 7; $row_item['comment$i_name'] = "john"; with the $i in $row_item['item$i_id'] being replaced with whatever $i is set as sort of like this:- $row_item['comment.'$i'._name'] Is this sort of concatenation possible inside array element names as I can't seem to get it to work? Hello dear folks i am currently workin on a little parser with cURL - and i have some questions he How to do the String concatenation with PHP ; note i wanna do it with curl! the target URL: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=572.8745475728288 click all checkbuttons Results: approx 6400 results Here i can provide some "more help for getting the target!" - btw see three detail page: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779&SchulAdresseMapDO=116191 http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779&SchulAdresseMapDO=116270 http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=261.2855969084779&SchulAdresseMapDO=188268 btw: we can loop over the results - with a iteration - especially i wanna know: how to do the String concatenation with PHP ; note i wanna do it with curl! function get_page_data($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); if($output!=false && $_POST['dt']=='No') return $output; curl_close($ch); } for($i=1;$i<=$match[1];$i++) { $url = "http://www.example.com/page?page={$i}"; $data = get_page_data($url); if($data) { $cleaned = string_between('onload="check();">', '</body>', $data); return = stip_tags($cleaned, '<table><tr><td><div>'); } } any and all help will be greatly appreciated love to hear from you best regards Hi - good evening! thanks for the answer and all the help so far Oncemore the "Fetching-part" for a little parser-script: Here we go - new target urls: see the overview: http://dms-schule.bildung.hessen.de/index.html http://dms-schule.bildung.hessen.de/suchen/suche_schul_db.html Search by pressing the button "type" and then choose all schools with the mouse! Results 2400 schools: Here i can provide some "more help for getting the target!" - btw: see some details for this target-server: http://dms-schule.bildung.hessen.de/suchen/suche_schul_db.html?show_school=9009 http://dms-schule.bildung.hessen.de/suchen/suche_schul_db.html?show_school=9742 http://dms-schule.bildung.hessen.de/suchen/suche_schul_db.html?show_school=9871 well - you see i have to iterate over the sites - with a function /(a loop) http://dms-schule.bildung.hessen.de/suchen/suche_schul_db.html?show_school=1000 to 10000 BTW - after fetching the page i have to see which one are empty - those ones do not need to be parsed! Well - i want to do this with curl-multi since this is the most advanced way to do this: I see i have an array that can be filled I have to try it out...!! Well, I'm not pretty sure - but judging by the low level of PHP i have: I think that i may need a double array to define the URLs like: Can i do like so?: $urls = array( "siteone" => "suche_schul_db.html?show_school=%i", "sitetwo" => "suche_schul_db.html?show_school=%i", "sitethree" =>"suche_schul_db.html?show_school=%i" ); $params = array ( for ($i = 1; $i <= 10000; $i++) { // body of loop } // well i have to define the variables in a open form like abvove nand not below: // better than doing it like so: "siteone" => array(9009, 9742, 9871), ); then pass them to curl-multi as: foreach ($urls as $id => $url) { foreach ($params[$id] as => $param) { $i = $id . $param; $finalurl = sprintf($url, $param); $conn[$i] = curl_init($finalurl); I don't know if that's fits the needs tip that i am looking for but I hope so ;-) Can i do like so [see above]? What do yu think. i send you many greetings martin Hi guys; I've managed to find my way into something of a maze. <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> I'm looking at this line in the code. I realise it's currently in the wrong syntax but I'm just trying multiple different variations. At the moment I'm actually just trying to make it go to a static link but my real goal is to - get it to pick up the id number, of the id row I click, and concatenate that with the rest of my address string. Then use that as the href. Something like this: - "'Details/' + $id + '/index.php'" It's really confusing me though inside this loop and for some reason the id number is being picked up as an int, by the looks of things. It's getting above my level of understanding. Any chance one of you masters would through a n00b a lifeline?
This is my code below
<!DOCTYPE html> <html> <head> <title>LifeSaver DB</title> <h1> LifeSaver Database </h1> </head> <body> <table> <tr> <th>Id</th> <th>Location</th> <th>Initials</th> <th>TimeStamp</th> <th>Notes</th> </tr> <?php $conn = mysqli_connect("localhost", "meh", "pas", "DB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM LifeSaver1 ORDER BY id DESC"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { //for href row $id = $row['id']; $Footage = ['Footage']; echo "<tr> <td> <a href="'Details/21/index.php'"?id= . $id .'>" . $row['id'] . "</a> </td> <td>" . $row["Location"] . "</td> <td>" . $row["Initials"]. "</td> <td>" . $row["TimeStamp"]. "</td> <td>" . $row["Notes"] . "</td> </tr>";} //show table echo "</table>"; } else { echo "0 results"; } $conn->close(); ?> </table> </body> <style> table, td, th { border: 1px solid black; margin: auto; } table { border-collapse: collapse; color: #000; <!--font colour --> font-family: monospace; font-size: 18px; text-align: center;} th { background-color: #337AFF; color: white; font-weight: bold; } tr:nth-child(odd) {background-color: #add8e6} </style> </html> Edited February 8, 2020 by JonnyDriller |