PHP - Need To Write Text In A Circle
Hi Guys,
Some help here would be most appreciated. What im basically trying to do is create an image like a postmark stamp where the text curves around the inside of the circle. This text is dynamically generated and will basically be a persons name. So I need a circle with the persons name curving inside the circle edge at the top. I have attached a image of a postmark just incase anyone isnt sure what i mean. If anyone could help it would be great. Regards, Jon Similar TutorialsAt the moment i can retrieve information from a DB and display it nicely in a vertical line of boxes (some boxes with extra information as needed). I basically need a version of this with exactly the same information, but instead of a top-down list of divs (boxes), I need them to be displayed going around a circle (starting top centre, going clockwise). Does anyone know if this is possible? And how easy would it be? Any scripts? It's already taken me ages to get the list pulling the appropriate info and displaying in a straight line. Thanks for any help/direction. Added: The number of divs displayed will be variable depending on what's in the DB. So I can't count on their being a certain number. Therefore the 'circle' would need to re-size in some way?! hi all .. I want to write arabic text in image .. this is my code .. <?php header("Content-Type: image/png; charset=utf8"); $im = imagecreatetruecolor(150, 30); // Create some colors $white = imagecolorallocate($im, 100, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); $font = 'tahoma.ttf'; $t = 'إن الدين عند الله الإسلام'; $text=utf8_encode($t); imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagepng($im); imagedestroy($im); ?> I very new to php and all I am simply trying to do is read the contents of a text file and echo it out on the screen. I have tried many things to see what I am doing wrong but it just simply isnt working for me. I know the server I am using has php enabled as well because I have tried a simple echo and it works fine. This is the code I am currently using. <?php $file = fopen(file.txt", 'r'); $read = fread($file, '6') echo $read; ?> also, I have tried this. <?php $file = file_get_contents('file.txt'); echo $file; ?> I have a file.txt on the server I am using in the same directory as index.php, I feel like this should be working but I get no result! Alls I have in the text file is a statement that says "hello world". I'm trying to include a routine to catch an error but it doesn't seem to write to a text file within a function. just using the following simple code, even if I simply try to write a letter it doesn't work
if ($http_status == 200) { return $response; } else { $myfile = fopen("ErrorData.txt", "a+") or die("Unable to open file!"); $txt = date("H:i:sa d-m-Y")." / Error data- / ".json_encode($response)."\r\n"; fwrite($myfile, $txt); fclose($myfile); }
Edited September 13, 2019 by Dvae56 Added code I want to add text to a file, getting it printed out in index.php and later want to edit/delete per row. I give codes page wise. first the form to take data: add.php: Code: [Select] <?php ?> <form method="post" action="add_data.php"> <fieldset> <legend>Student List</legend> Name : <input type="text" name="uname" /><br> Content : <input type="text" name="age" /> <br> <input type="submit" name="submit" value="send" /> </fieldset> </form> Next adding text to a file: add_data.php: Code: [Select] <?php $id = 1; if (file_exists("data.txt")) { $fp = fopen("data.txt", 'r'); $str = fread($fp, filesize("data.txt")); $str_arr = explode("|", $str); foreach ($str_arr as $rec) { if ($rec) { $id++; } } } $mode = (file_exists("data.txt"))? "a" : "w"; $fp = fopen("data.txt", $mode); $line = $id . "--" . $_POST['uname'] . "--" . $_POST['age'] . "|"; $res = fwrite($fp, $line); fclose($fp); header("location:index.php"); ?>In the index.php, I'd like to fetch data and edit them per row: Code: [Select] <?php $fp = fopen("data.txt", 'r'); $str = fread($fp, filesize("data.txt")); $str_arr = explode("|", $str); echo "<table border='1'>"; echo "<tr><td>ID</td><td>Name</td><td>Age</td><td>Option</td></tr>"; foreach ($str_arr as $rec) { if ($rec) { $rec_arr = explode("--", $rec); echo "<tr>"; foreach ($rec_arr as $col) { echo "<td>$col</td>"; } print "<td><a href=\"edit.php?id=$id\">Edit</a>/<a href=\"delete.php?id=$id\">Delete</a></td></tr>"; } } echo "</table>"; echo "<a href=\"add.php\">Add Data</a>"; ?> Next I want to Edit per row: edit.php: Code: [Select] <?php $fp = fopen("data.txt", 'r'); $str = fread($fp, filesize("data.txt")); $str_arr = explode("|", $str); foreach ($str_arr as $rec) { if ($rec) { $rec_arr = explode("--", $rec); $id = $rec_arr[0]; $name = $rec_arr[1]; $age = $rec_arr[2]; if ($id == $_REQUEST["id"]) { echo "<form action='edit_data.php' method='post'>"; echo "Name :<input type='text' name='uname' value='$name' /><br>"; echo "Age: <input type='text' name='age' value=$age /><br>"; echo "<input type='hidden' name='uid' value=$id />"; echo "<input type='submit' value='Edit'>"; echo "</form>"; } } } ?> From edit.php to edit_data.php where I practically try to edit per row: Code: [Select] <?php $fp = fopen("data.txt", 'r'); $str = fread($fp, filesize("data.txt")); $str_arr = explode("|", $str); foreach ($str_arr as $rec) { if ($rec) { $rec_arr = explode("--", $rec); $id = $rec_arr[0]; $name = $rec_arr[1]; $age = $rec_arr[2]; if ($id == $_POST['uid']) { $new_str = $id . "--" . $_POST['uname'] . "--" . $_POST['age'] . "|"; } else { $new_str = $id . "--" . $name . "--" . $age . "|"; } } } fclose($fp); $fp = fopen("data.txt", 'w'); fwrite($fp, $new_str); fclose($fp); ?> The mechanism is simple. Taking datas from a form, explode them to an array and get them into col/row pattern to edit and delete them. But my problem is when I want to edit in index.php page, specially in this part: Code: [Select] print "<td><a href=\"edit.php?id=$id\">Edit</a> It says, undefined index. But I try to catch this $id in the edit.php page, in this manner, as you see in my code: Code: [Select] foreach ($str_arr as $rec) { if ($rec) { $rec_arr = explode("--", $rec); $id = $rec_arr[0]; $name = $rec_arr[1]; $age = $rec_arr[2]; if ($id == $_REQUEST["id"]) { echo "<form action='edit_data.php' method='post'>"; echo "Name :<input type='text' name='uname' value='$name' /><br>"; echo "Age: <input type='text' name='age' value=$age /><br>"; echo "<input type='hidden' name='uid' value=$id />"; echo "<input type='submit' value='Edit'>"; echo "</form>"; } } } Have I done any mistake here? If anyone points out, I'll be obliged. 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> 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? Hello 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 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 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. 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. 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. 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... 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. 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] 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. 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 <?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? |