![]() |
Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [PHP] ma le tabelle come si dovrebbe gestirle? (http://www.dsy.it/forum/showthread.php?threadid=19481)
[PHP] ma le tabelle come si dovrebbe gestirle?
e tabelle html come si dovrebbe gestirle? cioè se ho un centinaio di tuple da stampare secondo una certa query secondo voi è giusto costruire la tabella tramite stringhe php o è meglio costruire tabelle con pezzi di codice php?
nel senso:
PHP:
function stampaRosa(){
$color1 = '#DDFFDD';
$color2 = '#DDCAFF';
$color = '#5533dd';
$count=1;
$query = "SELECT giocatori.cognome,giocatori.ruolo FROM giocatori,utente_has_giocatori where utente_has_giocatori.utente_nick='alex' and giocatori.cognome=utente_has_giocatori.giocatori_cognome";
$res = mysql_query($query);
if ($res)
echo "<br><br>GIOCATORI presenti nella ROSA: ".mysql_num_rows($res)."";
if (!$res) {
echo "Errore nella query richiesta.\n";
exit;
}
echo "<table><tr><td bgcolor='$color' width='160'><b>Cognome</b></td><td bgcolor='$color' width='160'><b>Ruolo</b></td></tr>";
while ($row = mysql_fetch_array($res)) {
if($count%2)
$color=$color1;
else
$color=$color2;
echo"<form action='iframe4.php' method='post' enctype='multipart/form-data'>";
printf ("<tr>");
printf ("<td bgcolor='$color'> $count) %s</td><td bgcolor='$color'>%s</td>", $row[0], $row[1]);
$selezione=$row[0];
printf ("<td><input type='hidden' value='$selezione' name='venduto'><input type='submit' value='Vendi !'></td></tr>");
printf ("</tr>");
$count++;
echo "</form>";
}
echo "</table>";
}
__________________
msn Messenger: giamma80 at tiscali.it
ATHENA !
Potresti fare un for da 1 a mysql_num_rows($res) (per esempio invece del while)
__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
ok, ma il mio quesito interessa l'uso delle tabelle, secondo voi la funzione php deve ritornare una stringa da usare da una tabella html, oppure va bene fare tutto in php?
__________________
msn Messenger: giamma80 at tiscali.it
ATHENA !
Mhh ora ho bene al tua domanda.
Non saprei non ci vedo molta differenza.
Cosa credi di fare quando fai echo ???
Dai in pasto all'html (al servr web) un codice html no ?
Cmq come penseresti di creare "una stringa da usare da una tabella html" ???
La tabella o la crei dinamicamente oppure la crei statica (sapendo pero' quante sono le righe).
Ma nel secondo caso mi pare un po' inutile usare php
__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
gia che ci siamo, se condo voi dove sta l'errore in questa query?
code:
UPDATE utente SET budget = ( (SELECT budget from utente where nick='$utente') -(select valore from giocatori where cognome='$comprato') ) WHERE nick='$utente'
__________________
msn Messenger: giamma80 at tiscali.it
ATHENA !
Originally posted by maynard80
gia che ci siamo, se condo voi dove sta l'errore in questa query?
code:
UPDATE utente SET budget = ( (SELECT budget from utente where nick='$utente') -(select valore from giocatori where cognome='$comprato') ) WHERE nick='$utente'
__________________
"io non sono come gli altri Robin Hood, io non ballo coi lupi"
"ogni mattina come narciso si specchia nel ruscello retrovisore", "ci sono mille modi per chiamare dio...dio,allha,adta,arauffa,crisma..afjasf...tanto non ti risponde"
Corrado Guzzanti è il mio Dio.
Roberto Saviano eroe nazionale.
Un paio di appunti veloci:
- perché avresti messo enctype='multipart/form-data' in una form che passa soltanto un campo testuale?
- ma soprattutto, perché fare una form per ogni tupla? Sarebbe più elegante e pulito fare una form globale, così da alleggerire il codice e permettere eventualmente selezioni multiple.
- $selezione=$row[0]; è inutile, potresti semplicemente fare value='" . $row[0] . "'.
- ultima cosa, per i valori delle proprietà dei tag HTML sarebbe meglio utilizzare i doppi apici, per farlo dentro una stringa PHP usa \".
__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.
query SQL:
code:
UPDATE utente SET budget = ( ( SELECT budget FROM utente WHERE nick = 'alex' ) - ( SELECT valore FROM giocatori WHERE cognome = 'zola' ) ) WHERE nick = 'alex'
__________________
msn Messenger: giamma80 at tiscali.it
ATHENA !
Originally posted by maynard80
query SQL:
code:
UPDATE utente SET budget = ( ( SELECT budget FROM utente WHERE nick = 'alex' ) - ( SELECT valore FROM giocatori WHERE cognome = 'zola' ) ) WHERE nick = 'alex'
__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.
All times are GMT. The time now is 22:10. | Show all 9 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.