stampare news
-
-
quindi faccio così??
id=$_GET['id']; $testo=@mysql_query("SELECT * FROM news ORDER BY id_news DESC limit 1 "); if(mysql_num_rows($testo)<1) exit('Non è possibile trovare la news.'); $testo=mysql_fetch_array($testo); $titolo=$testo['titolo']; $text=$testo['testo']; $datas=$testo['data']; $text=htmlspecialchars($text); -
si dovrebbe andare

-
-
quale?
postate anche l'errore per cortesia! -
massimux
quale?
postate anche l'errore per cortesia!Questo:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Programmi\EasyPHP 2.0b1\www\tapsos\index.php on line 24 Non è possibile trovare la news.Ciau
-
id=$_GET['id']; $testo=@mysql_query("SELECT * FROM news ORDER BY id_news DESC limit 1 "); $num=mysql_num_rows($testo); if ($num<1){ echo"Non ci sono news"; exit(); } $testoa=mysql_fetch_array($testo); $titolo=$testoa['titolo']; $text=$testoa['testo']; $datas=$testoa['data']; $text=htmlspecialchars($text);scrivi il codice in questo modo... altrimenti con almeno un record nel database scrivi questo e dimmi che ti mostra
id=$_GET['id']; $testo=@mysql_query("SELECT * FROM news ORDER BY id_news DESC limit 1 "); $testoa=mysql_fetch_array($testo); $titolo=$testoa['titolo']; $text=$testoa['testo']; $datas=$testoa['data']; $text=htmlspecialchars($text); -
Questi gli errori.
Primo codice:[B]Warning[/B]: mysql_num_rows(): supplied argument is not a valid MySQL result resource in [B]C:\Programmi\EasyPHP 2.0b1\www\tapsos\index.php[/B] on line [B]24[/B] Non ci sono newsSecondo codice:
[B]Warning[/B]: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [B]C:\Programmi\EasyPHP 2.0b1\www\tapsos\index.php[/B] on line [B]24[/B]Ciao!
-
Ti Prende le ultime due:
$query = "select * from news ORDER BY id DESC limit 2"; $dbResult = mysql_query($query, $db); $AffectedRows = mysql_affected_rows($db); while ($dati = mysql_fetch_array($dbResult, MYSQL_ASSOC) and $i < 2) { $i++; ....facilmente ottimizzabile se devi prenderne di più..
Vai tranquillo che funziona.
-
MZ
Ti Prende le ultime due:
$query = "select * from news ORDER BY id DESC limit 2"; $dbResult = mysql_query($query, $db); $AffectedRows = mysql_affected_rows($db); while ($dati = mysql_fetch_array($dbResult, MYSQL_ASSOC) and $i < 2) { $i++; ....o mamma...ke vuol dire??che cosa è??
-
Ma io che cosa faccio con questo codice?? A me serve visualizzare una sola news...quella con id più vekkio...come fare dato ke (come si legge sopra) mi da errore??
$query = "select * from news ORDER BY id DESC limit 2"; $dbResult = mysql_query($query, $db); $AffectedRows = mysql_affected_rows($db); while ($dati = mysql_fetch_array($dbResult, MYSQL_ASSOC) and $i < 2) { $i++; .... -
-
no problem.... l'importante e' che ci siamo riusciti
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi