Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo
Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo
Lenovo Legion Go 2 è la nuova handheld PC gaming con processore AMD Ryzen Z2 Extreme (8 core Zen 5/5c, GPU RDNA 3.5 16 CU) e schermo OLED 8,8" 1920x1200 144Hz. È dotata anche di controller rimovibili TrueStrike con joystick Hall effect e una batteria da 74Wh. Rispetto al dispositivo che l'ha preceduta, migliora ergonomia e prestazioni a basse risoluzioni, ma pesa 920g e costa 1.299€ nella configurazione con 32GB RAM/1TB SSD e Z2 Extreme
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti
A re:Invent 2025, AWS mostra un’evoluzione profonda della propria strategia: l’IA diventa una piattaforma di servizi sempre più pronta all’uso, con agenti e modelli preconfigurati che accelerano lo sviluppo, mentre il cloud resta la base imprescindibile per governare dati, complessità e lock-in in uno scenario sempre più orientato all’hybrid cloud
Cos'è la bolla dell'IA e perché se ne parla
Cos'è la bolla dell'IA e perché se ne parla
Si parla molto ultimamente di "bolla dell'intelligenza artificiale", ma non è sempre chiaro perché: l'IA è una tecnologia molto promettente e che ha già cambiato molte cose dentro e fuori le aziende, ma ci sono enormi aspettative che stanno gonfiando a dismisura i valori delle azioni e distorcendo il mercato. Il che, com'è facile intuire, può portare a una ripetizione della "bolla dotcom", e forse anche di quella dei mutui subprime. Vediamo perché
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 29-01-2008, 16:31   #1
MasterDany
Senior Member
 
L'Avatar di MasterDany
 
Iscritto dal: Dec 2007
Messaggi: 505
[PHP&mysql]Script per sito con articoli

Ciao a tutti ho creato unp script php che permette di scrivere articoli e salvarli in mysql allora per prima cosa ho creato un file.sql con scritto :
Codice:
Codice:
CREATE TABLE authors (
    id        INT UNSIGNED NOT NULL AUTO_INCREMENT,
    name        VARCHAR(100) NOT NULL,
    surname    VARCHAR(100) NOT NULL,

    PRIMARY KEY(id)
);

CREATE TABLE articles (
    id        INT UNSIGNED NOT NULL AUTO_INCREMENT,
    author_id    INT UNSIGNED NOT NULL,
    title        VARCHAR(100) NOT NULL,
    article        TEXT NOT NULL,

    PRIMARY KEY(id),
    KEY(author_id)
);
poi ho creato un file insert.php per inserire gli articoli:
Codice PHP:
Codice:
?php

$mysql = new mysqli('localhost', 'root', '', 'html_it_articles');
if(!$mysql)
{
    die("Errore di connessione al database, impossibile procedere");
}

if(isset($_POST['action']) and $_POST['action'] == 'insert')
{
    $mysql->query("INSERT INTO articles VALUES ('', '".$_POST['author']."', '".addslashes($_POST['title'])."', '".addslashes($_POST['article'])."')");
    header('Location: index.php');
}

$authors = $mysql->query("SELECT id, CONCAT(surname, ' ', name) AS fullname FROM authors ORDER BY surname ASC");
?>
<html>
    <head>
        <title>Inserimento articolo</title>
    </head>
    <body>
        <ul>
            <li><a href="index.php">Lista articoli</a></li>
            <li><a href="insert.php">Inserisci un articolo</a></li>
        </ul>
        <h3>Inserisci un articolo</h3>
        <form action="" method="post">
            <input type="hidden" name="action" value="insert" />
            <label>Autore:</label> <select name="author">
                <?php
                while($author = $authors->fetch_assoc())
                {
                    echo "<option value=".$author['id'].">".$author['fullname']."</option>";
                }
                ?>
            </select><br />
            <label>Titolo:</label> <input type="text" name="title" size="55"/><br />
            <label>Text:</label><br />
            <textarea name="article" rows="6" cols="60"></textarea><br />
            <input type="submit" value="Salva" />
        </form>
    </body>
