PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Using arrays
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Using arrays

Réponse
 
LinkBack Outils de la discussion
Vieux 13/09/2007, 10h42   #1 (permalink)
phill.luckhurst@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Using arrays

I'm quite new to PHP so please spoone feed me here.

I'm trying to generate a list of URLs from a directory to feed into a
slideshow but I'm completely stumped as to how to do it. I've been
given the following code to generate a list of 15 URLs with the right
extension but what do I do with it now?

Code:
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$xml = '<image_folder></image_folder>';
if ($FORBIDDEN_SET != "") $FORBIDDEN_SET = "AND $FORBIDDEN_SET";
$result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p
WHERE filename LIKE '%.jpg' $FORBIDDEN_SET ORDER BY RAND() LIMIT 15");
while ($row = mysql_fetch_array($result))
{
$type = 'normal';
$xml .= "".get_pic_url($row, $type) ."";
}
echo $xml;



?>
That bit displays a nice list of URLs for me but I need to feed them
into this second script where $URL would be the one of the URLs
selected in order from the list generated from the first script.

Code:
<?php

//include slideshow.php in your script
include "slideshow.php";

//add 15 slides
for ( $i=0; $i<15; $i++ ){
$slideshow[ 'slide' ][ $i ] = array ( 'url' => $URL );
}

//send the slideshow data
Send_Slideshow_Data ( $slideshow );

?>
As I said, I'm very new to this so I m probably barking up totally the
wrong tree.

I'm also running out of hair trying to work out how to do this.

  Réponse avec citation
Vieux 13/09/2007, 11h19   #2 (permalink)
Gremnebulin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using arrays

On 13 Sep, 10:42, "phill.luckhu...@googlemail.com"
<phill.luckhu...@googlemail.com> wrote:
> I'm quite new to PHP so please spoone feed me here.
>
> I'm trying to generate a list of URLs from a directory to feed into a
> slideshow but I'm completely stumped as to how to do it. I've been
> given the following code to generate a list of 15 URLs with the right
> extension but what do I do with it now?
>
>
Code:
> <?php
> define('IN_COPPERMINE', true);
> require('include/init.inc.php');
> $xml = '<image_folder></image_folder>';
> if ($FORBIDDEN_SET != "") $FORBIDDEN_SET = "AND $FORBIDDEN_SET";
> $result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p
> WHERE filename LIKE '%.jpg' $FORBIDDEN_SET ORDER BY RAND() LIMIT 15");
> while ($row = mysql_fetch_array($result))
> {
>         $type = 'normal';
>         $xml .= "".get_pic_url($row, $type) ."";}
>
> echo $xml;
>
> ?>
>
>
> That bit displays a nice list of URLs for me but I need to feed them
> into this second script where $URL would be the one of the URLs
> selected in order from the list generated from the first script.
>
>
Code:
> <?php
>
> //include slideshow.php in your script
> include "slideshow.php";
>
> //add 15 slides
> for ( $i=0; $i<15; $i++ ){
>         $slideshow[ 'slide' ][ $i ] = array ( 'url' => $URL );
>
> }
>
> //send the slideshow data
> Send_Slideshow_Data ( $slideshow );
>
> ?>
>
>
> As I said, I'm very new to this so I m probably barking up totally the
> wrong tree.
>
> I'm also running out of hair trying to work out how to do this.


