ScoobyDont
Members-
Posts
43 -
Joined
-
Last visited
Everything posted by ScoobyDont
-
Public Function to retrieve data from 2 tables pdo
ScoobyDont replied to ScoobyDont's topic in PHP Coding Help
Sorry if I was not clear enough I would like the query to link and retrieve ALL the data from both 'users' and 'vehicle' tables so I can use the data to echo in areas of the site -
Hi, I am at the minute changing from mysql to pdo and whilst its starting to click I am still struggling with a few things namely trying to retrieve and join data from 2 separate tables Table 1: Name: users columns 1.user_id 2.registration 3. email Table 2: Name vehicle columns 1.reg_id 2. registration 3.vehicle 4.chassis The function I am currently trying to get to work is this public function UserDetails($user_id) { try { $db = DB(); $query = $db->prepare("SELECT user_id, registration, email FROM users INNER JOIN vehicle ON users.user_id = vehicle.reg_id"); $query->bindParam("user_id", $user_id, PDO::PARAM_STR); $query->execute(); if ($query->rowCount() > 0) { return $query->fetch(PDO::FETCH_OBJ); } } catch (PDOException $e) { exit($e->getMessage()); } } I want the data so I can <?php echo $user->Vehicle?> on the frontend Any help much appreciated
-
Current Status and Previous States where to start
ScoobyDont replied to ScoobyDont's topic in PHP Coding Help
Right Ok will go down that route and bring this thread back up when without no doubt I will get stuck again Thank you...much appreciated -
HI All, Sorry for sounding crap but searching the net has come up with nothing and that's what I have nothing...and to be honest dont know where to start looking for what I need I will try and explain as best I can In the db I have current_status, this is updated from a select list in a form on website one status 1 status 2 status 3 etc etc So when the user changes the "status" from website 1 it updates the database and shows the current status in website 2 What I want is to show the previous states with a time stamp on when it was changed something like image attached Am I right in thinking I will not be able to do this with only working with one row in the db or is this possible with php alone Can someone give me a pointer where to start, I am not after anyone to write code just a little advice Thanks in advance
-
Hi I am creating a site using bootstrap and have a few collapsed panels, the trouble I am having is when the page first loads the down arrow needs pressing twice before it does anything, can this be fixed js $(document).on('click', '.panel-heading span.clickable', function(e){ var $this = $(this); if(!$this.hasClass('panel-collapsed')) { $this.parents('.panel').find('.panel-body').slideUp(); $this.addClass('panel-collapsed'); $this.find('i').removeClass('fa fa-arrow-up').addClass('fa fa-arrow-down'); } else { $this.parents('.panel').find('.panel-body').slideDown(); $this.removeClass('panel-collapsed'); $this.find('i').removeClass('fa fa-arrow-down').addClass('fa fa-arrow-up'); } }) And this is the code for the header <div class="panel-heading"> <span class="pull-right clickable"><i class="fa fa-arrow-down" aria-hidden="true"></i></span> <h4><i class="fa fa-calendar" aria-hidden="true"></i> Important Events </h4> </div> Thanks for any help in advance
-
HI, Thanks I will make sure my site is sqli'd This is just a dummy site to test populating my site from a third party site, so I am not to bothered about security etc etc etc at the minute. Here is the "update.php" code $registration = $_POST['registration']; $chassis = $_POST['chassis']; $engine = $_POST['engine']; $datein = $_POST['datein']; $timein = $_POST['timein']; $dateout = $_POST['dateout']; $timeout = $_POST['timeout']; $jobstatus = $_POST['jobstatus']; $wipno = $_POST['wipno']; $contactnumber = $_POST['contactnumber']; $email = $_POST['email']; $name = $_POST['name']; $vehicle = $_POST['vehicle']; $team = $_POST['team']; $data = "UPDATE `register` SET registration='$registration', chassis='$chassis', engine='$engine', datein='$datein', timein='$timein', dateout='$dateout', timeout='$timeout', jobstatus='$jobstatus', wipno='$wipno', contactnumber='$contactnumber', email='$email', name='$name', vehicle='$vehicle', team='$team' WHERE wipno=".'"'.$wipno.'"'; $query = mysql_query($data) or die("Ooops Its snapped. ". mysql_error()); ?>
-
This is the form that starts the query <form action="update.php" method="post" name="update"> <input id="wipno" placeholder="WIP No" name="wipno" class="textbox" type="text" /> <input name="submit" type="submit" id="submit" value="Get Customer Record" /> <p><a href="insert.php">Insert New Record</a></p> </form> This is "update.php" $search=$_POST['wipno']; $data = 'SELECT * FROM `register` WHERE `wipno` = "'.$search.'"'; $query = mysql_query($data) or die("That Didnt work. ". mysql_error()); $data2 = mysql_fetch_array($query); ?> <div class="header"><h3>Update Customer/Booking</h3></div> <form action="updated.php" method="post" name="updaterecord"> <label>Reg No</label><input name="registration" id="registration" type="text" class="formfieldssmall" value="<?php echo $data2['registration']?>"/> <label>Chassis No</label><input name="chassis" id="chassis" type="text" class="formfields" value="<?php echo $data2['chassis']?>"/> <label>Engine No</label><input name="engine" id="engine" type="text" class="formfields" value="<?php echo $data2['engine']?>"/> <label>Date In</label><input name="datein" id="datein" type="text" class="formfields" value="<?php echo $data2['datein']?>"/> <label>Time In</label><input name="timein" id="timein" type="text" class="formfieldssmall" value="<?php echo $data2['timein']?>"/> <label>Date Out</label><input name="dateout" id="dateout" type="text" class="formfields" value="<?php echo $data2['dateout']?>"/> <label>Time Out</label><input name="timeout" id="timeout" type="text" class="formfieldssmall" value="<?php echo $data2['timeout']?>"/> <label>Job Status</label><select name="jobstatus" class="formfields"> <option value="">Please Select</option> <option value="<?php echo $data2['jobstatus']?>"></option> <option value="offsite">Off Site</option> <option value="onsite">In On Site</option> <option value="allocatedtotech">Allocated to Tech</option> <option value="awaitingauth">Awaiting Authority</option> <option value="qualitycheck">Quality Check</option> <option value="awaitingwash">Awaiting Wash</option> <option value="awaitinginvoice">Awaiting Invoice</option> <option value="readytocollect">Ready to Collect</option> </select> <label>Wip No</label><input name="wipno" id="wipno" type="text" class="formfields" value="<?php echo $search?>">"/> <label>Contact No</label><input name="contactnumber" id="contactnumber" type="text" class="formfields" value="<?php echo $data2['contactnumber']?>"/> <label>Email</label><input name="email" id="email" type="text" class="formfields" value="<?php echo $data2['email']?>"/> <label>Name</label><input name="name" id="name" type="text" class="formfields" value="<?php echo $data2['name']?>"/> <label>Vehicle</label><input name="vehicle" id="vehicle" type="text" class="formfields" value="<?php echo $data2['vehicle']?>"/> <label>Team</label><select name="team" class="formfields"> <option value="">Please Select</option> <option value="sa1">SA1</option> <option value="sa2">SA2</option> <option value="sa3">SA3</option> <option value="sa4">SA4</option> </select> <br /> <input name="submit" type="submit" class="button"value="Update Customer" /> </form> Hope this helps
-
Hi I am creating a dummy 3rd party site for my main site, I have everything working apart from the most important part The trouble I am having is I use the dummy site to add a new user to a db and have a second page for updating, page 1 ="Enter Customer Number" - Submit button to open page 2 which is a form with populated data from the db The trouble is I cannot get it to re populate the select list <label>Job Status</label><select name="jobstatus" class="formfields"> <option value="">Please Select</option> <option value="offsite">Off Site</option> <option value="onsite">In On Site</option> <option value="allocated">Allocated</option> </select> Everytime I pull the data back into the form it says "Please Select" I have tried <?php echo $data['jobstatus']?>"> And placed it in a couple of areas but no luck. Can anyone help how I can repopulate the form list with what is in the db and not "Please Select" Thanks in advance