Sponsor for PC Pals Forum

Author Topic: php advice needed  (Read 8344 times)

Offline psp83

  • New Member
  • *
  • Posts: 23
php advice needed
« on: January 20, 2010, 19:34 »
Hi all..

Simon told me to come post here from IDnetters.

I've been coding websites in PHP for over 10yrs now but today i have come across something i need help/advice for.

I have a client that has a website that allows users to upload ads.. width/height (10px,20px to 100px). These dimensions are in a drop down.

Now comes the tricky part.. they want the ads displayed on the home page just like the million dollar home page site (http://www.milliondollarhomepage.com/)

The only data i have to work with is the image and sizes.

Any ideas how i can do this?

Thanks in advance!

Offline Clive

  • Administrator
  • *****
  • Posts: 62249
  • Winner BBC Quiz of the Year 2015,2016 and 2017
Re: php advice needed
« Reply #1 on: January 20, 2010, 19:39 »
Hi psp83 and  :welcome:  Sam is our resident expert on PHP and will be online later tonight.  He is working in Canada at the moment so his 'evening' is a bit later than ours!   :laugh:
Winner BBC Quiz of the Year 2015, 2016 and yet again in 2017.

Offline psp83

  • New Member
  • *
  • Posts: 23
Re: php advice needed
« Reply #2 on: January 20, 2010, 19:44 »
hey,

thats cool, i'm in no rush at the mo, i have 3 weeks to find a solution.

Paul

Offline Simon

  • Administrator
  • *****
  • Posts: 66211
  • First to score 7/7 in Quiz of The Week's News 2017
Re: php advice needed
« Reply #3 on: January 20, 2010, 19:48 »
Hi Paul, glad you managed to fight your way in!  ;D  :welcome:

As Clive said, hopefully Sam should be able to help you with this.
Many thanks to all our members, who have made PC Pals such an outstanding success!   :thumb:

Offline Baz

  • Established Member
  • ****
  • Posts: 767
Re: php advice needed
« Reply #4 on: January 20, 2010, 21:00 »
hey Paul, so youve had your arm twisted too eh?  ;)

Offline sam

  • Administrator
  • *****
  • Posts: 19386
Re: php advice needed
« Reply #5 on: January 21, 2010, 03:15 »
ooh just like that page, eh?

Interesting problem - not sure why anyone would wanna do that but still.

The milliondollar website cheats... they make a large png file: http://www.milliondollarhomepage.com/img-pix/image-map.png?r=397

This could be done in imagemagik (what does the server run?) and then they overlay a grid..

Code: [Select]
<area onmouseover="d(this)" onmouseout="e(this)" shape="rect" coords="630,310,640,320" href="http://www.getpixel.net" title="getpixel.net, stock photography"/>
Do you have todo it in PHP?

I guess in php you could just make a grid of images, now you'd have to do some image location optimisation to get it like that though..  just need to create an array of images and loop over them in the html.

I'll have a think a bit more - I've been coding in python all day and a bit wiped now.
- sam | @starrydude --



Offline psp83

  • New Member
  • *
  • Posts: 23
Re: php advice needed
« Reply #6 on: January 21, 2010, 14:26 »
Thanks for the reply sam.

The server is PHP 5 with GD and not imagemagik :(

Do i have to do it in PHP ? Well to be honest no, It can be done in javascript aswell. But i'm limited to what i can work with here. I'm just doing extras to a site already coded.

I have an array of the images and sizes.

Code: [Select]
Array
(
    [0] => Array
        (
            [image] => ad30x70.jpg
            [width] => 30
            [height] => 70
        )

    [1] => Array
        (
            [image] => ad70x30.jpg
            [width] => 70
            [height] => 30
        )
)

Thats the only data i have to work with.

And to be honest with you.. I have no idea where to start with this.

Paul

Offline sam

  • Administrator
  • *****
  • Posts: 19386
Re: php advice needed
« Reply #7 on: January 21, 2010, 15:08 »
well if you could take the data from the array then you could easily cast it into a grid (case below would just be 1 x 1) ..  in the below case each image is called photo*.jpg (* = 1 - 9), $image_path = the location of the images and $toptext = some kind of array or individual element that has the alt text for the image. ...

Code: [Select]
<?php

for($i=0$i<=9$i++) {

?>
<li> <a href="<?php echo $image_path?>photo<?php echo $i

?>
.jpg"><img src="<?php echo $image_path?>photo<?php echo $i?>.jpg"

alt="<?php echo $toptext?>" />   <img src="<?php echo $image_path

?>
photo<?php echo $i?>.jpg" alt="<?php echo $toptext?>" /></a> <br /> <?php }

?>


I'm unsure how todo this in a more random manner like in the website example... will have a think
- sam | @starrydude --



Offline psp83

  • New Member
  • *
  • Posts: 23
Re: php advice needed
« Reply #8 on: January 21, 2010, 15:59 »
Hi.

This is what I've got so far..



Now just to remove the spaces to make it like million dollar website.

Paul

Offline sam

  • Administrator
  • *****
  • Posts: 19386
Re: php advice needed
« Reply #9 on: January 21, 2010, 23:57 »
excellent, how did you generate the above?
- sam | @starrydude --



Offline psp83

  • New Member
  • *
  • Posts: 23
Re: php advice needed
« Reply #10 on: January 22, 2010, 02:19 »
Just simple html & php

Code: [Select]
<div id="grid">
<?php foreach($ad_array as $key=>$ad) : ?>
<img src="./<?php echo $ad['image']; ?>" width="<?php echo $ad['width']; ?>px" height="<?php echo $ad['height']; ?>px" />
<?php endforeach; ?>
</div>

Now just the tricky part.. removing the spaces and making the ads fit together. any ideas?

Offline sam

  • Administrator
  • *****
  • Posts: 19386
Re: php advice needed
« Reply #11 on: January 22, 2010, 03:52 »
some kind of optimization code... hmmm, do you want it so it stays static?  you could just hard feed them in...

Or maybe you just produce the big image by grabbing all the smaller images, in gimp and just create an image map over the top?

There has to be some code to fit box into a bigger box..

I have to say this such an odd thing todo!
- sam | @starrydude --



Offline psp83

  • New Member
  • *
  • Posts: 23
Re: php advice needed
« Reply #12 on: January 22, 2010, 15:35 »
It cant be static. Has to be done on the fly as more ads are being added all the time.

User fills in the form, uploads the ad, pays for it and it becomes active.

I've been trying to google for some code/tips but its a hard thing to google for as i dont exactly know what to search for or call it  ???

Offline Rik

  • Former Admin
  • *****
  • Posts: 26508
  • Ceud mille failte
Re: php advice needed
« Reply #13 on: January 22, 2010, 15:37 »
Could you not find a similar site and take a look at the page source, Paul?
Slainthe!

Rik

Offline psp83

  • New Member
  • *
  • Posts: 23
Re: php advice needed
« Reply #14 on: January 22, 2010, 15:42 »
Tried that with the million dollar home page script package you can download, its like looking for a needle in a haystack!

Plus most sites like this gives you the option to select where you want in the grid and you have more information then to use php GD to position the image. like in the million dollar home page, just create one large pic with image maps. But i dont have that to work with.. only thing i've got is the image and sizes :(

I think this part of the extras might have to get outsourced to a firm over seas or something.


Show unread posts since last visit.
Sponsor for PC Pals Forum