PHP - How To Find B When I Write A-c
Hi,
sorry if there already is a topic regarding my question.. I probably didn't find the right words to describe it properly.. would appreciate a link if anybody knows
I'm making a search form for an archive and my problem is that the labeling says e.g. "1400-3500 A-C".. Now i don't want to make thousands of entrys for 1 file.. How do i find that one file while searching for a number in between, like "1420" or "B"?
Thanks in advance!
Greetings localhobo
Edited by localhobo, 13 October 2014 - 01:28 PM. Similar TutorialsHello dear friends, let say we have text file (file.txt) i wanna php code that makes me able to write some text to this text file (file.txt) then save it as zipped file to be (zipped.zip) 1) I know how to write , will use this Code: [Select] <?php $File = "file.txt"; $Handle = fopen($File, 'w'); $Data = "Hello phpfreaks\n"; fwrite($Handle, $Data); $Data = "Hello World\n"; fwrite($Handle, $Data); print "Data Written"; fclose($Handle); ?> now the (file.text) will be saved with the following text Code: [Select] Hello phpfreaks Hello World Now the question which i do not know how to save it as zipped file not text file ? OR save it normally as text file (file.txt) then create zipped file of it (zipped.zip) thank you so much for help I want to create a xml-based rss which is readable by RSS readers Code: [Select] <?xml version="1.0"?> <rss version="2.0"> <channel> <title>Title</title> <link>http://link.com/</link> How I can write php strings from a php file into it as Code: [Select] <item> <title><? echo $title ?></title> <link><? echo $link ?></link> <description><? echo $description ?></description> <pubDate><? echo $date ?></pubDate> <guid><? echo $id?></guid> </item> hello how would i write, if $a has 1 or more of $b do something ? for example Code: [Select] if($a >1 $b){ do something }else{ do nothing } or >2 or >3 etc... thanks Code: [Select] if (file_exists("images/".$id."/img01.jpg")) { echo "<a href=\"/v1/images/".$id."/img01.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb01.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img02.jpg")) { echo "<a href=\"/v1/images/".$id."/img02.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb02.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img03.jpg")) { echo "<a href=\"/v1/images/".$id."/img03.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb03.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img04.jpg")) { echo "<a href=\"/v1/images/".$id."/img04.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb04.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img05.jpg")) { echo "<a href=\"/v1/images/".$id."/img05.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb05.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img06.jpg")) { echo "<a href=\"/v1/images/".$id."/img06.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb06.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img07.jpg")) { echo "<a href=\"/v1/images/".$id."/img07.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb07.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img08.jpg")) { echo "<a href=\"/v1/images/".$id."/img08.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb08.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a> "; } if (file_exists("images/".$id."/img09.jpg")) { echo "<a href=\"/v1/images/".$id."/img09.jpg\" rel=\"lightbox\"><img src=\"/v1/images/".$id."/thumb09.jpg\" class=\"img\" border=\"0\" width=\"60\" height=\"60\"></a>"; } This code works but it just seems a bit tedious. I may also include up to 20 images to check if they exist. Better way to do this? I have a web site where users can gain points, when they use my site. For example, if the user spends $10.00 then the user will get 10 points. In my web site there is a list of 10 retails (name). When the user clicks the link it will redirect to retailers website, where user can buy items. How can I find out how much the user has spent on the retailer? Thank you. I am trying to create a query that selects results from a table called matches. The results from this table must be based on whether or not there are results from another table called match_results. The results from the match_results table must be based on whether or not the row has either a home_id equal to the current team id, or a visitor_id equal to the current team id. If the current team id is equal to the home_id of the result from the match_results table, then the home_score must be greater than the visitor_score. If the current team id is equal to the visitor_id of the result from the match_results table, then the visitor_score must be greater than the home_score. In short, I am trying to make a query that finds a team's match record(wins and losses). If the result from the matches table doesn't have any results from the match_results table with the same match id, then it hasn't been played it. I hope this makes sense. Is there any way to do this in one single query? [attachment deleted by admin] like I said I'm not very good in coding. so your help to solve this one is more than appreciate. this is what I want to do.... IF I have an image_id1 in the database please show it. other than that please show me the TBC.jpg picture. in php/sql how this will be write. thanks sebastien Hi, I have a form on my homepage which on submit sends the data to my email. I need to know if it it possible to include in the form a read only field containing the refererid in the URL (for instance, if someone were to have visited my homepage by entering; http://www.mypage.com/?refererid=7777, could I capture that 7777 in one of the form fields so that when the form is submitted I recieve the refererid?) Thanks, any help appreciated... how can i find reference to something like this "navigationID=3" or "navigationID=44" within a string and then re write it to become something like this "/en/content/3/Link_Name"? there could be more than one reference within the string and the integer val (ie 3 and or 44) will not be known. Any help with this would be greatly appreciated. Hi all, I have fwrite() writing to a text file called 'numbers.txt'. The text file content is "23". I learn't fwrite() from the manual, so did: f$fp = fopen('/opt/numbers.txt', 'w'); fwrite($fp, '1'); fclose ($fp); I have used fwrite() to try and make the file content "123", but fwrite() writes over the content of the file, resulting in it just containing "1". I couldn't find anywhere about writing into, rather over, and hoping someone could please help me out. I'm trying to right this code Code: [Select] <option <?php echo $pageName == 'Home' ? 'selected="selected"' : ''; ?>>Home</option> In PHP Here is my attempt I know it's wrong but I can't get it to work. echo "<option> {$row["menuName"]} " == " {$row["menuName"]} " ? " 'selected=\"selected\"'" : " '' > {$row["menuName"]}</option>"; Instead of the == 'home' i want to echo the menuName and the same goes for at the end of the > In the html, in the source code this is all I get Code: [Select] <select name="menuName" value="options"> '' </option> '' </option> </select> Thanks for any help. Hey, What function / how would I find if a string has something? Say I have a string like: $string = 'Hello their! This is my post :) btw, my name is Justin.'; Say I wanted to find out if my name "Justin" is inside that string.. so: whateverfunction('Justin', $string) So I think you should get my idea now though Thanks a lot! The issue I'm having is that this query won't find a max value record if it has less than 5 votes. It'll only show the results of an entry has 5 or greater votes. Why is that? $contest_id = 5; $category_id = 8; $find_entries = $db->prepare("SELECT entry_id, user_id, votes FROM contest_entries WHERE contest_id = :contest_id AND category_id = :category_id AND e_status = :e_status AND votes = (SELECT MAX(votes) FROM contest_entries) LIMIT 1"); $find_entries->bindParam(':contest_id', $contest_id); $find_entries->bindParam(':category_id', $category_id); $find_entries->bindValue(':e_status', 0); $find_entries->execute(); $result_entries = $find_entries->fetchAll(PDO::FETCH_ASSOC); if(count($result_entries) > 0) { foreach($result_entries as $row) { $entry_id = $row['entry_id']; $user_id = $row['user_id']; $votes = $row['votes']; } echo $entry_id; } else { echo 'nothing'; } Edited June 26, 2019 by imgrooot Hi I downloaded a PHP script, copied at localhost and when I run it, it will not display all results instruction says that Globals should be off in PHP.ini and scripts should work while Globals are off. but I can't find php.ini in XAMPP. I tried xampp/apache/bin but I didn't find php.ini what should I do? eg http://www.xxxxxxx.com/index.php?action=viewarti&artid=5 How can I write the content of this link into file. <?php $a = 2; $b = 3; $z = fopen("test.txt", 'a+'); if($a > $b) { echo "A is bigger than B"; } elseif fwrite($z, $b); fclose($z); ?> is there a way to get elseif to write to a file? so if b is bigger than a it writes $b to a file? Can you suggest a better way to write this code (I didn't create it):
<body onload="getParameterByName('url')"> <a href="" id="urllink" >Click Here</a> </body>so, I don't have to change the <body> tag? Hey guys, any suggestions how i could read and write msWord files without using the COM interface. I need to keep all the formatting intact though... any ideas? many thanks |