</html>
poi ho creato un file show.php e ho inserito per leggere gli articoli:
Codice PHP:
Codice:
<?php

$mysql = new mysqli('localhost', 'root', '', 'provacast');
if(!$mysql)
{
    die("Errore di connessione al database, impossibile procedere");
}

if(!isset($_GET['id']))
{
    header('Location: index.php');
}

$article = $mysql->query("
    SELECT
        AR.id AS id,
        AR.title AS title,
        AR.article AS content,
        CONCAT(AU.surname, ' ', AU.name) AS author
    FROM
        articles AR,
        authors AU
    WHERE
        AR.author_id = AU.id AND
        AR.id = ".$_GET['id'])->fetch_assoc();
?>
<html>
    <head>
        <title>Articolo (<?php echo $article['id']; ?>)</title>
    </head>
    <body>
        <ul>
            <li><a href="index.php">Lista articoli</a></li>
            <li><a href="insert.php">Inserisci un articolo</a></li>
        </ul>
        <h3><?php echo $article['title']; ?></h3>
        <i><?php echo $article['author']; ?></i>
        <p>
            <?php echo $article['content']; ?>
        </p>
    </body>
</html>
infine ho creato l'index.php per linkare gli articoli in modo che tutti possano vederli:
Codice:
Codice PHP:
<?php

$limit = 5; // articoli per pagina

$mysql = new mysqli('localhost', 'root', '', 'provacast');
if(!$mysql)
{
    die("Errore di connessione al database, impossibile procedere");
}

$result = $mysql->query("SELECT COUNT(*) AS tot FROM articles")->fetch_assoc();

$page = isset($_GET['p']) ? $_GET['p'] : 1;
$totals = $result['tot'];
$totals_pages = ceil($totals / $limit);

$articles = $mysql->query("
    SELECT
        AR.id AS id,
        AR.title AS title,
        CONCAT(SUBSTR(AR.article, 1, 200),  ' ...') AS content,
        CONCAT(AU.surname, ' ', AU.name) AS author
    FROM
        articles AR,
        authors AU
    WHERE
        AR.author_id = AU.id
    ORDER BY id DESC
    LIMIT ".(($page - 1) * $limit).",".$limit);
?>
<html>
    <head>
        <title>Articoli</title>
    </head>
    <body>
        <ul>
            <li><a href="index.php">Lista articoli</a></li>
            <li><a href="insert.php">Inserisci un articolo</a></li>
        </ul>
        <p>Articoli totali: <?php echo $totals; ?></p>
        <table width="500px">
            <?php
            while($article = $articles->fetch_assoc())
            {
                printf('<tr>
                        <td>%d. <a href="show.php?id=%d">%s</a> (%s) </td>
                    </tr>
                    <tr>
                        <td><p>%s</p></td>
                    </tr>
                    <tr>
                        <td><hr /></td>
                    </tr>',
                    $article['id'],
                    $article['id'],
                    $article['title'],
                    $article['author'],
                    $article['content']
                    );
            }
            ?>
        </table>
        <p>Pagina <?php echo $page; ?> di <?php echo $totals_pages; ?> <br />
        <?php
        if($page - 1 > 0)
        {
            echo '<a href="?p='.($page - 1).'">&lt; prev</a> | ';
        }else
        {
            echo '&lt; prev | ';
        }
        if($page + 1 <= $totals_pages)
        {
                    echo '<a href="?p='.($page + 1).'">next &gt;</a>';
        }else
        {
                    echo 'next &gt;';
        }
        ?>
        </p>
    </body>
</html>
Gli articoli li inserisce IN MY SQL PERò NON MI MOSTRA L'ELENCO NELL'INDEX .l'errore pesno che stia sell'index ma non lo trovo...Gli articoli li insrisce perchè nell'index che ho testato in locale 'era scritto articoli totali 2 ma poi non c'è l'elenco degli articoli...secondo voi che ho sbagliato?

Ultima modifica di MasterDany : 29-01-2008 alle 16:39.
MasterDany è offline   Rispondi citando il messaggio o parte di esso
Old 04-02-2008, 17:37   #2
MasterDany
Senior Member
 
L'Avatar di MasterDany
 
Iscritto dal: Dec 2007
Messaggi: 505
vi riporto la query sql:
Codice:
-- phpMyAdmin SQL Dump
-- version 2.9.1.1
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generato il: 04 Feb, 2008 at 05:10 PM
-- Versione MySQL: 5.0.27
-- Versione PHP: 5.2.0
-- 
-- Database: `provacast`
-- 

-- --------------------------------------------------------

-- 
-- Struttura della tabella `articles`
-- 

CREATE TABLE `articles` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `author_id` int(10) unsigned NOT NULL,
  `title` varchar(100) NOT NULL,
  `article` text NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `author_id` (`author_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

-- 
-- Dump dei dati per la tabella `articles`
-- 

INSERT INTO `articles` (`id`, `author_id`, `title`, `article`) VALUES 
(1, 0, 'Daniele', 'sdsadsadf'),
(2, 0, 'dfgfdg', 'dfgdgdfg'),
(3, 0, 'dfgdg', 'dfgdfgdfg'),
(4, 0, 'nbmbm', 'nbmnbmnbmbmnbm'),
(5, 0, 'hgjhjhg', 'hgjhgjgh'),
(6, 0, 'dsfds', 'dsfsdfsdf'),
(7, 0, 'prova', 'dsfsdafsda'),
(8, 0, 'uyiyiyijhkjhk', 'uyfivhgkjhnmjhvkjnmnmnbmbm'),
(9, 0, 'vbgnvb', 'vbnvnvb');

-- --------------------------------------------------------

-- 
-- Struttura della tabella `authors`
-- 

CREATE TABLE `authors` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(100) NOT NULL,
  `surname` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- 
-- Dump dei dati per la tabella `authors`
-- 


-- --------------------------------------------------------

-- 
-- Struttura della tabella `news`
-- 

CREATE TABLE `news` (
  `id` int(5) unsigned NOT NULL auto_increment,
  `titolo` varchar(255) NOT NULL,
  `testo` text NOT NULL,
  `data` int(11) default NULL,
  `autore` varchar(50) default NULL,
  `mail` varchar(50) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- 
-- Dump dei dati per la tabella `news`
--
Che ho sbagliato?
__________________
Giochi:Fallout 3,Civilitation IV,Call of Duty-World at War,Far Cry 2,Crysis,Age of Empires III. BLOG
Non ricordo niente ma non lo dimenticherò mai
MasterDany è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'...
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti AWS re:Invent 2025: inizia l'era dell'AI-as-a-Se...
Cos'è la bolla dell'IA e perché se ne parla Cos'è la bolla dell'IA e perché se...
BOOX Palma 2 Pro in prova: l'e-reader diventa a colori, e davvero tascabile BOOX Palma 2 Pro in prova: l'e-reader diventa a ...
FRITZ!Repeater 1700 estende la rete super-veloce Wi-Fi 7 FRITZ!Repeater 1700 estende la rete super-veloce...
SpaceX: un satellite ha fotografato il s...
36 idee regalo con offerte Amazon sotto ...
Sony assume il controllo dei Peanuts: Sn...
DJI Neo scende a 149€ su Amazon, in vers...
Scoperto un nuovo esopianeta che orbita ...
Blue Origin NS-37: successo per la missi...
Potrebbe essere stata rilevata una super...
La cometa interstellare 3I/ATLAS è...
Xiaomi 17 Ultra: l'autonomia non sarà un...
Il processo produttivo a 2 nm di TSMC è ...
L'atteso aggiornamento dei driver della ...
The Elder Scrolls VI nel 2029 e Fallout ...
Il Ryzen 7 9850X3D appare nel catalogo d...
Weekend pre natalizio Amazon, ecco tutte...
Prezzi giù su Oral-B iO: spazzolini elet...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 23:40.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v