On 13 Sep, 10:42, "phill.luckhu...@googlemail.com"
<phill.luckhu...@googlemail.com> wrote:
> I'm quite new to PHP so please spoone feed me here.
>
> I'm trying to generate a list of URLs from a directory to feed into a
> slideshow but I'm completely stumped as to how to do it. I've been
> given the following code to generate a list of 15 URLs with the right
> extension but what do I do with it now?
>
>
Code:
> <?php
> define('IN_COPPERMINE', true);
> require('include/init.inc.php');
> $xml = '<image_folder></image_folder>';
> if ($FORBIDDEN_SET != "") $FORBIDDEN_SET = "AND $FORBIDDEN_SET";
> $result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p
> WHERE filename LIKE '%.jpg' $FORBIDDEN_SET ORDER BY RAND() LIMIT 15");
> while ($row = mysql_fetch_array($result))
> {
>         $type = 'normal';
>         $xml .= "".get_pic_url($row, $type) ."";}
>
> echo $xml;
>
> ?>
>
>
> That bit displays a nice list of URLs for me but I need to feed them
> into this second script where $URL would be the one of the URLs
> selected in order from the list generated from the first script.
>
>
Code:
> <?php
>
> //include slideshow.php in your script
> include "slideshow.php";
>
> //add 15 slides
> for ( $i=0; $i<15; $i++ ){
>         $slideshow[ 'slide' ][ $i ] = array ( 'url' => $URL );
>
> }
>
> //send the slideshow data
> Send_Slideshow_Data ( $slideshow );
>
> ?>
>
>
> As I said, I'm very new to this so I m probably barking up totally the
> wrong tree.
>
> I'm also running out of hair trying to work out how to do this.



Use the explode() function to break up the list in a $xml into a na
array, and foreach() through it.

Alternatively,
recode the first fragement so that the list is not built up as a
string
(ie take out the .= ) and build up the array $slideshow instead.

  Réponse avec citation
Vieux 13/09/2007, 12h19   #3 (permalink)
phill.luckhurst@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using arrays

On 13 Sep, 11:19, Gremnebulin <peterdjo...@yahoo.com> wrote:
> On 13 Sep, 10:42, "phill.luckhu...@googlemail.com"
>
>
>
>
>
> <phill.luckhu...@googlemail.com> wrote:
> > I'm quite new to PHP so please spoone feed me here.

>
> > I'm trying to generate a list of URLs from a directory to feed into a
> > slideshow but I'm completely stumped as to how to do it. I've been
> > given the following code to generate a list of 15 URLs with the right
> > extension but what do I do with it now?

>
> >
Code:
> > <?php
> > define('IN_COPPERMINE', true);
> > require('include/init.inc.php');
> > $xml = '<image_folder></image_folder>';
> > if ($FORBIDDEN_SET != "") $FORBIDDEN_SET = "AND $FORBIDDEN_SET";
> > $result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p
> > WHERE filename LIKE '%.jpg' $FORBIDDEN_SET ORDER BY RAND() LIMIT 15");
> > while ($row = mysql_fetch_array($result))
> > {
> >         $type = 'normal';
> >         $xml .= "".get_pic_url($row, $type) ."";}
Code:
>
> > echo $xml;
>
> > ?>
> > 

>
> > That bit displays a nice list of URLs for me but I need to feed them
> > into this second script where $URL would be the one of the URLs
> > selected in order from the list generated from the first script.

>
> >
Code:
> > <?php
Code:
>
> > //include slideshow.php in your script
> > include "slideshow.php";
>
> > //add 15 slides
> > for ( $i=0; $i<15; $i++ ){
> >         $slideshow[ 'slide' ][ $i ] = array ( 'url' => $URL );
>
> > }
>
> > //send the slideshow data
> > Send_Slideshow_Data ( $slideshow );
>
> > ?>
> > 

>
> > As I said, I'm very new to this so I m probably barking up totally the
> > wrong tree.

>
> > I'm also running out of hair trying to work out how to do this.

>
> On 13 Sep, 10:42, "phill.luckhu...@googlemail.com"
>
>
>
>
>
> <phill.luckhu...@googlemail.com> wrote:
> > I'm quite new to PHP so please spoone feed me here.

>
> > I'm trying to generate a list of URLs from a directory to feed into a
> > slideshow but I'm completely stumped as to how to do it. I've been
> > given the following code to generate a list of 15 URLs with the right
> > extension but what do I do with it now?

>
> >
Code:
> > <?php
> > define('IN_COPPERMINE', true);
> > require('include/init.inc.php');
> > $xml = '<image_folder></image_folder>';
> > if ($FORBIDDEN_SET != "") $FORBIDDEN_SET = "AND $FORBIDDEN_SET";
> > $result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p
> > WHERE filename LIKE '%.jpg' $FORBIDDEN_SET ORDER BY RAND() LIMIT 15");
> > while ($row = mysql_fetch_array($result))
> > {
> >         $type = 'normal';
> >         $xml .= "".get_pic_url($row, $type) ."";}
Code:
>
> > echo $xml;
>
> > ?>
> > 

