
hyster
Members-
Posts
253 -
Joined
-
Last visited
Everything posted by hyster
-
thanks again scootstah, ur a star just encase any1 else has need for this , this is my final code to create a transparent png overlaid with text, rotate 90 deg and save to a folder <?php $nick = 'some source'; $img=imagecreatetruecolor(100,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $degrees = 90; //rotate image $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$nick); imagealphablending($img,false); imagesavealpha($img,true); $img1 = imagerotate($img, $degrees, 0); imagepng($img1, "./img/name/$nick.png"); imagedestroy($img); ?>
-
just come across another issue lol. I cant use any html when using the code, I want to redirect after the code runs. if I put the code into the php it still outputs as plain text not html <meta http-equiv='refresh' content='5; url=./png.php?name=$nick' /> <?php $name = $_GET['name']; $img=imagecreatetruecolor(180,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$name); header('Content-Type: image/png'); imagealphablending($img,false); imagesavealpha($img,true); imagepng($img, "./img/name/$name.png"); imagedestroy($img); ?>
-
thanks scootstah
-
this code works fine apart from it displays the image in the browser, what id like to happen is to have the image save to a folder, I don't understand all the code so I don't no what im looking for <?php $name = 'Hyster'; $img=imagecreatetruecolor(180,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$name); header('Content-Type: image/png'); imagealphablending($img,false); imagesavealpha($img,true); imagepng($img); exit; ?>
-
thanks jacques1, im nearly there. I re-designed the database as u said. I made the 1st row from another query using distinct to get the players name for the columns. do I have to create a new query to populate the 1st td stating what the tank is ?? I cant work out how to start a new row when I new tank is outputted instead of a record row <table border="1"> <?php // populate 1st header row echo "<tr><td>Tank List</td>"; $sql1 = "SELECT DISTINCT nickname FROM player_list "; $result1 = $conn->query($sql1); if ($result1->num_rows > 0) { // output data of each row while($row1 = $result1->fetch_assoc()) { echo "<td>".$row1["nickname"]."</td>"; } } echo "</tr>"; //populate data rows $sql = "SELECT tank_list.name_i18n, tank_list.tank_id, tank_list.name, player_list.account_id, player_list.nickname, garage_list.tank_id IS NOT NULL AS combination_exists FROM player_list CROSS JOIN tank_list LEFT JOIN garage_list ON player_list.account_id = garage_list.account_id AND tank_list.tank_id = garage_list.tank_id where tank_list.level='10' ORDER BY tank_list.name ASC, tank_list.nation ASC, player_list.nickname ASC "; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>".$row["name_i18n"]."</td><td> ".$row["combination_exists"]."</td></tr>"; } } else { echo "0 results"; } $conn->close(); ?> </table> //current output <TABLE border="1"> <TBODY> <TR> <TD>Tank list</TD> <TD>beasthr</TD> <TD>Georgieboii</TD> <TD>Fluffy_Bad_Squirrel</TD> <TD>Angry_Hamster</TD> <TD>Olddevil333</TD> <TD>Hyster</TD></TR> <TR> </TR> <TR> </TR> <TR> <TD>Bat.-Châtillon 25 t</TD> <TD> 1</TD></TR> <TR> <TD>Bat.-Châtillon 25 t</TD> <TD> 1</TD></TR> <TR> <TD>Bat.-Châtillon 25 t</TD> <TD> 0</TD></TR> <TR> <TD>Bat.-Châtillon 25 t</TD> <TD> 0</TD></TR> <TR> <TR> <TD>Bat.-Châtillon 25 t</TD> <TD> 0</TD></TR> <TR> <TD>Bat.-Châtillon 25 t</TD> <TD> 0</TD></TR> <TR> <TD>FV215b</TD> <TD> 0</TD></TR> <TR> <TD>FV215b</TD> <TD> 0</TD></TR> <TR> <TD>FV215b</TD> <TD> 0</TD></TR> <TR> <TD>FV215b</TD> <TD> 1</TD></TR> <TR> <TD>FV215b</TD> <TD> 0</TD></TR> <TR> <TD>FV215b</TD> <TD> 0</TD></TR> <TR> </TR> <TR> <TD>FV215b (183)</TD> <TD> 0</TD></TR> <TR> <TD>FV215b (183)</TD> <TD> 0</TD></TR> <TR> <TD>FV215b (183)</TD> <TD> 0</TD></TR> <TR> <TD>FV215b (183)</TD> <TD> 0</TD></TR> <TR> <TD>FV215b (183)</TD> <TD> 1</TD></TR> <TR> <TD>FV215b (183)</TD> <TD> 0</TD></TR> <TR> </TR> <TR> <TD>E 100</TD> <TD> 1</TD></TR> <TR> <TD>E 100</TD> <TD> 0</TD></TR> <TR> <TD>E 100</TD> <TD> 0</TD></TR> <TR> <TD>E 100</TD> <TD> 0</TD></TR> <TR> <TD>E 100</TD> <TD> 1</TD></TR> <TR> <TD>E 100</TD> <TD> 0</TD></TR> <TR> </TR> <TR> </TR></TBODY></TABLE>
-
im trying to create a html table from 2 SQL tables. the result will be like this page http://bad.x10.mx/cw/view.php but with the columns and rows reversed the tables are GARAGE -> nickname - tank_id(array of values) TANK_LIST -> tank_id(single entry) GARAGE - tank_id only holds X amount of tanks not all in TANK_LIST - tank_id creating the table I don't no how to display a given tank in the correct position in the players column as the GARAGE don't hold every tank, would it be possible to do it purely in SQL or do I have to use php or both :/ atm the only way I can think of doing this is a query for each td cell but since there are 451 TANK_LIST rows and id be searching for 30 players that's a massive amount of query's. I hope I made sense as im confusing myself just trying to explain what im after
-
OMG [$test] is the only thing I didn't try I think :$ massive thanks guys
-
im trying to use a $_GET variable working in the foreach condition but no matter what I try it always comes back as "invalid argument" or "unexpected $variable". I tried to build a string then put it it but get the same results $data$test $output$data$test I spent a few hours on google this but I cant find anything that has a anything but the variable for the array in the source //$output is a json array // works as I want it to foreach ($output['data']['502438129'] as $item) { echo $item['mark'] . '</br>'; } // I get Invalid argument supplied for foreach() $test = $_GET["account_id"]; foreach ($output['data'].$test as $item) { echo $item['mark'] . '</br>'; }
-
I used strcasemp instead of strcmp
-
thanks barand. as usual ur a star
-
this code works fine but id like to sort by the account_name alphabetically. I have found the sort() function but the only examples I can find sort from the "1st" level of an array. sort($output) wont work as there is nothing to sort by I need something like sort($output['data']['500020315']['members']['account_name']) but when I try to use sort ill get an unexpected foreach $output = json_decode($json, true); echo '<table>'; foreach ($output['data']['500020315']['members'] as $item) { echo '<tr><td>'.$item['account_name'] . '</td></tr>'; } ?> </table>
-
im trying to loop the array but its throwing an error on the 500020315 saying its unexpected. echo a single entry works fine but I don't understand why it dosent like the number in the foreach thanks for any help $output = json_decode($json, true); // works fine with single entry echo $output['data']['500020315']['members']['3']['role']; // needs to be looped foreach ($output->data->500020315->members as $item) { echo $item->role . '<br>'; }
-
thanks guys, got it sorted
-
thanks barand, exactly what im after im now stuck on looping the $file, if I put a foreach loop in it only loops for the player column I can not figure out how to replace $ar[1] so it auto loops the file portion while($row = $result->fetch_assoc()) { $str=$row["file"]; $ar=explode(",",$str); echo $row["player"]. '<IMG src="test_files/' . $ar[1]. '"><br>'; } }
-
output is below Array ( [0] => fdg [player] => fdg [1] => ussr-Object263.png [file] => ussr-Object263.png ) Array ( [0] => hyster [player] => hyster [1] => china-Ch19_121.png [file] => china-Ch19_121.png ) Array ( [0] => merc [player] => merc [1] => germany-E-100.png [file] => germany-E-100.png )
-
I have a database with 2 columns, player - file PLAYER - FILE hyster - ussr-Object263.png hyster - ussr-Object268.png merc - germany-E-100.png merc - germany-JagdPz_E100.png what I want to do is create a horizontal table like this <table> <tr> <td>hyster</td><td> ussr-Object263.png ussr-Object268.png </td> </tr> <tr> <td>merc </td><td> germany-E-100.png germany-JagdPz_E100.png</td> </tr> </table> the file part is going to be an image, I can do it vertical by running 2 query's but I will be getting up to 30 names so to many for a vertical system. its the method im stuck on so any pointers in the way to do this please ?? all the code I have so far. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "test"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM players GROUP BY player,file"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo '' . $row["player"]. '<IMG src="test_files/' . $row["file"]. '"><br>'; } } else { echo "0 results"; } $conn->close(); ?>
-
I have a database with 2 columns, player - file PLAYER - FILE hyster - ussr-Object263.png hyster - ussr-Object268.png merc - germany-E-100.png merc - germany-JagdPz_E100.png what I want to do is create a horizontal table like this <table> <tr> <td>hyster</td><td> ussr-Object263.png ussr-Object268.png </td> </tr> <tr> <td>merc </td><td> germany-E-100.png germany-JagdPz_E100.png</td> </tr> </table> the file part is going to be an image, I can do it vertical by running 2 query's but I will be getting up to 30 names so to many for a vertical system. its the method im stuck on so any pointers in the way to do this please ?? all the code I have so far. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "test"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM players GROUP BY player,file"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo '' . $row["player"]. '<IMG src="test_files/' . $row["file"]. '"><br>'; } } else { echo "0 results"; } $conn->close(); ?>