Hi all, can you review this ?
Posted: Fri Aug 15, 2003 12:25 pm
Hey, i just started at php yesterday, i m a designer with some sciences background, but i never did any programming befor (well i have good html knowledge)
so i started soimething to sort a list of clients, the code i did below works but i guess it's not very optimise. If you could help me optimise this code it would be nice
ps : what u see it's like the start, i ll slowly add stuff like i will change my array for a external texte file and i ll start adding button to add and modify the texte file...but i m starting slow
)
thx
i'm happy cuz i did it with no help..
code :
<?php
$zip = array( '330 renoir' => 'j6a 5p8',
'12 iutp' => 'h9a 3k3',
'154 trew' => 'i7k 5s6',
'12587 asss' => 'p8j 7r5',
'110 errie' => 'l9o 5d5'
);
$adress = array( '514 885-0965' => $zip,
'514 620-1609' => $zip,
'514 726-2978' => $zip,
'514 816-1609' => $zip,
'450 618-8788' => $zip
);
$names = array( 'a' => $adress,
'b' => $adress,
'c' => $adress,
'd' => $adress,
'e' => $adress
);
list ($rue, $codepostal) = each($zip);
list ($numeros) = each($adress);
list ($noms) = each($names);
ksort($names);
echo "<table width=\"350\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n\t<td height=\"20\"><strong>Noms</strong></td>\n<td height=\"20\"><strong>Numéros</strong></td>\n<td height=\"20\"><strong>Rue</strong></td>\n<td height=\"20\"><strong>Code Postale</strong></td>\n</tr>\n";
reset($names);
reset($adress);
reset($zip);
while (list($noms) = each($names)) {
echo "<tr>\n\t<td>";
printf("%s", $noms);
echo "</td>\n<td>";
while (list($numeros) = each($adress)) {
printf("%s", $numeros);
echo "</td>\n<td>";
break;
}
while (list($rue, $codepostal) = each($zip)) {
printf("%s", $rue);
echo "</td>\n<td>";
printf("%s", $codepostal);
echo "</td>\n</tr>\n";
break;
}
}
echo "</table>";
?>
so i started soimething to sort a list of clients, the code i did below works but i guess it's not very optimise. If you could help me optimise this code it would be nice
ps : what u see it's like the start, i ll slowly add stuff like i will change my array for a external texte file and i ll start adding button to add and modify the texte file...but i m starting slow
thx
i'm happy cuz i did it with no help..
code :
<?php
$zip = array( '330 renoir' => 'j6a 5p8',
'12 iutp' => 'h9a 3k3',
'154 trew' => 'i7k 5s6',
'12587 asss' => 'p8j 7r5',
'110 errie' => 'l9o 5d5'
);
$adress = array( '514 885-0965' => $zip,
'514 620-1609' => $zip,
'514 726-2978' => $zip,
'514 816-1609' => $zip,
'450 618-8788' => $zip
);
$names = array( 'a' => $adress,
'b' => $adress,
'c' => $adress,
'd' => $adress,
'e' => $adress
);
list ($rue, $codepostal) = each($zip);
list ($numeros) = each($adress);
list ($noms) = each($names);
ksort($names);
echo "<table width=\"350\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n\t<td height=\"20\"><strong>Noms</strong></td>\n<td height=\"20\"><strong>Numéros</strong></td>\n<td height=\"20\"><strong>Rue</strong></td>\n<td height=\"20\"><strong>Code Postale</strong></td>\n</tr>\n";
reset($names);
reset($adress);
reset($zip);
while (list($noms) = each($names)) {
echo "<tr>\n\t<td>";
printf("%s", $noms);
echo "</td>\n<td>";
while (list($numeros) = each($adress)) {
printf("%s", $numeros);
echo "</td>\n<td>";
break;
}
while (list($rue, $codepostal) = each($zip)) {
printf("%s", $rue);
echo "</td>\n<td>";
printf("%s", $codepostal);
echo "</td>\n</tr>\n";
break;
}
}
echo "</table>";
?>