-
Posts
283 -
Joined
-
Last visited
-
Days Won
2
Everything posted by maicol07
-
Oh, I was missing a / in the config file. I deleted you from the database so you can retry to register...
-
I think that the configuration on XAMPP is different from the one on Tommy. I tried to use PHP Info on the two server and see what isn't activated. Here is the list: apache2handlerApache EnvironmentHTTP Headers Informationbz2odbcposixpspellreadlineMaybe are these functions lost that cause the problems?
-
Thanks for the info, but I don't know anything about cron..
-
It's because every time Softaculous make a backup of all my installation it uses around 400-500 MB of space. My entire websites with only one copy of backup for installation on the server use around 500 MB. And so, everytime Softaculous make the backups, I have to delete the old ones... (I know there is a setting on the backup page that delete the old backups but I'd like to have at least 2 backups for installation...). So I ask if it is possible that Tommy can have some more space. Thanks
-
Hi, is it possible to increase the disk space of Tommy server? I can't host more of 4/5 sites due to the limited disk quota... Thanks
-
Oh, because I pasted it from XAMPP... But the error on Tommy is You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='1'' at line 1 Also in the view.php file there is an error between the buttons and the table that I don't understand: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Today I'll see all the SQL statements in this area and I'll find what is wrong...
-
I moved the topic here: https://www.helionet.org/index/topic/29002-help-with-php-mysql-script/
-
Hi, I have some PHP pages (from my last topic: https://www.helionet.org/index/topic/28805-dropdown-with-mysql-tables-names-of-a-database-as-options-and-php-mysql-errorssuggestions/) that integrates MySQL that don't work very well... here are my problems: If you go on http://apps.maicol07.tk/app/sld/voti/ and you register/login you can see what doesn't work... When you click on the pencil or the trash button (after you have inserted a new record with the + button on the right-bottom of the screen) it gives this error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id=1' at line 2 SQL QUERY: SELECT * FROM $materia WHERE id=$id; The dropdown in the view.php (or view-paginated.php) file it is blank (except the first option that I've added) while on XAMPP it works... The table of view.php doesn't work on Tommy, while on XAMPP it works.Source Code: http://s000.tinyupload.com/index.php?file_id=87380380194489995693 Thanks
-
Any solutions? Also, the dropdown doesn't work... it is blank... https://apps.maicol07.tk/app/sld/voti/test_dropdown.php The code is on this post: https://www.helionet.org/index/topic/28805-dropdown-with-mysql-tables-names-of-a-database-as-options-and-php-mysql-errorssuggestions/page-2?do=findComment&comment=131657 Thanks
-
Ok thanks, I solved all the errors, but the table doesn't show... in any file... I edited the view-paginated.php file with some changes... here's the code: <?php require ("includes/config.php"); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: login.php'); } $nomeutente=$_SESSION['username']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Visualizza Record</title> <!--Import Google Icon Font--> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script> <div class="container"> <p align="right">Ciao, <?php echo $nomeutente; ?><br> <a href='logout.php'class="waves-effect waves-light btn"><i class="material-icons left">power_settings_new</i>Logout</a></p> <form method="get"> Visualizza voti di: <div class="input-field inline"> <?php // load database values require 'connect-db.php'; // connect to database $conn = new mysqli($server, $user, $pass, $db); if ($conn->connect_error) die("Connection failed: ".$conn->connect_error); // perform query $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); // start dropdown select echo "<select name='materia'>"; echo "<option value='allmaterie'>Tutte le materie</option>"; // for each table in database create an entry while ($row = $result->fetch_assoc()) { $table = $row["Tables_in_members ($nomeutente%)"]; $mat=ucfirst(substr($table, strpos($table, "_") + 1)); echo "<option value='$table'>$mat</option>"; } echo "</select>"; ?> </div> <script> $(document).ready(function() { $('select').material_select(); }); </script> <button class="btn waves-effect waves-light" type="submit" name="action">Visualizza <i class="material-icons left">search</i> </button> </form> <br><br> <?php /* VIEW-PAGINATED.PHP View all the data of a MySQL table This is a view.php file that contains impagination */ // load database values require 'connect-db.php'; // connect to database $connection = new mysqli($server, $user, $pass, $db); if ($connection->connect_error) die("Connection failed: ".$connection->connect_error); // view impagination echo "<a href='view.php' class='waves-effect waves-light btn' type='button'><i class='material-icons left'>search</i>Visualizza Tutto</a> | <a class='waves-effect waves-light btn' href='view-paginated.php?page=1' disabled><i class='material-icons left'>find_in_page</i>Visualizza impaginato</a>"; echo "</p>"; // view table data echo "<table class='centered striped responsive-table' border='1' cellpadding='10'>"; echo "<tr> <th>Voto</th> <th>Data</th> <th>Materia</th> <th>Peso</th> <th>Descrizione</th></tr>"; $iRows = 10; //Show 10 rows at a time $iStart = mysqli_real_escape_string($connection,$_GET['start']); $iEnd = $iStart + $iRows; if (isset($_GET['materia'])) { $materia=$_GET["materia"]; $rData = mysqli_query($connection,"SELECT * FROM $materia LIMIT $iStart,$iEnd"); } else { $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); while ($row = $result->fetch_assoc()) { $row_result=$row["Tables_in_members ($nomeutente%)"]; $rData = mysqli_query($conn,"SELECT * FROM '$row_result' LIMIT $iStart,$iEnd") or die(mysqli_error($connection)); } } if (!$rData) { die(mysqli_error($conn)); } while ($aRow = mysqli_fetch_assoc($rData)) { // printing table contents echo "<tr>"; echo '<td>' .$aRow["voto"]. '</td>'; echo '<td>' .$aRow["data"]. '</td>'; echo '<td>' .$aRow["materia"]. '</td>'; echo '<td>' .$aRow["peso"]. '</td>'; echo '<td>' .$aRow["descrizione"]. '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $aRow["id"] . '&materia='.$aRow["materia"].'"><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $aRow["id"] . '&materia='.$aRow["materia"].'"><i class="material-icons left">delete</i>Elimina</a></td>'; echo "</tr>"; } // close the table echo "</table>"; // impagination if ($iStart==10) { $disableback="disabled"; } else { $disableback=""; } if ($iStart==$iEnd) { $disablefwd="disabled"; } else { $disablefwd=""; } echo "<br>"; echo "<a ".$disableback. " class='btn waves-effect waves-light' href=\"".$_SERVER['PHP_SELF']."?start=$iStart-$iRows\"><i class='material-icons left'>arrow_back</i>Pagina precedente</a>"; echo " "; echo "<a ".$disablefwd." class='btn waves-effect waves-light' href=\"".$_SERVER['PHP_SELF']."?start=$iStart+$iRows\"><i class='material-icons right'>arrow_forward</i>Pagina successiva</a>"; // Calculating average $num=0; $den=0; while ($aRow = mysqli_fetch_assoc($rData)) { $num+=($aRow["voto"]*$aRow["peso"]); $den+=$aRow["peso"]; } $media=$num/$den; echo '<div align="center" style="padding:4px; border:2px solid blue; color:black;">MEDIA: '.$media.'</div>'; ?> <div class="fixed-action-btn"> <a class="btn-floating btn-large red"><i class="large material-icons">add</i>Aggiungi</a> <ul> <li><a href="new_voto.php" class="btn-floating blue"><i class="material-icons">note_add</i></a>Aggiungi voto</li> <li><a href="new_materia.php" class="btn-floating yellow darken-1"><i class="material-icons">class</i></a>Aggiungi Materia</li> </ul> </div> </div> </body> </html> Why doesn't the table show? Thanks
-
Ok, I applied it but it gives me some errors... Notice: Undefined index: start in C:\xampp\htdocs\sitesld\view-paginated.php on line 83 Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\sitesld\view-paginated.php on line 88Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\sitesld\view-paginated.php on line 111 [AFTER THE BLANK TABLE (See question below)] Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\sitesld\view-paginated.php on line 111 Code of the page: <?php require ("includes/config.php"); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: login.php'); } $nomeutente=$_SESSION['username']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Visualizza Record</title> <!--Import Google Icon Font--> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script> <div class="container"> <p align="right">Ciao, <?php echo $nomeutente; ?><br> <a href='logout.php'class="waves-effect waves-light btn"><i class="material-icons left">power_settings_new</i>Logout</a></p> <form method="get"> Visualizza voti di: <div class="input-field inline"> <?php // load database values require 'connect-db.php'; // connect to database $conn = new mysqli($server, $user, $pass, $db); if ($conn->connect_error) die("Connection failed: ".$conn->connect_error); // perform query $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); // start dropdown select echo "<select name='materia'>"; echo "<option value='allmaterie'>Tutte le materie</option>"; // for each table in database create an entry while ($row = $result->fetch_assoc()) { $table = $row["Tables_in_members ($nomeutente%)"]; $mat=ucfirst(substr($table, strpos($table, "_") + 1)); echo "<option value='$table'>$mat</option>"; } echo "</select>"; ?> </div> <script> $(document).ready(function() { $('select').material_select(); }); </script> <button class="btn waves-effect waves-light" type="submit" name="action">Visualizza <i class="material-icons left">search</i> </button> </form> <br><br> <?php /* VIEW-PAGINATED.PHP Views all the data of a MySQL table This modified version has impagination */ //database connection already done before echo "<a href='view.php' class='waves-effect waves-light btn' type='button'><i class='material-icons left'>search</i>Visualizza Tutto</a> | <a class='waves-effect waves-light btn' href='view-paginated.php?page=1' disabled><i class='material-icons left'>find_in_page</i>Visualizza impaginato</a>"; echo "</p>"; // view data in a table echo "<table class='centered striped responsive-table' border='1' cellpadding='10'>"; echo "<tr> <th>Voto</th> <th>Data</th> <th>Materia</th> <th>Peso</th> <th>Descrizione</th></tr>"; $iRows = 10; //Show 10 rows at a time $iStart = mysqli_real_escape_string($connection,$_GET['start']); $iEnd = $iStart + $iRows; $rData = mysqli_query($connection,"SELECT * FROM table LIMIT $iStart,$iEnd"); while ($aRow = mysqli_fetch_assoc($rData)) { // printing content of all rows in a table echo "<tr>"; echo '<td>' .$aRow["voto"]. '</td>'; echo '<td>' .$aRow["data"]. '</td>'; echo '<td>' .$aRow["materia"]. '</td>'; echo '<td>' .$aRow["peso"]. '</td>'; echo '<td>' .$aRow["descrizione"]. '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . mysql_result($result, $i, 'id') . '"><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . mysql_result($result, $i, 'id') . '"><i class="material-icons left">delete</i>Elimina</a></td>'; echo "</tr>"; } // close the table echo "</table>"; // impagination echo "<a href=\"".$_SERVER['PHP_SELF']."?start=$iStart-$iRows\">Pagina precedente</a>"; echo "<a href=\"".$_SERVER['PHP_SELF']."?start=$iStart+$iRows\">Pagina successiva</a>"; // Calculating average $num=0; $den=0; while ($aRow = mysqli_fetch_assoc($rData)) { $num+=($aRow["voto"]*$aRow["peso"]); $den+=$aRow["peso"]; } $media=$num/$den; echo '<div align="center" style="padding:4px; border:2px solid blue; color:black;">MEDIA: '.$media.'</div>'; ?> <div class="fixed-action-btn"> <a class="btn-floating btn-large red"><i class="large material-icons">add</i>Aggiungi</a> <ul> <li><a href="new_voto.php" class="btn-floating blue"><i class="material-icons">note_add</i></a>Aggiungi voto</li> <li><a href="new_materia.php" class="btn-floating yellow darken-1"><i class="material-icons">class</i></a>Aggiungi Materia</li> </ul> </div> </div> </body> </html> PROBLEM 2: In the file above and in the file below the table rows don't show... I don't know why... can you please help me? <?php require ("includes/config.php"); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: login.php'); } $nomeutente=$_SESSION['username']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Visualizza Voti</title> <!--Import Google Icon Font--> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script> <div class="container"> <p align="right">Ciao, <?php echo $nomeutente; ?><br> <a href='logout.php'class="waves-effect waves-light btn"><i class="material-icons left">power_settings_new</i>Logout</a></p> <div class="fixed-action-btn"> <a class="btn-floating btn-large red"><i class="large material-icons">add</i>Aggiungi</a> <ul> <li><a href="new_voto.php" class="btn-floating blue"><i class="material-icons">note_add</i></a>Aggiungi voto</li> <li><a href="new_materia.php" class="btn-floating yellow darken-1"><i class="material-icons">class</i></a>Aggiungi Materia</li> </ul> </div> <form method="get"> Visualizza voti di: <div class="input-field inline"> <?php // load database values require 'connect-db.php'; // connect to database $conn = new mysqli($server, $user, $pass, $db); if ($conn->connect_error) die("Connection failed: ".$conn->connect_error); // perform query $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); if (isset($_GET['materia'])) { $mat_sel=$_GET['materia']; // start dropdown select echo "<select id='materia' name='materia' value='$mat_sel'>"; } else { echo "<select id='materia' name='materia'>"; } echo "<option value='allmaterie'>Tutte le materie</option>"; // for each table in database create an entry while ($row = $result->fetch_assoc()) { $table = $row["Tables_in_members ($nomeutente%)"]; $mat=ucfirst(substr($table, strpos($table, "_") + 1)); echo "<option value='$table'>$mat</option>"; } echo "</select>"; ?> </div> <script> $(document).ready(function() { $('select').material_select(); }); </script> <button class="btn waves-effect waves-light" type="submit" name="action">Visualizza <i class="material-icons left">search</i> </button> </form> <br><br> <?php // Is a subject selected or no? if (isset($_GET['materia'])) { $allmaterie=False; if ($_GET['materia']=='allmaterie') { $allmaterie=True; } } else { $allmaterie=True; } // view the data in a table echo "<button class='waves-effect waves-light btn' type='button' disabled><i class='material-icons left'>search</i>Visualizza Tutto</button> | <a class='waves-effect waves-light btn' href='view-paginated.php?start=1'><i class='material-icons left'>find_in_page</i>Visualizza impaginato</a>"; echo "<br><br>"; echo "<table class='centered striped responsive-table' border='1' cellpadding='10'>"; echo "<thead>"; echo "<tr> <th>Voto</th> <th>Data</th> <th>Materia</th> <th>Peso</th> <th>Descrizione</th></tr>"; echo "</thead>"; echo "<tbody>"; if ($allmaterie=True) { $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); while ($row = $result->fetch_assoc()) { $row_result=$row["Tables_in_members ($nomeutente%)"]; $result = mysqli_query($conn,"SELECT * FROM '$row_result'") or die(mysqli_error($connection)); // loop table result while($row = mysqli_fetch_array( $result )) { // printing table echo "<tr>"; echo '<td>' . $row['voto'] . '</td>'; echo '<td>' . $row['data'] . '</td>'; echo '<td>' . $row['materia'] . '</td>'; echo '<td>' . $row['peso'] . '%</td>'; echo '<td>' . $row['descrizione'] . '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $row['id'] . '><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $row['id'] . '&materia='.$row['materia'].'><i class="material-icons left">delete</i>Elimina</a>'; echo "</tr>"; } } // close table echo "</tbody>"; echo "</table>"; } else { $materia=$_GET['materia']; $result = mysqli_query($connection, "SELECT * FROM $materia") or die(mysqli_error($connection)); // loop table results while($row = mysqli_fetch_array( $result )) { // printing contents of all rows in a table echo "<tr>"; echo '<td>' . $row['voto'] . '</td>'; echo '<td>' . $row['data'] . '</td>'; echo '<td>' . $row['materia'] . '</td>'; echo '<td>' . $row['peso'] . '%</td>'; echo '<td>' . $row['descrizione'] . '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $row['id'] . '><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $row['id'] . '&materia='.$row['materia'].'><i class="material-icons left">delete</i>Elimina</a>'; echo "</tr>"; } // Close the table echo "</table>"; } // Calculating average $num=0; $den=0; while ($aRow = mysqli_fetch_assoc($rData)) { $num+=($aRow["voto"]*$aRow["peso"]); $den+=$aRow["peso"]; } $media=$num/$den; echo '<div align="center" style="padding:4px; border:2px solid blue; color:black;">MEDIA: '.$media.'</div>'; ?> </div> </body> </html> Thanks
-
I don't think it works with my code and my variables, because I want to show a paginated mysql table in php. This is my code: <?php /* VIEW-PAGINATED.PHP Visualizza tutti i dati della tabella 'players' Questa è una versione modificata del file view.php che include l'impaginazione */ //connessione al database già effettuata sopra // numero di risultati da visualizzare per pagina $per_page = 10; // calcola le pagine totali $result = mysqli_query($connection, "SELECT * FROM members WHERE TABLE_NAME LIKE $nomeutente"); $total_results = mysqli_num_rows($result); $total_pages = ceil($total_results / $per_page); // controlla se la variabile 'page' è impostata nell'URL (es: view-paginated.php?page=1) if (isset($_GET['page']) && is_numeric($_GET['page'])) { $show_page = $_GET['page']; // mi assicuro che il valore di $show_page sia valido if ($show_page > 0 && $show_page <= $total_pages) { $start = ($show_page -1) * $per_page; $end = $start + $per_page; } else { // errore - mostra il primo set di risultati $start = 0; $end = $per_page; } } else { // se la pagina non è impostata, mostra il primo set di risultati $start = 0; $end = $per_page; } // visualizza impaginazione echo "<button class='waves-effect waves-light btn' type='button'><i class='material-icons left'>search</i>Visualizza Tutto</button> | <a class='waves-effect waves-light btn' href='view-paginated.php?page=1' disabled><i class='material-icons left'>find_in_page</i>Visualizza impaginato</a>"; for ($i = 1; $i <= $total_pages; $i++) { echo "<a href='view-paginated.php?page=$i'>$i</a> "; } echo "</p>"; // visualizza i dati in tabella echo "<table class='centered striped responsive-table' border='1' cellpadding='10'>"; echo "<tr> <th>Voto</th> <th>Data</th> <th>Materia</th> <th>Peso</th> <th>Descrizione</th></tr>"; // loop tra i risultati della query del database, visualizzandoli in tabella for ($i = $start; $i < $end; $i++) { // mi assicuro che PHP non cerchi di mostrare risultati che non esistono if ($i == $total_results) { break; } // emissione del contenuto di ogni riga in una tabella echo "<tr>"; echo '<td>' . mysql_result($result, $i, 'voto') . '</td>'; echo '<td>' . mysql_result($result, $i, 'data') . '</td>'; echo '<td>' . mysql_result($result, $i, 'materia') . '</td>'; echo '<td>' . mysql_result($result, $i, 'peso') . '</td>'; echo '<td>' . mysql_result($result, $i, 'descrizione') . '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . mysql_result($result, $i, 'id') . '"><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . mysql_result($result, $i, 'id') . '"><i class="material-icons left">delete</i>Elimina</a></td>'; echo "</tr>"; } // chiude la tabella echo "</table>"; // impaginazione ?> Thanks Also, if you have time, I ask you why I get this error: Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\sitesld\view.php on line 141 In this code: <?php require ("includes/config.php"); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: login.php'); } $nomeutente=$_SESSION['username']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Visualizza Voti</title> <!--Import Google Icon Font--> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Import materialize.css--> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <!--Import jQuery before materialize.js--> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script type="text/javascript" src="js/materialize.min.js"></script> <div class="container"> <p align="right">Ciao, <?php echo $nomeutente; ?><br> <a href='logout.php'class="waves-effect waves-light btn"><i class="material-icons left">power_settings_new</i>Logout</a></p> <div class="fixed-action-btn"> <a class="btn-floating btn-large red"><i class="large material-icons">add</i>Aggiungi</a> <ul> <li><a href="new_voto.php" class="btn-floating blue"><i class="material-icons">note_add</i></a>Aggiungi voto</li> <li><a href="new_materia.php" class="btn-floating yellow darken-1"><i class="material-icons">class</i></a>Aggiungi Materia</li> </ul> </div> <form method="get" action=""> Visualizza voti di: <div class="input-field inline"> <?php // load database values require 'connect-db.php'; // connect to database $conn = new mysqli($server, $user, $pass, $db); if ($conn->connect_error) die("Connection failed: ".$conn->connect_error); // perform query $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); if (isset($_GET['materia'])) { $mat_sel=$_GET['materia']; // start dropdown select echo "<select name='materia' value='$mat_sel'>"; echo "<option value='allmaterie'>Tutte le materie</option>"; // for each table in database create an entry while ($row = $result->fetch_assoc()) { $table = $row["Tables_in_members ($nomeutente%)"]; $mat=ucfirst(substr($table, strpos($table, "_") + 1)); echo "<option value='$table'>$mat</option>"; } echo "</select>"; ?> </div> <script> $(document).ready(function() { $('select').material_select(); }); </script> <button class="btn waves-effect waves-light" type="submit" name="action">Visualizza <i class="material-icons left">search</i> </button> </form> <br><br> <?php // identifica se è stata selezionata una materia o no if (isset($_GET['materia'])) { $allmaterie=False; if ($_GET['materia']=='allmaterie') { $allmaterie=True; } } else { $allmaterie=True; } // visualizza i dati in tabella echo "<button class='waves-effect waves-light btn' type='button' disabled><i class='material-icons left'>search</i>Visualizza Tutto</button> | <a class='waves-effect waves-light btn' href='view-paginated.php?page=1'><i class='material-icons left'>find_in_page</i>Visualizza impaginato</a>"; echo "<br><br>"; echo "<table class='centered striped responsive-table' border='1' cellpadding='10'>"; echo "<tr> <th>Voto</th> <th>Data</th> <th>Materia</th> <th>Peso</th> <th>Descrizione</th></tr>"; if ($allmaterie=True) { $sql = "show tables LIKE '$nomeutente%'"; $result = $conn->query($sql) or die($conn->error); while ($row = $result->fetch_assoc()) { $row_result=$row["Tables_in_members ($nomeutente%)"]; $result = mysqli_query($conn,"SELECT * FROM '$row_result'") or die(mysqli_error($connection)); // loop tra i risultati della query del database, visualizzandoli in tabella while($row = mysqli_fetch_array( $result )) { // emissione del contenuto di ogni riga in una tabella echo "<tr>"; echo '<td>' . $row['voto'] . '</td>'; echo '<td>' . $row['data'] . '</td>'; echo '<td>' . $row['materia'] . '</td>'; echo '<td>' . $row['peso'] . '%</td>'; echo '<td>' . $row['descrizione'] . '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $row['id'] . '><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $row['id'] . '><i class="material-icons left">delete</i>Elimina</a>'; echo "</tr>"; } // chiude la tabella echo "</table>"; } } else { $materia=$_GET['materia']; $result = mysqli_query($connection, "SELECT * FROM $materia") or die(mysqli_error($connection)); // loop tra i risultati della query del database, visualizzandoli in tabella while($row = mysqli_fetch_array( $result )) { // emissione del contenuto di ogni riga in una tabella echo "<tr>"; echo '<td>' . $row['voto'] . '</td>'; echo '<td>' . $row['data'] . '</td>'; echo '<td>' . $row['materia'] . '</td>'; echo '<td>' . $row['peso'] . '%</td>'; echo '<td>' . $row['descrizione'] . '</td>'; echo '<td><a class="waves-effect waves-light btn" href="edit.php?id=' . $row['id'] . '><i class="material-icons left">mode_edit</i>Modifica</a></td>'; echo '<td><a class="waves-effect waves-light btn" href="delete.php?id=' . $row['id'] . '><i class="material-icons left">delete</i>Elimina</a>'; echo "</tr>"; } // chiude la tabella echo "</table>"; } ?> </div> </body> </html> Thanks
-
Ah ok, it's because I'm very familiar with Python and so I use it... I searched on php.net and I found that the PHP operator for concatenation is . and it works! Another MySQL-PHP problem: I'm trying to convert to MySQLi the function mysql_result($result, $i, 'voto') but in mysqli there isn't any result function... how can I convert this? Thanks P.S.: I tried searching on Google but I can't use the code I found for this functions...
-
Ok solved, I 've moved session_start() from under html to above html. Now the dropdown doesn't show the options, instead it gives a blank option... EDIT: On XAMPP it works perfectly but not on Tommy... CODE: <?php include ("includes/config.php"); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: login.php'); } $username=$_SESSION['username']; ?> <html> <body> <form method="get"> <?php // load database values require 'connect-db.php'; // connect to database $conn = new mysqli($server, $user, $pass, $db); if ($conn->connect_error) die("Connection failed: ".$conn->connect_error); // perform query $sql = "show tables LIKE '$username%'"; $result = $conn->query($sql) or die($conn->error); // start dropdown select echo "<select>"; // for each table in database create an entry while ($row = $result->fetch_assoc()) { $table = $row["Tables_in_members ($username%)"]; echo "<option value='$table'>$table</option>"; } echo "</select>"; ?> <input type="submit" class="btn waves-effect waves-light" value="VISUALIZZA"> </form> </body> </html> Why? PROBLEM 2: I'm trying to create a table named $username_$subject but it doesn't work... I created before a variable, see below... $usersub=$username+"_"+$subject; mysqli_query($connection,"CREATE TABLE $usersub ( `voto` FLOAT NOT NULL , `data` CHAR NOT NULL , `materia` CHAR NOT NULL , `peso` INT NOT NULL , `descrizione` TEXT NOT NULL )") or die(mysqli_error($connection)); Thanks for your help!
-
I tried to edit something, but now it shows 2 blank options... In the error file: [18-Jul-2017 19:47:07 UTC] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/maicol07/public_html/apps/app/sld/voti/test_dropdown.php:2) in /home/maicol07/public_html/apps/app/sld/voti/includes/config.php on line 3
-
I've looked now... Sincerly I didn't know of error_log file... [18-Jul-2017 17:51:22 UTC] PHP Fatal error: Call to a member function fetch_assoc() on boolean in /home/maicol07/public_html/apps/app/sld/voti/test_dropdown.php on line 21
-
Hi, I tried but it doesn't work... it doesn't also show the button to send the form... page: https://apps.maicol07.tk/app/sld/voti/test_dropdown.php Code: <html> <body> <form> <?php $username="maicol07"; // load database values require 'connect-db.php'; // connect to database $conn = new mysqli($server, $user, $pass, $db); if ($conn->connect_error) die("Connection failed: ".$conn->connect_error); // perform query $sql = "show tables like '$username_%"; $result = $conn->query($sql); // start dropdown select echo "<select>"; // for each table in database create an entry while ($row = $result->fetch_assoc()) { $table = $row['Tables_in_maicol07_sld_voti']; echo "<option value='$table'>$table</option>"; } echo "</select>"; ?> <input type="submit" class="btn waves-effect waves-light" value="VISUALIZZA"> </form> </body> </html> Thanks
-
Ok thanks, it is only because on XAMPP it gives me an error, but if it works on Tommy ok!
-
I used the first code you gave me (second post) and it gives me that error. So, the error is related to that code, that has the Sql query SHOW TABLES. The other question is: the script I wrote in my last post can already be used or I need to edit something? Thanks
-
No, I mean this code: show tables while (another table) { select * from table } Anyway, the code you write doesn't work on XAMPP... it gives me this error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0' at line 1
-
Sorry but I can't understand well the condition in the while and in the line below the table...
-
With the SQL SELECT statement, I can select all the data (or a column) of a table. Example: SELECT * FROM table1 If I have table1, table2, table3, ... how can I SELECT all the data of all the tables? Thanks