>
> > That bit displays a nice list of URLs for me but I need to feed them
> > into this second script where $URL would be the one of the URLs
> > selected in order from the list generated from the first script.

>
> >
Code:
> > <?php
Code:
>
> > //include slideshow.php in your script
> > include "slideshow.php";
>
> > //add 15 slides
> > for ( $i=0; $i<15; $i++ ){
> >         $slideshow[ 'slide' ][ $i ] = array ( 'url' => $URL );
>
> > }
>
> > //send the slideshow data
> > Send_Slideshow_Data ( $slideshow );
>
> > ?>
> > 

>
> > As I said, I'm very new to this so I m probably barking up totally the
> > wrong tree.

>
> > I'm also running out of hair trying to work out how to do this.

>
> Use the explode() function to break up the list in a $xml into a na
> array, and foreach() through it.
>
> Alternatively,
> recode the first fragement so that the list is not built up as a
> string
> (ie take out the .= ) and build up the array $slideshow instead.- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


Brilliant, I'm learning a lot this week.

I've used the explode() and this now generates the list.

Code:
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$xml = '<image_folder></image_folder>';
if ($FORBIDDEN_SET != "") $FORBIDDEN_SET = "AND $FORBIDDEN_SET";
$result = mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} AS p
WHERE filename LIKE '%.jpg' $FORBIDDEN_SET ORDER BY RAND() LIMIT 15");
while ($row = mysql_fetch_array($result))
{
$type = 'normal';
$xml .= " ".get_pic_url($row, $type) ."";
}
$url = explode(" ", $xml);


?>
so now I come onto the second bit to create the $slideshow array.

Code:
<?php

//include slideshow.php to access the Send_Slideshow_Data function
include "slideshow.php";
include "flashthumb.php";

for ( $i=0; $i<15; $i++ ){
$slideshow[ 'slide' ][ $i ] = array ( 'url' => $url[7] );
}

Send_Slideshow_Data ( $slideshow );

?>
I'm struggling a little with the correct syntax here. The line with
$url[7] I would like to count with $i but I'm not sure how to put that
in.

$slideshow[ 'slide' ][ $i ] = array ( 'url' => $url[$i] );

Does not work. I'm sure it's simple and it's just a simple syntax
thing. I'll crack this php malarky one day.

Thanks for your

  Réponse avec citation
Vieux 13/09/2007, 12h53   #4 (permalink)
Gremnebulin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using arrays

On 13 Sep, 12:19, "phill.luckhu...@googlemail.com"
<phill.luckhu...@googlemail.com> wrote:

> [/code]
>
> I'm struggling a little with the correct syntax here. The line with
> $url[7] I would like to count with $i but I'm not sure how to put that
> in.
>
> $slideshow[ 'slide' ][ $i ] = array ( 'url' => $url[$i] );
>
> Does not work. I'm sure it's simple and it's just a simple syntax
> thing. I'll crack this php malarky one day.
>
> Thanks for your



The syntax is fine.

  Réponse avec citation
Vieux 13/09/2007, 13h39   #5 (permalink)
phill.luckhurst@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using arrays

On 13 Sep, 12:53, Gremnebulin <peterdjo...@yahoo.com> wrote:
> On 13 Sep, 12:19, "phill.luckhu...@googlemail.com"
>
> <phill.luckhu...@googlemail.com> wrote:
> > [/code]

>
> > I'm struggling a little with the correct syntax here. The line with
> > $url[7] I would like to count with $i but I'm not sure how to put that
> > in.

>
> > $slideshow[ 'slide' ][ $i ] = array ( 'url' => $url[$i] );

>
> > Does not work. I'm sure it's simple and it's just a simple syntax
> > thing. I'll crack this php malarky one day.

>
> > Thanks for your

>
> The syntax is fine.


Thanks for all your it's now working. I needed $url[$i+1]


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h33.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12689 seconds with 13 queries