Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Percentage relevance you mean? You'll want full text searching. There was a tutorial on here, but it appears to have disappeared.
  2. Are you sure its London.php with a capital L and not london.php?
  3. The manual explains it - you define the centre points (x,y) and the height and width of the ellipse. For a circle, these are the same.
  4. You don't even need the function: <?php $str = $_SERVER['PHP_SELF']; echo $str[1]; //using 1 rather than 0, since 0 is the forward slash ?>
  5. Well, for a simple dot, you can load your map with one of the imagecreatefrom functions (www.php.net/imagecreatefromgif, www.php.net/imagecreatefrompng etc). You can then set the pixel to a particular colour with imagesetpixel() However, if you're wanting to draw a circle, things get more complicated. Even if you act as if the circle is a square, you'll need to consider the extreme points of the square when working out where it can be placed.
  6. Unless i'm being blind, you've not shown us the performExport() function.
  7. Something like: <?php function defineSpot($xlower, $xhigher, $ylower, $yhigher){ $x = rand($xlower, $xhigher); $y = rand($ylower, $yhigher); $objects[0] = array(112,12,0,0); $objects[1] = array(15,17,54,12); $objects[2] = array(80,12,69,53); $objects[3] = array(16,100,172,12); $errors = FALSE; $found = FALSE; while($found === FALSE){//while we havnt found somewhere to place ot foreach($objects as $v){ //cycle through each object to see if there is a problem if($iconx >= $v[0] & $icony >= $v[1] && $iconx <= $v[2] && $icony <= $v[3]){ $errors = TRUE; break; } } if($errors === FALSE){//if after going through everything, errors is still false, then we've found the position $found = TRUE; }else{ $x = rand($xlower, $xhigher); $y = rand($ylower, $yhigher); } } $spot = array($x,$y); return $spot; } $spot = defineSpot(0,200,0,200); echo 'X co-ordinate:'.$spot[0].'<br />Y Co-ordinate:'.$spot[1]; ?> That should do it, but you'll need to run it a few times to check its working. Also, you might want to add a counter inside the loop, and exit after a large number of iterations - in case it's not possible to place given the restrictions and objects (will stop a continuous loop)
  8. The line you need to add to your .htaccess file is: AddType application/x-httpd-php .png
  9. Take a look at this FAQ here: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html
  10. First off, you actually need to send the user to dirupdate.php - not have it as onclick attribute. Second, you seem to pass the title of the website in the url, but then use the ctype_digit() function on it. Surely the title is not numeric? You would be better off using the ID - something which should be unique. Try this as your first page: <table width='100%' border='0' class='panel'> <tr> <td>Website</td> <td align='right'>Popularity</td </tr> <?php $query = "SELECT * FROM directory ORDER BY pop"; $result = mysql_query ($query); while ($row = mysql_fetch_assoc ($result)) { $id = html_entity_decode($row['id']); $title = html_entity_decode($row['title']); $www = html_entity_decode($row['www']); $pop = html_entity_decode($row['pop']); $desc = html_entity_decode($row['description']); echo '<tr><td width="50%"><A HREF="dirupate.php?id='.$id.'&www='.urlencode($www).'" target="_blank">'.$title.'</A></td><td width="50%" align="right">'.$pop.'</td></tr>'; } ?> </table> And this as dirupdate.php: <?php include("../login/include/session.blc");//i assume this is your database connection? $id = (int)$_GET['id']; //type casting to ensure it is an integer $www = urldecode($_GET['www']); $query = "UPDATE `directory` SET `pop` = (pop +1) WHERE `id` = $id"; $result = mysql_query($query) or die(mysql_error()); header("location:$www");//forward the user to the destination ?> Oh, and finally, any reason for all the html_entity_decodes?
  11. Well, you can set up apache to parse files with extensions other than .php as php files. Therefore, you can set up apache to parse .png files as php files. Of course, this would mean any images that you normally use that are png files would be a problem, but you could use a .htaccess file, placed in the appropriate sub directory, to ensure this only covers this particular thing. See this tutorial: http://www.phpfreaks.com/tutorials/34/0.php Other than that, you would probably have to generate the images prior to them being used, save them on the server as .png images, which could then be used. This would remove the dynamic aspect, but would still allow users to generate their own signitures.
  12. Things don't work like that. PHP is a server side language. By the time things get to the browser, it has been parsed. You cannot perform an onlick event in that way; you must make another request. That request can either be in the form of another page load, or an AJAX request, which would work in the way you want it to. The first method is much easier however; you would link to another page, upate the database, and forward the user onto the page in the URL.
  13. A very simple way of doing it: [code] <?php if(isset($_POST['submit'])){ unlink($_POST['file']); echo $_POST['file'].' deleted'; } ?> <form action="<?php echo $_SERVER['phpself']; ?>" method="POST" /> <?php echo '<select name="file">'; foreach(glob('*.*') as $file){ echo '<option value="'.$file.'">'.$file.'</option>'."\n"; } echo '</select>'; ?> <input type="submit" name="submit" value="Delete!" </form> [/code] You might want to secure that a bit though.
  14. A circle makes things a little more complicated. However, i suggest that whilst you use a circle for display, for the purposes of positioning, you treat it as a square. It'll be much easier to work out where it can/cannot go if its a square.
  15. Well, the second parameter of ftp_delete is the path to the file. You appear to be just using the file name?
  16. So its not a single dot. Its a square. imagecreaterectangle() 3: Fairly simply alteration then, you still use the rand() function to generate the top left co-ordinates, and work out the bottom right by adding 10 to them. Of course, you will now need to reduce the area that you generate the random co-ordinates for by 10. e.g. if you want to place something randomly between 20,20 and 80,80 then you need to get a random number between 20 and 70 for the x and y co-ordinates, since you add 10 to these for the bottom right corner.
  17. Yes, you don't have a loop. Try: <?php ## video for testing $video = '<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/w_1516P6zE8"></param> <param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/w_1516P6zE8" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"> </embed></object>'; ## show 2 ontop of each other $i = 0; echo '<table align="center">'; for($x=0;$x<4;$x++){ if ($i==0) { echo '<tr><td>'.$video.'</td>'; } else { echo '<td>'.$video.'</td></tr>'; } $i++; $i=$i % 2; } echo '</table>'; ?>
  18. Use the HTML meta tag: <meta http-equiv="refresh" content="2;url=http://www.google.com"> Would redirect to google after 2 seconds.
  19. Question 1: A single dot? imagesetpixel() - though i think you might find that might be too small. www.php.net/gd - take a look. That's what you can do. Question 2:Well, for each item, you could store its four extreme co-orindates (assuming square/rectangular shapes), cycle through each object, and check to make sure it doesn't overlap: <?php $objects = array(); //xstart,ystart,xfinish,yfinish $objects[0] = array(10,10,30,30);//perhaps a house $ojects[1] = array(40,10,45,50);//a fence? $iconx = 20;//x co-ordinate $icony = 20;//y co-ordinate $errors = FALSE; foreach($objects as $v){ if($iconx >= $v[0] & $icony >= $v[1] && $iconx <= $v[2] && $icony <= $v[3]){ $errors = TRUE; break;//no need to continue looking through the array } } if($errors){ echo 'That image cannot be placed there!'; }else{ echo 'Place that image there'; } ?> If you are using non-square objects, it might be easier to store the individual pixels which you cannot allocate a position to. You could then just use the in_array() function to check to see if the pixel you are going to place your icon on is within this set of dissallowed pixels. Question 3: Well, assuming the single pixel: <?php //create image $iconx = rand(20,80);//define minimum and max for x and y positions $icony = rand(20,80); imagesetpixel($image,$iconx,$icony,imagecolorallocate($image,255,0,0)); ?>
  20. Try this FAQ here: http://www.phpfreaks.com/forums/index.php/topic,95426.0.html It's for database results, but it should't be too hard to modify it for your purpose.
  21. Question 1: Given the fact that you want to make different icons, it would possibly be best to simply 'draw' onto an existing image. Rather than using the imagecreate() function, use the imagecreatefromgif/jpg/png functions to load your 'map'. Then, draw your shapes onto your map using, perhaps, imagefilledpolygon() If you don't want to draw the icons, then you can use the imagecopy() or imagecopymerge() functions to copy your existing icons onto your map Question 2: It's a matter or knowing where everything is. If you know where your fences etc are, then simply don't allow any icon to be placed there - if you check the top left, top right, bottom left and bottom right potential co-ordinates of an icon against areas which someone cannot be placed, you can determine wether or not to place them there. Question 3: I assume this is for the random placing of the person? Couldn't you juse use the rand() function to generate a place for them witin the given parameters?
  22. I don't really undestand your description of the problem. Moreover, i can't actually see any sorting being done on the data. All i see is : <script src="sorttable.js"></script> Which isn't overly helpful. Is there some links generated by that? How is the sort performed - there are no ORDER BY clauses in your queries?
  23. Set the names like: <input type="checkbox" name="checkbox[]" value="<?php echo $id;?>" >
  24. Entirely possible. If you want somone to do it for you, head over to the freelance forum. This isn't the place for people to just do stuff for you. If you have a go yourself, and get stuck, then come back and we'll help you out.
  25. Surely a fourth person giving the same opinion will be enough? Databases were designed for storing data, for accessing data, for sorting data etc. Files were not. Use the right tool for the job!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.