Jump to content

jodunno

Members
  • Content Count

    100
  • Joined

  • Last visited

  • Days Won

    2

jodunno last won the day on May 15

jodunno had the most liked content!

Community Reputation

5 Neutral

About jodunno

  • Rank
    Advanced Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. advice allready given. read entire thread b4 trolling.
  2. use css but don't ask me why the techies name it text-align instead of content-align or something more inclusive. <style>.image { text-align: center; }</style> <div class="image"> <img src="logo.jpg" alt="John Doe"/> </div>
  3. so this is not correctly formed. I wish i knew how to describe the variables accurately but i do not know how to do so. let's try it this way and see if it makes sense: you need to define a way to connect to the database using pdo. thus $bdd = new PDO (); you can name this variable whatever you want to name it. $80s_rocker_still_rockin_but_missing_me_long_hair = new PDO(). get it? then you need a query, which can be called whatever you want it to be called. such as $qry, $query, $scorpions_bad_boys_running_wild. who cares about the name. The concept is important here: $jodunno_nuthin = 'SELECT * FROM convoy_part WHERE user_convoy= :I"; you are actually going to 'prepare' this query for execution. then you use another variable named anything that you want to represent the database actions being performed. $s2, $start, $kix_blow_my_fuse or whatever. $gnr_nighttrain = new PDO("bla blah", more-blah , blah); $jodunno_nuthin = 'SELECT * FROM convoy_part WHERE user_convoy= :I"; $load_the_cannons = $gnr_nighttrain->prepare($jodunno_nuthin); $load_the_cannons->execute(array(':I' => $_GET['id'])); $db_is_shooting_back = $load_the_cannons->fetch(); put it all together in one sensical operation. so let's light the cannons and fire: $query = "SELECT * FROM convoy_part WHERE user_convoy= :I'; $start = $bdd->prepare($query); $start->execute(array(':I' => $_GET['id'])); then perform your fetch. think of a dog chasin' a stick: fetch boy! $result = $start->fetch(); naming variables really doesn't matter when you are practicing code. understanding variables is 'sehr wichtig'. keep it all sensical, logical and easy to understand when you look at the code 5 years from now. The idea is to understand what $bdd represents and what $query represents, etc. you are often times getting lost and mixing variable names as if you don't understand what is happening. stay focused! Best wishes.
  4. oh, yay! i am happy for you! good work! Thank you for putting forth the effort. Best wishes.
  5. hello, i really have no time to code it for you. i need to mention that my last post needs to be adjusted by you. the query needs to be changed from columns to all if you wish to fill the variables correctly. so $query = 'SELECT convoy_name, convoy_organizer FROM convoys where id = :getId'; needs to be $query = 'SELECT * FROM convoys where id = :getId'; you take things to literally and i have no time to be perfect. i need to go for now.
  6. we also have to deal with the missing code because php will not function correctly when it comes across an undefined variable or many undefined variables. I mentioned $convoy_kilometer not being set in an earlier post but today i see the code. I didn't see that code yesterday, so my apologies for missing this code. now that you have the data from the database, you need to integrate it into your code. You will use only this working code to retrieve the data. So your old attempts must not be included in the file anymore. replace your content with the working code then slowly rebuild the page to work with this code. a few working changes means you can speed up the process and finish the page. so if the code works, then start your new document like so: <?php session_start(); if (!isset($_SESSION['username'])) { die('<meta http-equiv="refresh" content="1; URL=">'); } ?> <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="all,follow"> <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css"><link rel="stylesheet" href="css/font.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Muli:300,400,700"> <link rel="stylesheet" href="css/style.default.css" id="theme-stylesheet"> <link rel="stylesheet" href="css/custom.css"><link rel="shortcut icon" href="img/favicon.ico"> </head> <body> <?php require('connection/db1.php'); //db1.php should contain your db connection material. i've included it here to remind you that it is needed for db connection //remove this code if you have it set in db1.php. notice that we set PDO::FETCH_ASSOC so you don't need to do this in the fetch statement //start of removable code if it exists in db1.php $your_db_username = 'root'; $your_db_password = ''; $attributes = array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); //end of removable code if it exists in db1.php $connection = new PDO("mysql:host=$host; dbname=$yourdbnamevar; charset=utf8mb4", $your_db_username, $your_db_password, $attributes); $query = 'SELECT convoy_name, convoy_organizer FROM convoys where id = :getId'; $start = $connection->prepare($query); $start->execute(array(':getId' => $_GET['id'])); //are you sure that $_GET['id'] is set and not empty/contains valid data? //$count = $start->rowCount(); //i think that count should still work correctly but i've commented it out to avoid problems. $result = $start->fetch(); foreach ($result as $results) { $convoy_veranstalter = $result['convoy_veranstalter']; $convoy_server = $result['convoy_server']; $convoy_date = $result['convoy_date']; $convoy_adddate = $result['convoy_adddate']; $convoy_language = $result['convoy_language']; $convoy_participants = $result['convoy_participants']; $convoy_route = $result['convoy_route']; $convoy_description = $result['convoy_description']; $convoy_kilometer = $result['convoy_kilometer']; $convoy_web_social = $result['convoy_web_social']; } ?> <?php include 'includes/inc.navbar.php';?> <!-- Sidebar Navigation end--> <div class="page-content"> <div class="page-header"> <div class="container-fluid"> <h2 class="h5 no-margin-bottom">Dashboard</h2> </div> </div> <section class="no-padding-top no-padding-bottom"> <div class="container-fluid"> <div class="row"> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-user-1"></i></div><strong>Veranstalter:</strong> </div> <div class="dashtext-3"><?php if (isset($convoy_veranstalter)) { echo $convoy_veranstalter; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-contract"></i></div><strong>Teilnehmer:</strong> </div> <div class="dashtext-3"><?php if (isset($count)) { echo $count; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-paper-and-pencil"></i></div><strong>Kilometer</strong> </div> <div class="dashtext-3"><?php if (isset($convoy_kilometer)) { echo $convoy_kilometer; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-writing-whiteboard"></i></div><strong>Server</strong> </div> <div class="dashtext-3"><?php if (isset($convoy_server)) { echo $convoy_server; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="35" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> </div> </div> </section> <section class="no-padding-top"> <div class="container-fluid"> <div class="row"> <div class="col-lg-9"> <div class="block margin-bottom-sm"> <div class="title"><strong>Event Description:</strong></div> <?php echo $convoy_description;?> </div> </div> </div> <footer class="footer"> <div class="footer__block block no-margin-bottom"> <div class="container-fluid text-center"> <p class="no-margin-bottom">2020 &copy; Your company. Design by <a href="https://bootstrapious.com/p/bootstrap-4-dark-admin">Bootstrapious</a>.</p> </div> </div> </footer> </div> </div> <!-- JavaScript files--> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/popper.js/umd/popper.min.js"> </script> <script src="vendor/bootstrap/js/bootstrap.min.js"></script> <script src="vendor/jquery.cookie/jquery.cookie.js"> </script> <script src="vendor/chart.js/Chart.min.js"></script> <script src="vendor/jquery-validation/jquery.validate.min.js"></script> <script src="js/charts-home.js"></script> <script src="js/front.js"></script> </body> </html> replace echo variables with an if isset to avoid errors if a problem exists. let us know how it goes...
  7. jodunno

    json, ajax help

    Hello everyone, i do not know how to use json or ajax to accomplish anything in code. However, i have read many times about the benefits of json/ajax, which sound lovely to me. For example, i have a background settings page on my website where a user can turn on/off bg photos, select a bg color instead of photo, apply a tint color to a bg photo, select a tint color or apply a css bg pattern to the whole bg. I currently do all of this via form post, write to db, set in session, read from session, display selection accordingly. I am now wondering how i could do this using json or ajax so that the user remains on the page and json or ajax communicates with php to make the changes. Anyone know of a simple tutorial for this process? anyone willing to offer sample code or pseudo code? i have no idea how this works. Thank you.
  8. so you are saying that it works? you see the data pulled from the database?
  9. it seems to me that you are copying and pasting code from this thread without trying to understand the code. for example, you have the following code in your file: $query = "SELECT * FROM convoy_part WHERE us_convoy=:get_id"; $stmt = $pdo->prepare($query); $start->execute(array(':getId' => $_GET['id'])); $result = $stmt->fetchALL(PDO::FETCH_ASSOC); you don't even notice the difference between :get_id and :getId. (the underscore naming convention, by the way, is just more useless bytes added to the file) once again, remove the following code block from your file: <?php include 'connection/sql1.php'; // Abrufen der ID für Teilnehmerknopf if (isset($_GET['id'])) { $user2 = mysqli_real_escape_string($conn , $_GET['id']); $query = "SELECT * FROM convoy_part WHERE id= '$user2' "; $run_query = mysqli_query($conn, $query) or die(mysqli_error($conn)) ; } ?> do you not notice that the aforementioned codeblock contains mysqli code? in your code you echo $convoy_kilometer but where is this data coming from? where do you set a variable named $convoy_kilometer? last time i mention a practice file. I recommend that you make a new blank php file specifically for learning pdo. use your current file as a basis. Actually, just start frsh from the html body tag with a proper pdo code block. simply echo results to see it working, then build the rest of your page. you have enough pdo ammo to clean up your document. the rest is up to you. let us know when you get it working...
  10. I strongly urge you to create a practice file. You have to integrate your code to the pdo format. You implemented pdo but you still have old mysqli statements left in the code which need to be removed. I wouldn't loop at all if you are only fetching all columns in one row. a loop is necessary if you need all columns from many rows. xampp is nice and easy to install. set up a simple database and create a php file to practice pdo. like so: database name: mytestdb table name: convoys columns: id, user_id, convoy_name, convoy_organizer $host = 'localhost'; $yourdbnamevar = 'mytestdb'; $your_db_username = 'root'; $your_db_password = ''; $attributes = array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $fake_id = 1; $connection = new PDO("mysql:host=$host; dbname=$yourdbnamevar; charset=utf8mb4", $your_db_username, $your_db_password, $attributes); $query = 'SELECT convoy_name, convoy_organizer FROM convoys where id = :id'; $start = $connection->prepare($query); $start->execute(array(':id' => $fake_id)); $result = $start->fetch(); echo $result['convoy_name'] . '<br>' . $result['convoy_organizer']; Best wishes.
  11. his code is missing the closing bracket: $stmt->execute([':get_id' => $ _GET ['id']]); which is why i use array (so that brackets are easy to see): $start->execute(array(':getId' => $_GET['id'])); really, you should use a practice file and select names that are consistent. either $start, $s2, $stmt or some other name but mixing names even in this thread is confusing.
  12. so you just want the filename (optional extension) from a uri? <?php declare (strict_types = 1); $uri = 'http://my-site.com/gifts/images/my-image.jpg'; echo $uri . '<br>'; $ext = pathinfo($uri, PATHINFO_EXTENSION); $uri = pathinfo($uri, PATHINFO_FILENAME); echo 'filename is: ' . $uri . '<br>voila!<br>'; echo '<br>looking for extension?<br>'; echo 'filename and extension: ' . $uri . '.' . $ext; echo '<br>and once again, voila!'; exit; ?>
  13. you have the following code: <?php // Abrufen der ID für Teilnehmerknopf if (isset($_GET['id'])) { $user2 = mysqli_real_escape_string($conn , $_GET['id']); $query = "SELECT * FROM convoy_part WHERE id= '$user2' "; $run_query = mysqli_query($conn, $query) or die(mysqli_error($conn)) ; } ?> you should practice pdo in a new php file. write it out according to my example and examples on internet pages about pdo. when you see the expected results printed on the screen of your new php practice file, then you can begin integrating your webpage to the new pdo method of retrieving data from a db.
  14. Hello Endrick, please slow down and be certain that you are maintaining consistency in your variable names. you are using $s2 in place of $start. let's agree on names: $bdd, $query, $s2, $results. Then try the following code: <?php require('connection/db1.php'); // Abfragen der Daten z.B. für <?php echo $convoy_description; ... $bdd = new PDO("", ,); //fill in connection data and be sure that this data is available in db1.php $query = 'SELECT * FROM convoy_part WHERE user_convoy = :getID'; $s2 = $bdd->prepare($query); $s2->execute(array(':getID' => $_GET['id'])); //if you do not set fetch association in the attributes, then you must set it in your while loop while ($result = $s2->fetch(PDO::FETCH_ASSOC)) { $convoy_name = $result['convoy_name']; $convoy_veranstalter = $result['convoy_veranstalter']; $convoy_server = $result['convoy_server']; $convoy_date = $result['convoy_date']; $convoy_adddate = $result['convoy_adddate']; $convoy_language = $result['convoy_language']; $convoy_participants = $result['convoy_participants']; } ?>
  15. also, db1.php has insufficient data for making a connection. $bdd = new PDO('mysql:host=localhost;dbname=;charset=utf8', '', ''); let's pretend that your database is name 'mytestdb' and your database username is 'root' and your password is empty (default empty using xampp). $host = 'localhost'; $yourdbnamevar = 'mytestdb'; $your_db_username = 'root'; $your_db_password = ''; $attributes = array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $bdd = new PDO("mysql:host=$host; dbname=$yourdbnamevar; charset=utf8mb4", $your_db_username, $your_db_password, $attributes); be sure to include host, database name, character set if you need it followed by the actual db username, password and attributes. as for your last post, have you tried the following approach? $result = $start->fetch(); $convoy_name = $result['convoy_name']; $convoy_veranstalter = $result['convoy_veranstalter']; $convoy_server = $result['convoy_server']; $convoy_date = $result['convoy_date']; $convoy_adddate = $result['convoy_adddate']; $convoy_language = $result['convoy_language']; $convoy_participants = $result['convoy_participants']; //you could also use closeCursor as a feel-good terminator $start=>closeCursor(); once you execute the fetch, then your data is available to you. Either set variables for each requested column or use loops.
×
×
  • 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.