omardavinci
-
Posts
32 -
Joined
-
Last visited
Posts posted by omardavinci
-
-
Thanks a lot for your help. I am very thankful. You helped me a lot . Merci.
-
At first i create the form very easy with php:
<h4>Title 1</h4>
<form method="POST">
<table>
<tr>
<td><input id ="1" type="text" name="valueToSearch" placeholder="Value To Search"></td><br><br>
</tr>
<tr><td><input type="submit" name="search" value="Filter"></td></tr>
</form></table>
<br>
';Obviously since if(isset[$_POST]) i did the query like this:
But in my case i want to update $articles ($articles are the articles ordered by pages), i mean this:
$perPage = 2;
//Positioning
$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;
$art = $database_connection->query("SELECT id FROM user");
//Query
$articles = $database_connection->prepare("SELECT id FROM user LIMIT $start,$perPage");
$articles->execute();
$articles = $articles->fetchAll();
$resultado = $database_connection->query("SELECT COUNT(*) AS total FROM user");
$fila = $resultado->fetch(PDO::FETCH_ASSOC);
$total = $fila["total"];
$pages = ceil($total/$perPage);In conclusion, my question is very short. how i can update $articles when someone use filter to filter the table. In other words, i am trying to search some way to update $articles and i am little lost. Thanks in advance.
-
solved i am dump i was sending other path
-
-
Hi i am trying to do a simple pagination in php but when i try for example go to some page like localhost/page=1 i get this result:The requested URL /www/page=2 was not found on this server. Obviously this is because i did some mistake in the code. I share with members the php and html file for if someone has some suggestion. Thanks in advance:
html:
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title><?php echo $title; ?></title><link rel="stylesheet" type="text/css" href="Styles/Stylesheet.css" /></head><body><div id="wrapper"><div id="banner"></div><nav id="navigation"><ul id="nav"><li><a href="index.php">Home</a></li><li><a href="tool.php">Coffee</a></li><li><a href="manager.php">Shop</a></li><li><a href="#">About</a></li></ul></nav><div id="content_area"><?phprequire_once("tool.php");foreach ($articles as $article):echo $article['id'];endforeach;?></br><?phpfor($x=1;$x<=$pages;$x++):?><a href="page=<?php echo $x;?>"><?php echo $x;?></a><?php endfor;?></div><div id="sidebar"></div><footer><p>All rights reserved</p></footer></div></body></html>php:
<?php
require_once 'database.php';$database_connection = database_connect();$title='hola';$content='<div>';//user input$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;$perPage = 1;//Positioning$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;$art = $database_connection->query("SELECT id FROM coffee");//Query$articles = $database_connection->prepare("SELECT id FROM coffee LIMIT 0,5");$articles->execute();$articles = $articles->fetchAll();$resultado = $database_connection->query("SELECT COUNT(*) AS total FROM coffee");$fila = $resultado->fetch(PDO::FETCH_ASSOC);$total = $fila["total"];$pages = ceil($total/$perPage);echo $pages;$content .= '<div>';include 'Template_1.php';?>any suggestion, dissapointment is good received
-
Sorry was solved i need to bind parameter // statement $statement->bindValue(':fname', $fname); after use prepare
-
Hi sorry but i tried to use of many ways and i use prepare etc, But i cant create one without vars. But when i use one form and check the post method to save this new row. It is empty. Code:
<?phprequire_once 'database.php';$database_connection = database_connect();$users = $database_connection->query('SELECT * FROM coffee')->fetchAll();$title = 'Home';$content = '<h4>Title 1</h4><form method="POST"><table><tr><td><input type="number" name="fname" required placeholder="First Name"></td></tr><tr><td><input type="text" name="lname" required placeholder="Last Name"></td></tr><tr><td><input type="text" name="age" required placeholder="Age" min="10" > </td></tr><tr><td><input type="submit" name="insert"></input></td></br></tr></form></table><br>';$content .= '<br><table>';if(isset($_POST['submit']) == "insert"){// get values form input text and number$fname = $_POST['fname'];$lname = $_POST['lname'];$age = $_POST['age'];$uso = $database_connection->query('INSERT INTO coffee (id) VALUES (:fname)');}else{echo "nothing";}foreach($users as $user) {$content .= '<tr>';$content .= '<td>' . $user["id"] . '</td>';$content .= '<td>' . $user["type"] . '</td>';$content .= '<td>' . $user["price"] . '</td>';$content .= '<td><a href="index.php">' . $user["price"] . '<a/></td>';$content .= '<td><a href="index.php">' . $user["price"] . '<a/></td>';$content .= '</tr>';}$content .= '</table>';include 'Template.php';?>I am trying to do easy things. Like insert,update,delete,search but with a form.
-
-
I forgot to ask can someone recommend me some guide updated of PHP and mysql thanks for all
-
thx:
foreach($users as $user) {$content = $content . '<td>' . $user["id"] . '</td>';}$content .= 'I will learn more the basic things.
-
i know that this iterate one array and output to the client but it is not my question. Anyways i will take your advice.
I am newbie yes but no one born knowing perfectly php and all. So i wait one new opportunity in my other questions thx.
-
My question is only that:
I cant include this code in $content var when i have content of my page:
foreach($users as $user):echo $user['id'];endforeach;This was only my question. But i will take your advice thx
-
Ok sir i will take your advice thx a lot
-
Ok sorry i will learn more. Sorry again. But my question is very short sir: I did one content var in php because i want to do my webpage in php only and there i include my html content. So i couldn't include my querys since there? This is my question nothing more. Maybe i dont know nothing about php and mysql but this is not my question. Anyways thx for your help
-
Sorry for the mistake i created the rows with insert into, i was confused sorry again. I confused rows with columns;
I fixed this mistake now:
My question is very short, some way to include rows since content php, I could only do outside of my template like this:
<?phprequire_once 'database.php';$database_connection = database_connect();$users = $database_connection->query('SELECT id FROM coffee')->fetchAll();var_dump($users);$title = 'Home';$content = '<h4>Title 1</h4><table><th><td>   Name    </td><td>   Title    </td><td>   ola   </td></th><tr><?php foreach($users as $user): ?><td><?php echo $user["id"]?></td><?php endforeach;?></tr></table>';?><?php foreach($users as $user): ?><td><?php echo $user['id']?></td><?php endforeach;?>Some way to include in content of php? Or some way that show me the table inside of my template thxx
-
when i do:
var_dump($users);i get this message:
C:\wamp\www\www\tabla.php:10:
array (size=0)
emptyBut it is strange because i created one table called tabla and it have content. And when i select one column like Nombre:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Nombre' in 'field list'' in C:\wamp\www\www\tabla.php on line 9
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Nombre' in 'field list' in C:\wamp\www\www\tabla.php on line 9
And the table i created since database of users, since phpmyadmin, all is right. So maybe i did something wrong.
The table exists like you can see in this image:
https://i.imgsafe.org/5391e48b22.png
the code of tabla for you need to check:
<?phprequire_once 'database.php';$database_connection = database_connect();$users = $database_connection->query('SELECT # FROM tabla')->fetchAll();var_dump($users);$title = 'Home';$content = '<h4>Title 1</h4><table><th><td>   Name    </td><td>   Title    </td><td>   ola   </td></th><tr><?php foreach($users as $user): ?><td><?php echo $user["id"]?></td><?php endforeach;?></tr></table>';include 'Template.php';?>Sorry again for all
-
sorry for users but maybe i forgot to change it.
But anyways when i use this, i get the same:
<?php foreach($users as $user): ?><td><?php echo $user["id"]?></td><?php endforeach;?>Yes you are right i took many mistakes with source code so i need to take more care the next time.
-
ok sorry
so when i do this:
$users = $database_connection->query('SELECT * FROM users')->fetchAll();
<?php foreach($users as $users): ?><tr><td><?php echo $user['id']?></td></tr><?php endforeach;?>i included this for showing the tables but not show me nothing i will check more tutorials thxThe code finally:<?phprequire_once 'database.php';$database_connection = database_connect();$users = $database_connection->query('SELECT * FROM tabla')->fetchAll();$title = 'Home';$content = '<h4>Title 1</h4><table><th><td>   Name    </td><td>   Title    </td><td>   ola   </td></th><?php foreach($users as $users): ?><tr><td><?php echo $user["id"]?></td></tr><?php endforeach;?></table>';include 'Template.php';?>Any suggestion is good received, dissapointments too
-
A sorry you are right i did since databases.php
But why doesnt show me the elements of the table??
-
sir i tried to call again fetchall and take me error:
<?phprequire_once 'database.php';$database_connection = database_connect();$users = $database_connection->query('SELECT * FROM tabla')->fetchAll();$rows = $users->fetchAll();$title = 'Home';$content = '<h4>Title 1</h4><table><th><td>   Name    </td><td>   Title    </td><td>   ola   </td></th><?php foreach($rows as $row): ?><tr><td>echo $row["id"]</td></tr><?php endforeach;?></table>';include 'Template.php';?> -
Thx a lot SIR you are very good person thx
-
Hi i get the follow error.
Fatal error: Call to a member function fetchALL()Code:
<?php$db = new PDO("mysql:host=localhost;dbname=dwn;cahset=UTF","root","");$sql = "SELECT * FROM 'users'";$stmt = $db -> query($sql);$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);$title = "Home";$content = '<h4>Title 1</h4><table><th><td>   Name    </td><td>   Title    </td><td>   ola   </td></th></table>';include 'Template.php';?> -
Hi i am using notepad++, i tried netbeans but it takes me some problems like: Object not-found or i put the source to open and create one project. And when i did updates, they are not updated, etc etc. So please if you have some good editor or you prefer netbeans which do you prefer?
-
all it is ok thx
Use frameworks for my projects
in Frameworks
Posted
Nowadays, it seems that frameworks are a best environement for advanced developers. On the other hand, it could be argued that they really are not necessary when you develop some website in php. However, this environements speed up a lot the appearing of many projects. So my question is: You recomend some novice developer to use frameworks? Any suggestions or dissapointments are good received. Thanks in advance.