Jump to content

Tekky

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by Tekky

  1. i don't understand this part, what is a LEFT JOIN?
  2. Hello, i need to compare two tables together. Here's my objective : One column in "a" database is named "Saint". And one column in "b" database is named "Nom". If for exemple, in the column of "a" is the name "test", then it has to look in database "b" and look for the same name. If the same name is on the database b, then i need to get the data (it's an url) of another column in the database b and use it as a href. I already know how to use the href in the project and the rest is done, both database are made and forms ready to insert new data in both but i'm a bit stuck on this problem
  3. Tekky

    Form List

    Hello and thank you for the time spent helping me. But i have another question, in your example, the <form> method is "get". But i also need to have a "post" method to recover the option used and sent and then display it somewhere else in the page. Do i have to make a <form> in another form (but i believe it's not really working) so is there any way to use both get and post or something?
  4. Hello, i'm a bit blocked, i'm trying to make a form, which display a list of options (the options would be retrieved from a data base), then a url corresponding to the option choosen which is saved in the database would be displayed. Basically : 1) Php script will load in the <input list> as much options as data is available in the database (if we have 10 names stored, then the 10 names will show up in the list!) 2)Once we choose the name we want and click on send, the name choosen have to show under the form with a url linked to it. My data base will have 3 data in one row. First is ID, second is Name, and third is URL. The url have to be recovered from it. Here's what i'm starting with from scratch : <form action="" method="get"> <label for="ListSaint">Choisis le Saint qui correspond a la date souhaité :</label> <input list="ListSaints" name="ListSaint" id="ListSaint"> <datalist id="ListSaints"> <option value="test1"> <option value="test2"> </datalist> <input type="submit"> </form> <h1>L'url est : <a href="url/"></a></h1> But i can not figure out how to add an option to the <datalist> with a php command which is connected to the data base. Thank you for paying attention to this.
  5. Oh i'm sorry i read this part too fast earlier. Thank you again!
  6. This is working fine when a data is in, but once nothing is in the string, i get this error : on the code web view : <input type='text' class="form-control" id="formJardin" name='JardinConseil' value="<br /> <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Trying to access array offset on value of type bool in C:\wamp64\www\b\form.php on line <i>186</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0001</td><td bgcolor='#eeeeec' align='right'>363456</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp64\www\b\form.php' bgcolor='#eeeeec'>...\form.php<b>:</b>0</td></tr> </table></font> ">
  7. The input which is working show : <input type='text' class="form-control" id="formJour" name='ConseilJour' value='un t&#039;a'> and one of the input not working : <input type='text' class="form-control" id="formJardin" name='JardinConseil' value='Ceci est un conseil d'>
  8. I also tried this, but this doesn't work on all my input, the only one working is : value='<?= htmlentities($post['ConseilJour'],ENT_QUOTES) ?? ''?> value='<?= htmlentities($post['ConseilJour'],ENT_QUOTES) ?? ''?> But if i do it with another value, for example : value='<?= htmlentities($post['JardinConseil'],ENT_QUOTES) ?? ''?> This is not working on this input This is why i'm a bit confused...
  9. A last small question, whenever a string contain a special character (in my case, the apostrophe), the sentence stop right before and half of the sentence is missing and etc. On my other project i was used to do this : <?php $jourconseil=utf8_encode($row['ConseilJour']); ?> But since i was used to copy one variable to another for nothing. I was wondering if there was a way to do it without using a variable. I tried this : <input type='text' class="form-control" id="formJour" name='ConseilJour' value='<?= utf8_encode($post['ConseilJour']) ?? ''?>'> But it doesn't really work, is there any way to do this ?(the php we should be looking at is in the <value>) thank you again for all the help
  10. Thank you a lot for everything and i'm sorry for the late answer, it took me a bit of time to understand every part, and as you said, it's just about logic working before even starting to code. I'm really gratefull, i managed to make it work with other's fields and everything. And i now understand why doing both in the same code is also easier !
  11. Then how should i do it? Thank you for the clear answer by the way, i really appreciate it.
  12. Hello. I'd like to make a form page where i can edit the data stored in my data base. Here's the steps i need : -> Select the date corresponding to the data row i want to edit. -> Show in <input> the current row data so i can edit only the <input> i want and the other's will write the same as before. -> Press button to send. With one condition : if no data available for the date selected, then show <input> with nothing in, so we can start uploading new data in a new row corresponding to the date. I already did 80% of the program i think, the input show the current data row and when button pressed, the data corresponding to today date get updated, but i have a problem with the date picker, i can't get to change the <input> data depending of the days selected. And same with the condition, i'm not sure where to add the code for it. Following next the total code i've done so far already : Form part : <?php $host = "localhost"; $username = "client"; $password = "client"; $dbname = "site";// On crée la connection PDO ici $dsn = "mysql:host=$host;dbname=$dbname"; $pdo = new PDO($dsn, $username, $password); $date = $_GET['date'] ?? date('Y-m-d'); // si aucun input, on met la date d'aujourd'hui par défault $days = $_GET['days'] ?? 0; // le nombre de jour par défault a 0 $dt = new DateTime($date); $newdate = $dt->modify("$days days")->format('Y-m-d'); //query $res = $pdo->prepare("SELECT * FROM cercles WHERE dates = ? "); $res->execute([$newdate]); if ($res->rowCount() > 0){ $row = $res->fetch(); $Energie = $row["Energie"]; $Planete = $row["Planete"]; $Lune = $row["Lune"]; $Saint = $row["Saint"]; $JardinConseil=$row["JardinConseil"]; $Ange=$row["Ange"]; $ConseilJour=$row["ConseilJour"]; $Soleil=$row["Soleil"]; $TypeLune=$row["TypeLune"]; echo "<html> <body> <form> <button name='days' value='-1'>&lt;</button> <input type='date' name='date' value='<?=$newdate?>' > <button name='days' value='1' >&gt;</button> <form action='phpUpdateFormScript.php' method='post'> Date: $newdate<br> Changer la date : <input type='date' name='dates' value='$newdate'> <br> Energie: <input type='text' name='Saint' value='$Energie'><br> Planete: <input type='text' name='Saint' value='$Planete'><br> Conseil jardin: <input type='text' name='Saint' value='$JardinConseil'><br> Ange: <input type='text' name='Saint' value='$Ange'><br> Saint: <input type='text' name='Saint' value='$Saint'><br> Conseil du jour: <input type='text' name='Saint' value='$ConseilJour'><br> Lune: <input type='text' name='Energie' value='$Lune'><br> Soleil: <input type='text' name='Planete' value='$Soleil'><br> TypeLune: <input type='text' name='Lune' value='$TypeLune'><br><br> <input type ='submit'> </form> </form </body> </html>"; } else { echo "Not Found"; } ?> Update script used in the <form action> : <?php $newdate = $_POST["dates"]; $Planete = $_POST["Planete"]; $Lune = $_POST["Lune"]; $Saint = $_POST["Saint"]; $Energie=$_POST["Energie"]; $JardinConseil=$_POST["JardinConseil"]; $Ange=$_POST["Ange"]; $ConseilJour=$_POST["ConseilJour"]; $Soleil=$_POST["Soleil"]; $TypeLune=$_POST["TypeLune"]; $servername = "localhost"; $username = "client"; $password = "client"; $db = "site"; $conn = new mysqli($servername, $username, $password, $db); if ($conn->connect_error){ die("Connection failed: ". $conn->connect_error); } $sql = "update cercles set `dates`='[$newdate]',`Energie`='$Energie',`Planete`='$Planete',`JardinConseil`='$JardinConseil',`Ange`='$Ange',`Saint`='$Saint',`ConseilJour`='$ConseilJour',`Lune`='$Lune',`Soleil`='$Soleil',`TypeLune`='$TypeLune'"; if ($conn->query($sql) === TRUE) { echo "Les données suivant ont étaient mis a jour pour la date ".$newdate." : ".$Energie"-".$Planete."-".$JardinConseil."-".$Ange"-".$Saint"-".$ConseilJour"-".$Soleil"-".$TypeLune; } else { echo "Error: ".$sql."<br>".$conn->error; } $conn->close(); ?> The front-end result : Thank you in advance for the help
  13. Yes, i asked myself the same questions.. I figured it out, all i has to do was to setup the div in the same form, and put as hidden the input and then it worked fine. Thank you for all the help, i'll mark as solution your comments and we can close the topic. Thank you again. Have a great day
  14. Hello, thank you a lot for the fast and the quality of the answer. I really appreciate it. It really helped me to understand what i was missing. But you didn't used any function in the small alternative you showed. However, i believe a function is necessary to have the buttons in different <div> and so different <form> ? Like this : (sorry for the bad quality drawing).
  15. Thank you a lot, this make a lot more sense, and i'll fix that right now. But my other problem is that, my php is loading when the page is loaded, so basically : step 1 -> the page load, and so php load informations from : SELECT * FROM cercles WHERE dates = curdate() step 2 -> The user have two buttons, one to load data from the previous day, and another one to load the data on the next day. To do this, i can use : SELECT * FROM cercles WHERE dates = curdate() - interval 1 day (or + interval 1 day instead for the second button). But in my index.php, i don't know how to reload all the data on the button click since i didn't make it a function? I tried to make it a function but it kinda broke all the html since it's in a while and so the html is only loaded if the database can return the values asked.. I don't know if i made my problem clear enough for you to understand.. Anyways, thank you already for the fast answer, i really appreciate it !
  16. Hello, i have a project for school. I have to display data from a mysqldata base corresponding of today date. And when i click on a button, the data must change to yesterday data instead. i already managed to display the data corresponding of the daily date. But i can't think of a way for displaying previous day data. I'm very new with php, i usually only do front-end. I'm not asking you to do my work, but if you could give me some tracks i could follow or should look at to begin, i would really appreciate it! thank you. Here's my index.php code : <!DOCTYPE html> <html> <head> <title>Mon chemin de vie</title> <!-- CSS only --> <link rel="stylesheet" type="text/css" href="css/navbar.css"> <link rel="stylesheet" type="text/css" href="css/cercles.css"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> <!-- JS script only --> <script src="https://kit.fontawesome.com/dacae46ffa.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script> </head> <?php $temp0=1; $temp1=0; // Configure la date local et récupere la date d'aujourd'hui date_default_timezone_set('Europe/Paris'); $date = date('d/m/Y'); echo $date; // Se connecte a la base de donnée $host = 'localhost'; //identifiants local dev : //$host = 'localhost'; $dbname = 'site'; $username = 'client'; $password = 'client'; $dsn = "mysql:host=$host;dbname=$dbname"; // récupérer les informations correspondant a la date d'aujourd'hui $currentdate = "SELECT * FROM cercles WHERE dates = '$date' "; try{ $pdo = new PDO($dsn, $username, $password); $stmt = $pdo->query($currentdate); if($stmt === false){ die("Erreur"); } }catch (PDOException $e){ echo $e->getMessage(); } ?> <body> <!-- Navbar only --> <nav class="navbar bg-light "> <div class="container-fluid"> <a class="navbar-brand" href="#">Mon chemin de vie</a> <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar"> <span class="navbar-toggler-icon"></span> </button> <div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar" aria-labelledby="offcanvasNavbarLabel"> <div class="offcanvas-header"> <h5 class="offcanvas-title" id="offcanvasNavbarLabel">Nos pages</h5> <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button> </div> <div class="offcanvas-body"> <ul class="navbar-nav justify-content-end flex-grow-1 pe-3"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Accueil</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Naturologie</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Agenda 2023</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Contacts et prestations</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Alphabets sacrés</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Conseils planétaires</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Prénoms</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Lunologie</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Décodage de soi</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Numérologie</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Angéologie</a> </li> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Astrologie</a> </li> </ul> </div> </div> </div> </nav> <?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : ?> <?php // On incrémente l'id de 1 ou moins 1 pour récupérer le jour d'avant ou après $jouravant=($row['id'])-1; $jourapres=($row['id'])+1; // Fonction boutton jour avant $previousdate = "SELECT dates FROM cercles WHERE id = '$jouravant' "; try{ $pdo = new PDO($dsn, $username, $password); $previousdate1 = $pdo->query($previousdate); if($previousdate1 === false){ die("Erreur"); } }catch (PDOException $e){ echo $e->getMessage(); } $afterdate = "SELECT dates FROM cercles WHERE id = '$jourapres' "; try{ $pdo = new PDO($dsn, $username, $password); $afterdate1 = $pdo->query($afterdate); if($afterdate1 === false){ die("Erreur"); } }catch (PDOException $e){ echo $e->getMessage(); } ?> <?php while($row1 = $previousdate1->fetch(PDO::FETCH_ASSOC)) : ?> <?php while($row2 = $afterdate1->fetch(PDO::FETCH_ASSOC)) : ?> <!-- Cercles only --> <div class="cercles"> <div class="d-flex justify-content-around"> <div class="quote-wrapper"> <blockquote class="text circle-bg-rose"> <p>Énergie <?php echo htmlspecialchars($row['Energie']); ?></p> </blockquote> </div> <div class="quote-wrapper"> <blockquote class="text circle-bg-bleu"> <p>Jeudi </br><span class="planets"><?php echo htmlspecialchars($row['Planete']); ?></span></p> </blockquote> </div> <div class="quote-wrapper"> <blockquote class="text circle-bg-vert"> <p>Jardin Conseil Pratique </br><span class="small-text"><?php echo utf8_encode($row['JardinConseil']); ?></span></p> </blockquote> </div> </div> <div class="d-flex justify-content-around flex-mid"> <div class="quote-wrapper mid"> <blockquote class="text circle-bg-violet"> <p><?php echo htmlspecialchars($row1['dates']); ?><form method="post"><input type="submit" name="button1"class="btn btn-link fa fa-arrow-left arrow-button" value="Button1" /></p></form> </blockquote> </div> <div class="big-quote-wrapper"> <blockquote class="text circle-bg-red"> <p><?php echo htmlspecialchars($row['dates']); ?> <img src="assets/img/image-1.png"class="text-4xl" width="320" height="90" loading="lazy"> <?php echo htmlspecialchars($row['Lune']); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo htmlspecialchars($row['Soleil']); ?> <?php echo utf8_encode($row['TypeLune']); ?> </p> </blockquote> </div> <div class="quote-wrapper mid"> <blockquote class="text circle-bg-violet"> <p><?php echo htmlspecialchars($row2['dates']); ?><button class="btn btn-link fa fa-arrow-right arrow-button"></button></p> </blockquote> </div> </div> <div class="d-flex justify-content-around"> <div class="quote-wrapper"> <blockquote class="text circle-bg-ange"> <p>Ange</br></br><?php echo htmlspecialchars($row['Ange']); ?></p> </blockquote> </div> <div class="quote-wrapper"> <blockquote class="text circle-bg-beige"> <p>Saint</br></br><?php echo htmlspecialchars($row['Saint']); ?></p> </blockquote> </div> <div class="quote-wrapper"> <blockquote class="text circle-bg-vert-clair"> <p>Conseil du jour</br><span class="small-text"><?php echo utf8_encode($row['ConseilJour']); ?></span></p> </blockquote> </div> </div> </div> <?php endwhile; ?> <?php endwhile; ?> <?php endwhile; ?> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.