PHP - Select If In A Long Text Char Line
Code:
Code: [Select] PostInfo,color-main,Newman,not-collapsed;Friends,color-main2,Top Friends,not-collapsed||Twitter,color-main2,Twitter,not-collapsed;Signature,color-main2,Signature,not-collapsed;AboutMe,color-transparent,About Me,not-collapsed Now I want make a function like if PostInfo = "not-collapsed" = do this/etc, So simply, how do I extract some content out of this and then use each thing to equal to if it's 'not-collapsed' or 'collapsed' ? Very hard but i think possible? ty Similar Tutorialshello I want select first 500 char of my text and insert it as intro text and all of them for full. anyone can help me? thank you Hi, I have an html page with multiple image tags inside it. I'm wanting to get the full URL of a specific image within that file. The specific image I'm looking for must start with 'http://www.mysite.com/images/' in the src part of the tag to make sure I'm getting the correct image. To find the occurence, I'm using strpos() to find the character position of the string match. What I then need to do is complete the rest of the URL to get the image name and then output this. So basically I need to get the string that comes after 'http://www.mysite.com/images/' and end when the speech mark occurs to close the src part of the image tag. This will then give me the full URL of my image. How do I do this? Or is there a better way to do this? Thanks. If I break up this long line of code will it still work correctly? Original... Code: [Select] define('WEB_ROOT', ENVIRONMENT === 'dev' ? 'http://localhost/example.org/' : 'http://example.org/'); Desired... Code: [Select] define('WEB_ROOT', ENVIRONMENT === 'dev' ? 'http://localhost/example.org/' : 'http://example.org/'); Or maybe... Code: [Select] define('WEB_ROOT', ENVIRONMENT === 'dev' ? 'http://localhost/example.org/' : 'http://example.org/'); Debbie I have a text file that contain something like this : question.txt ------------------------ 12/10/2010 Quest : Was a web designer really care about your web security other than thinking so hard to design your web just based on how the web will looks like?. >>from:sombody@somwhere.com,opinion=not at all,comment:your site are cool 11/10/2010 Quest : Was a web designer really love his girl friend in other side they r almost got no time dating with her? >>from:sombody@somwhere.net,opinion=he loves computer,comment:your site are waste. ------------------------- All i need to do is, grabing all informations after the char ">>" and write it to another text file name "output.txt" that will contain : output.txt --------------------- from:sombody@somwhere.com,opinion=not at all,comment:your site are cool from:sombody@somwhere.net,opinion=he loves computer,comment:your site are waste. --------------------- can some one show me the way? thanks. Hi all, The code creates 4 select boxes.The user clicks on one item in each of the boxes and these are entered into the SQL statement.Trouble is I keep getting error after error all referring to line 59(the SQL statement line) can any keen eyed PHP freak see what I am doing wrong(or even if the whole of the code is any good)..Not too experienced with php so any comments suggestions(or laughs) greatly appreciated. <!DOCTYPE HTML> <html> <body> <select name = "author"> <option value="kendavies">ken davies</option> <option value="arthursmith">arthur smith</option> <option value="gillrafferty">gill rafferty</option> <option value="mollybrown">molly brown</option> <option value="gilbert riley">gilbert riley</option> <option value="colinwilson">colin wilson</option> <option value="jamesgreen">james green</option> <option value="arnoldlaing">arnold laing</option> <option value="cathyellis">cathy ellis</option> <option value="carolreed">carol reed</option> </select> <select name = "publisher"> <option value="yonkers">yonkers</option> <option value="blueparrot">blue parrot</option> <option value="zoot">zoot</option> </select> <select name = "yearpublished"> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> </select> <select name = "genre"> <option value="adventure">adventure</option> <option value="thriller">thriller</option> <option value="crime">crime</option> <option value="biography">biography</option> <option value="romance">romance</option> </select> $aa = "author" $bb = "publisher" $cc = "yearpublished" $dd = "genre" <?php $aa = "author"; $bb = "publisher"; $cc = "yearpublished"; $dd = "genre"; mysql_connect ("localhost","root","") or die(mysql_error()); mysql_select_db ("authors") or die(mysql_error()); $strSQL = SELECT * FROM `books` WHERE author = '".$aa."' AND publisher = '".$bb."' AND yearpublished = '".$cc."' AND genre ='".$dd."'" "; $rs = mysql_query($strSQL;); while($row = mysql_fetch_array($rs) ) { print $row ['ID']."<br/>"; print $row ['author']."<br/>"; print $row ['booktitle']."<br/>"; print $row ['publisher']."<br/>"; print $row ['yearpublished']."<br/>"; print $row ['genre']."<br/>"; print $row ['copiessold']."<br/>"; } mysql_close(); ?> </body> </html> Hello all , here is another problem of my project. I need to create a textarea , drop down list and submit button . At first , I can type whatever I want in the textarea , but for certain part I can just choose the word I want from drop down list and click submit , then the word will appear in the textarea as my next word . But I have no idea how to make this works , is there any simple example for this function ? Thanks for any help provided . i have a text from the database and i want to echo just the first line , but i dont know the character = new line i tried those (to know the character) : Code: [Select] if(strpos($question['q_text'],'\n')!==false){echo 'yes';} elseif(strpos($question['q_text'],'\n')===false){echo 'no';} if(strpos($question['q_text'],'<br>')!==false){echo 'yes';} elseif(strpos($question['q_text'],'<br>')===false){echo 'no';} if(strpos($question['q_text'],'<br/>')!==false){echo 'yes';} elseif(strpos($question['q_text'],'<br/>')===false){echo 'no';} all of them are No ! Hi! Basically, I'm making a PHP file that lists things from a file, so if the file contained; '@-Line 1-@@-Line 2-@' it would produce <li><a href="#">Line 1</a></li><li><a href="#">Line 2</a></li>, but I want it so it changes the coding for 1 of every 2 lines. So I've came up with this code: $myFile = "list.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, 100); fclose($fh); $oldtxt = array("@-", "-@"); $newtxt = array('<li><a href="#">','</a></li>'); $newData = str_replace($oldtxt, $newtxt, $theData); $array = explode("</li>", trim($newData)); $lineno = count($array); $linenofinal = $lineno - 1; for($i=1;$i<$linenofinal;$i++){ if(($i % 2)=='0'){ } } The bit that I'm stuck on is inside the if statement. How could I get it to replace for example <li> in line $i with <li class="1in2"> Thanks in advance, Daviga404 =D how can make the text box like line as in the photo
Hey all, i need a function or a way to replace each letter in a string to a star (*) Thanks Hi, I have this very simple code... <?php echo "<code>"; $hFile = fopen("myfile.ini","rt"); while(!feof($hFile)) { $string = trim(fgets($hFile,8)); $c = substr($string,0,1); if($c!="[" && $c!="\n" && $c!="\r" && $c!="") { $i = crc32($string); echo printf("%8X", $i) ."=". $string ."<br/>"; } } fclose($hFile); echo "</code>"; ?> However, it's returning results like this: Code: [Select] 4C20553D=4NATION 7BE5EF8C=4RIP EAAD529E=4SPIDER 4EB7AFA2=4WEED 7367626=4_OR_14 83101629=5CROSS When I wanted leading 0's, like this: Code: [Select] 4C20553D=4NATION 7BE5EF8C=4RIP EAAD529E=4SPIDER 4EB7AFA2=4WEED 07367626=4_OR_14 83101629=5CROSS I've tried "%.8X", which I figured would work... but it just turned all the hashes to 0. Also, which other varients of CRC are commonly used? The results I am getting are not what I expected as from another program... Hi, Im trying to make a script to mass update a load of links in my database but im stuck on the basics, How can i detect a new line in a text area? Anyone know why this dosen't work? Code: [Select] <?php if($_POST[newlinks]) { $newlinks = preg_split("\n", ($_POST['newlinks'])); $i = 1; foreach ($newlinks as $newlink) { echo "$i - $newlink <br />"; $i++; } } else { echo "<form method=\"POST\" action=\"changehost.php\">"; echo "<br /> <strong>Enter the new links to try and replace old ones</strong> <br />"; echo "<textarea rows=\"16\" name=\"newlinks\" cols=\"84\"></textarea>"; echo "<input type=\"submit\" value=\"Submit\" name=\"B1\">"; ?> This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=347272.0 Hi guys, I have script which scraps content from web and writes it down in a text file, now everything seems to be okay. Its scraps and writes well but the problem is when i open that text file one weird character keeps coming after some words which i don't know about. I have attached the text file, will you guys please look at it and tell me how to replace that square looking character into new line in text file. Hi, Have a text file that is being read. I want to print the contents however I want each line of the text file to appear on a new line in the browser. So far $str = file_get_contents('records.txt'); $lines = explode("\n", $str); echo $lines[0]; Help appreciated Hi All, I am exporting data to excel, but run into a problem if the text contains a line break. When it gets to the line break, it cuts off the rest of the text. Here is my printer code: Code: [Select] $file = 'Notes_Export'; $csv_output = array(); $tmp = array(); $tmp[] = 'Created On'; $tmp[] = 'Created By'; $tmp[] = 'Note'; $csv_output[] = '"' . implode('","', $tmp) . '"'; $sql = "SELECT pn.created_on, CONCAT( u.firstname,' ', u.lastname) AS created_by, pn.note FROM prop_notes pn LEFT JOIN users u ON pn.created_by = u.user_id "; $sql .= "WHERE pn.deleted_by IS NULL AND pn.archive = '0' AND pn.property_id = '".$_GET['pid']."'"; $result = mysqli_query($connect, $sql); while($rowr = mysqli_fetch_row($result)) { $tmp = array(); for ($j=0; $j<3; $j++) {$tmp[] = $rowr[$j];} $csv_output[] = '"' . implode('","', $tmp) . '"'; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); // header( "Content-disposition: filename=".$filename.".csv"); header("Content-disposition: attachment; filename=".$filename.".csv"); print implode("\n",$csv_output) . "\n"; exit; Hi My problem is that text that is in my database are showing up next to each other in a line rather than on seperate lines, normally I would have just used <br> but as it's generated from my sql I don't know how to do it. Code: [Select] <ul id="headlines"> <?php foreach ( $results['articles'] as $article ) { ?> <a href=".?action=viewArticle&articleId=<?php echo $article->id?>"><?php echo htmlspecialchars( $article->title )?></a> <?php } ?> </ul> Anyone have any idea? Thanks hello I've some text and I want release download link between it . so I'm using Code: [Select] $finddl = textbetween ('DOWNLOAD:','</div>',$text); but some times $text writer using <!--QuoteBegin--> and <!--QuoteEnd--> not download: and </div>. how I can say that is , if download: unavailable searching <!--QuoteBegin--> and select textbetween ? Thank you |