Jump to content

Search the Community

Showing results for tags 'sql'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 102 results

  1. Hello everyone, I am a total newbie in PHP and so do here. I am trying to build a table consisting foreign key and primary key and it is showing error like "Parse error: syntax error, unexpected 'cities' (T_STRING) in line number 29". I have marked up my lines according to sublime text 3 editor. I am trying to create a database. 1 <?php 2 $servername = "localhost"; 3 $username = "username"; 4 $password = "password"; 5 $dbname = "newDB"; 7 // Create connection 8 $conn = new mysqli($servername, $username, $password, $dbname); 10 // Check connection 11 if ($conn->connect_error) { 12 die("Connection failed: " . $conn->connect_error);} 14 $firstname = $conn->real_escape_string($_REQUEST['firstname']); 15 $lastname = $conn->real_escape_string($_REQUEST['lastname']); 16 $address = $conn->real_escape_string($_REQUEST['address']); 17 $city = $conn->real_escape_string($_REQUEST['city']); 18 $country = $conn->real_escape_string($_REQUEST['country']); 19 $phone_number = $conn->real_escape_string($_REQUEST['phone_number']); 20 $email = $conn->real_escape_string($_REQUEST['email']); 22 // Attempt insert query execution 23 $sql1 = "INSERT INTO cities VALUES ('$city')"; 25 $sql2 = "INSERT INTO countries VALUES ('$country')"; 27 $sql3 = "INSERT INTO Contacts (firstname, lastname, address, city, country, phone, email) VALUES ('$firstname', '$lastname', '$address', $city, $country, '$phone_number','$email')"; 29 SELECT * FROM cities; SELECT * FROM countries; SELECT * FROM Contacts; if($conn->query($sql1) === true){ echo "City added successfully."; } else{ echo "ERROR: Could not able to execute " . $conn->error; } if($conn->query($sql2) === true){ echo "Çountry added successfully."; } else{ echo "ERROR: Could not able to execute " . $conn->error; } if($conn->query($sql3) === true){ echo "Çontact added successfully."; } else{ echo "ERROR: Could not able to execute " . $conn->error; } // Close connection $conn->close(); ?>
  2. Hello Everyone - I am playing around with some MYSQL and PHP project I have. I ran into a complex problem getting a PHP table filled with data from MYSQL. I will try to explain what I am trying to do: I am trying to do something like this but in PHP. This is my data from MYSQL database. The Table is called Children This is a quick explanation of how each column on the first screenshot should be filled from the database. This code is what I have so far... to be honest i am not sure how to get the totals of rest of the columns. Maybe use I can use subqueries or if statements... not sure! Can you please help me out? $r = mysqli_query($dbc,"SELECT Classrooms.ClassroomName, COUNT(*) AS TotalChildren FROM Children JOIN Classrooms ON Children.classroomID = Classrooms.classroomID GROUP BY Classrooms.ClassroomName");
  3. I'm attempting to create a SQL command that can sort through a concatenated string in my database it is listed at Colors: blue,red,green,yellow is SELECT * FROM `shoes` WHERE CONCAT(',',color,',') LIKE '%,blue,red%' How do I filter the data where it can come up with shoes that are available in red or blue or red and blue and so on? I could use where find_in_set('blue', colors) > 0 and find_in_set('red', colors) > 0 Is there a better way of doing this? Shoe name: shoe A Shoe size: 7,8,9 Shoe color: black , brown, grey For example could have a shoe available in black , size 8 or 9 or 8 and 9.
  4. I have a page of html tables that are filled by database values through PHP, and there are no problems there. However, I have an issue on one of the tables. I have a pricing table, attached below. The $575 is currently filled from a field in the database that is set from a CSV upload, but the new CSV template is not doing this because it's missing the price field. This is the SQL statement that I'm using in the database, since the price is based off of meterSize, meterType and workOrderType2: UPDATE staging INNER JOIN pricing ON staging.meterType = pricing.meterType AND staging.meterSize = pricing.meterSize AND staging.workOrderType2 = pricing.workOrderType SET staging.onsiteTestSurveyPrice = pricing.price This works, but only with the original template, so I'm looking into doing this strictly in PHP with the table/row values, if possible. An example of what I'm looking for, using the html table and PHP: If $row['meterSize'] contains 3", $row['meterType'] contains COMPOUND and $row['workOrderType2'] contains ONSITE SURVEY AND TEST then $575 should go in <td><? echo $row['onsiteSurveyTestCost'];?> </td> Here's the code for those 3 conditional table rows: <tr style="border: none;"> <td style="border: none; text-align: left;">Meter Type:</td> <td style="border: none; text-align: right;"><? echo $row['meterType'];?> </td> </tr> <tr style="border: none;"> <td style="border: none; text-align: left;">Meter Size:</td> <td style="border: none; text-align: right;"><? echo $row['meterSize'];?> </td> </tr> <tr style="border: none;"> <td style="border: none; text-align: left;">Service Preformed:</td> <td style="border: none; text-align: right;"><? echo $row['workOrderType2'];?> </td> </tr> Is there a way to do this? I have multiple prices that are based on multiple conditions, but If I could figure out how to do this once then I can alter the values accordingly. Basically I want to mirror the db/SQL statement only with strictly PHP and the values in each table row. How can I do that, if possible?
  5. I have this query : select GROUP_CONCAT(Other_type)as projtype2,PrT_id from _Otherproject_typetbl,_project_typetbl where _Otherproject_typetbl.Other_id=_project_typetbl.Other_id and Project_id=in_projid; and it gives this result: +-----------+--------+ | projtype2 | PrT_id | +-----------+--------+ | All_other | HR_3 | +-----------+--------+ 1 row in set (0.04 sec) I would to set the value incase it is "Allother" to be set to empty or null in any of the columns +-----------+--------+ | projtype2 | PrT_id | +-----------+--------+ | null | HR_3 | +-----------+--------+ 1 row in set (0.04 sec)
  6. Hi all, I was hoping you could point me in the right direction, I have 2 questions. 1. I want to have an option drop down which uses the array of a returned sql query. I have the following code which uses onchange to submit the selection, how do I use the mysql_fetch_array($result1) to give a list of the two selected columns in the $Site=array() bit. 2. The selected result will be used in more SQL select statements, so once a site from the list is selected the relevant data from other tables will be displayed using e.g. select person from people [some inner join statement] where site="site 1"; Therefore the $_POST value must be available to be passed to other queries once selected. Thanks for any help, I still feel like a noob, but I'm getting there. Gary <?php include 'header.php'; ?> <div class='container'> <?php include 'menu.php'; ?> <?php include 'connect.php'; ?> <?php $sql1="SELECT Sites.Site_ID, Sites.Site_name_1 FROM `Sites`"; $result1=mysql_query($sql1); ?> <?php function get_options() { $site=array('Site 1'=>'Site 1', 'Site 2'=>'Site 2', 'Site 3'=>'Site 3'); $options=''; while(list($k,$v)=each($site)) { $options.='<option value="'.$v.'">'.$k.'</option>'; } return $options; } if(isset($_POST['site'])) { echo $_POST['site']; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <select name="site" onchange="this.form.submit();"> <?php echo get_options(); ?> </select>
  7. Hi all, I currently have a table listed, with one of the rows being hyperlinked and linking to an input form, should be autopopulated from the code (ID or other unique identifier) of the row, however, when clicking the link the form does not load. I will insert relevant code to this thread and if anyone would be able to shed some light on this that would be great. NOTE: SQL code has already been tested using PHPMyAdmin and works fine. Although, it may need changed to help with this issue - I'm not quite sure. Please see screenshots for relevant code.
  8. I have a form that is populated by a CSV file, always 229 fields but anywhere up to 10 or 12 rows. The form populates correctly, but I'm having issues saving it all. The loop seems like it's missing something or maybe something is mismatched. Here is the form code: **page-confirm.php** $connect = mysqli_connect($server, $user, $pw, $db); if ($connect->connect_error) { die("Connection failed: " . $conn->connect_error); }else{ //echo'success!'; } if(isset($_POST['preview'])) { ini_set('auto_detect_line_endings', true); $file = $_FILES["file"]["tmp_name"]; $handle = fopen($file, "r"); $maxPreviewRows = PHP_INT_MAX; // this will be ~2 billion on 32-bit system, or ~9 quintillion on 64-bit system $hasHeaderRow = true; echo "<form method='post' action='/form-submit' >"; echo '<table>'; if ($hasHeaderRow) { $headerRow = fgetcsv($handle); echo '<thead><tr>'; foreach($headerRow as $value) { echo "<th>$value</th>"; } echo '</tr></thead>'; } echo '<tbody>'; $rowCount = 0; while ($row = fgetcsv($handle)) { $colCount = 0; echo '<tr>'; foreach($row as $value) { echo "<td><input name='row[".$rowCount."][".$colCount."]' type='text' value='$value' /></td>"; $colCount++; } echo '</tr>'; if (++$rowCount > $maxPreviewRows) { break; } } echo '</tbody></table>'; echo "<input type='submit' name='confirm' value='confirm'>"; echo '</form>'; } ?> Here's the code for the submission page with the insert loop: **page-formsubmit.php** $connect = mysqli_connect($server, $user, $pw, $db); if ($connect->connect_error) { die("Connection failed: " . $connect->connect_error); }else{ echo'success!'; } //var_dump($_POST); $sql = $inserts = $binds = []; foreach ($_POST['row'] as $rowValue){ if(is_array($rowValue) && count($rowValue) > 0 ){ foreach($rowValue as $rowData){ /*** * Stupidly, I had missed that row contains arrays * rather than values, so you need a foreach, inside the * foreach as so: ***/ foreach ($rowData as $columnKey => $columnValue){ //$columnValue will now equal $value //$columnKey will be the column number (1...229) /*** * This is the area you can construct your SQL query values. * db_connection is assumed to be setup. ***/ $sql[] = "`column_name_".$columnKey."`"; $binder = "value".$columnKey; $inserts[] = ":".$binder; $binds[$binder] = $columnValue; unset($binder); } unset($columnKey,$columnValue); } unset($rowData); /*** * This is the area the SQL query is set on a per row basis ***/ $sqlFull = "INSERT INTO staging (".implode(",",$sql).") VALUES(".implode(",",$inserts).")"; $connect->prepare($sqlFull); /*** * EDIT: bind param MUST come after the prepare call ***/ foreach($binds as $bindKey=>$bindRow){ $connect->bind_param(":".$bindKey, $bindRow); } unset($bindKey,$bindRow); var_dump($binds); $sql = $inserts = $binds = []; //reset arrays for next row iteration. /*** * db_connection then executes the statement constructed above ***/ $connect->execute(); } //close if. } unset($rowValue); ?> You can see in the submission page where I comment out the var_dump for post data. When it's active, it prints out this for the array: success!array(1) { ["row"]=> array(5) { [0]=> array(229) and continues printing the 229 elements for all 7 rows. There is something that's not quite working in this loop because even a debug statement within the loop to print the query won't work. I just need to make sure it iterates all 229 fields of every row to the end of the form and puts them into my staging table. My staging table, which is temporary, has 229 named fields in the exact order as the CSV, so I shouldn't have to declare each field I don't believe.
  9. I have two functions, one loading data and the other loading the data into an html table. I've done this for 3 other data sets without issue but this one is not loading into the table for some reason. The html table loads but it's empty. I have error printing on but there are no errors. Also the query returns the correct results when I manually run it so I know it's getting results, plus it's printing the result resource ID. So my result prints, and my html table shows up, but the results are not in the table so I'm assuming maybe I'm not passing it to the table properly? Any guidance here is greatly appreciated //Function to gather data private function loadActivity($cust) { $this->dbConnect(); //loading set data values from top of function file $fromC = $this->cy_from; $fromP = $this->py_from; $thruC = $this->cy_thru; $thruP = $this->py_thru; $endYr = $this->py_endYr; $query = " select count(*), 'PRIOR' as Range from actvty where cust = {$cust} AND date between '{$fromP}' and '{$thruP}' union all select count(*), 'CURRENT' as Range from actvty where cust = {$cust} AND date between '{$fromC}' and '{$thruC}' union ALL select count(*), 'FULL' as Range from actvty where cust = {$cust} AND date between '{$fromP}' and '{$endYr}'"; $result = odbc_exec($this->ocon,$query); print_r($result); //This prints "Resource ID #76" $this->activitySum = array(); if ($result) { while ($row = odbc_fetch_array($result)) { $this->activitySum[$row['Range']]; $this->isloaded = true; } }else{ echo"query failed" . odbc_error(); } } public function getCallActivityHTMLcust($cust, $header='Activity'){ $this->loadActivity($cust); $h2 = "<table class='customer-table'>"; $h2 .= "<thead><tr><th colspan='2' style='font-weight: bold'></th>" . htmlspecialchars($header) . "</tr></thead>"; $h2 .= "<tbody>"; $h2 .= "<tr><td>{$this->pyyy} YTD</td><td style='text-align: right;'>" . $this->activitySum['PRIOR'] . "</td></tr>"; $h2 .= "<tr><td>{$this->yyyy} YTD</td><td style='text-align: right;'>" . $this->activitySum['CURRENT'] . "</td></tr>"; $h2 .= "<tr><td>{$this->pyyy} Full Year</td><td style='text-align: right;'>" . $this->activitySum['FULL'] . "</td></tr>"; $h2 .= "</tbody></table>"; return $h2; }
  10. Hi all. How can i send mail to multiple users at the same time with each user getting their own related data. I'm using php mailer as an engine to send the mail. Based on this, i'd have loved to setup a cron for it but i do not know how, so i figure i'd just do it manually before i get to know how to setup a cron job. It's just to send a reminder to users and each user has a different subscription expiry time. I want each user to get their respective expiration date, expiry day etc. Thanks if(isset($_POST['send_reminder'])){ $sql = "SELECT * FROM users WHERE status = '$status'"; $stmt = $pdo->query($sql); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $name = $row['name']; $acct_no = $row['acct_no']; $email_addresses = $row['email']; $expiry_date = $row['expiry_date']; $expiry_day = $row['expiry_day']; } $message="Hello $name,<br> <p> This is to remind you that your subscription will expire in $expiry_day. </p> <p> Details as follows: Name: $name<br> Account Number: $acct_no<br> Email: $email_addresses<br> Expire in days: $expiry_day<br> Expiry Date: $expiry_date </p> <p> Thank you </p> $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'mail.server.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'mails@services.cap'; // SMTP username $mail->Password = 'password'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to $mail->From = mails@services.cap'; $mail->FromName = 'Club 404'; $mail->addAddress($email_addresses); // Add a recipient $mail->WordWrap = 587; // Set word wrap to 50 characters $mail->AddEmbeddedImage("../img/logo.png", "my_logo"); $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'REMINDER ON CLUB EXPIRY DATE'; $mail->Body = $mess; $mail->send(); }
  11. iam trying to insert a summary into a table.Is it possible to write a case condition inside an insert statement like so: insert into match_summ(MatchID ,match_venueID,stadium_LocationID,SeasonID,CompetitionID,Team_catId)values('5','6','7','8','9', CASE WHEN homeid = l_team_id THEN teamcat_id=1 END , CASE WHEN l_team_id = awayid THEN teamcat_id=2 ELSE teamcat_id= 0 END ); Is what iam trying to do possible??What is the best way to do it???
  12. i was working on a mini project that imports csv file to the database through ajax and it's working fine <?php if(!empty($_FILES["marks_file"]["name"])) { $connect = mysqli_connect("localhost", "root", "", "dbname"); $output = ''; $allowed_ext = array("csv"); $extension = end(explode(".", $_FILES["marks_file"]["name"])); if(in_array($extension, $allowed_ext)) { $file_data = fopen($_FILES["marks_file"]["tmp_name"], 'r'); fgetcsv($file_data); while($row = fgetcsv($file_data)) { $name = mysqli_real_escape_string($connect, $row[0]); $Physics = mysqli_real_escape_string($connect, $row[1]); $Maths = mysqli_real_escape_string($connect, $row[2]); $Chemistry = mysqli_real_escape_string($connect, $row[3]); $Biology = mysqli_real_escape_string($connect, $row[4]); $SST = mysqli_real_escape_string($connect, $row[5]); $query = " INSERT INTO csv (name, Physics, Maths, Chemistry, Biology, SST) VALUES ('$name', '$Physics', '$Maths', '$Chemistry', '$Biology' , '$SST') "; mysqli_query($connect, $query); } $select = "SELECT * FROM csv ORDER BY id DESC"; $result = mysqli_query($connect, $select); $output .= ' <table class="table table-bordered"> <tr> <th width="25%" >name</th> <th width="15%" >Physics</th> <th width="15%" >Maths</th> <th width="15%" >Chemistry</th> <th width="15%" >Biology</th> <th width="15%" >SST</th> </tr> '; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td>'.$row["name"].'</td> <td>'.$row["Physics"].'</td> <td>'.$row["Maths"].'</td> <td>'.$row["Chemistry"].'</td> <td>'.$row["Biology"].'</td> <td>'.$row["SST"].'</td> </tr> '; } $output .= '</table>'; echo $output; } else { echo 'errorx'; } } else { echo "errory"; } ?> however the imported csv files inserts null values in the tables because the format of all csv files assigned to me are in the exact same format: ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,,,,,, ,,,Fields,Physics~75,Maths~50,Chemistry~65,Bio~85,SST~100 ,,,Name1,10,25,35,42,62 ,,,Name2,80,45,45,45,25 ,,,Name3,63,25,63,36,36 ,,,Name4,82,36,75,48,42 ,,,Name5,45,45,78,25,24 ,,,Name6,36,36,15,75,36 ,,,Name7,99,45,24,24,45 ,,,Name8,45,85,85,85,96 i changed my code a bit modified the functions to espace blank spaces and not return null values in the data tables while (($row = fgetcsv($file_data, 1000, ",")) !== FALSE) { if ((string) $row[0] != '0' and empty($row[0])) { continue; } $name = mysqli_real_escape_string($connect, $row[0]); $Physics = mysqli_real_escape_string($connect, $row[1]); $Maths = mysqli_real_escape_string($connect, $row[2]); $Chemistry = mysqli_real_escape_string($connect, $row[3]); $Biology = mysqli_real_escape_string($connect, $row[4]); $SST = mysqli_real_escape_string($connect, $row[5]); $query = " INSERT INTO csv (name, Physics, Maths, Chemistry, Biology, SST) VALUES ('$name', '$Physics', '$Maths', '$Chemistry', '$Biology' , '$SST') "; mysqli_query($connect, $query); } But it doesn't work with the specified csv files i think the ajax call breaks and that's why nothing happens.However it works fine with csv files without blank spaces
  13. I have a page that displays about 12 tables that are filled from database values. These values correspond with a single record but some of these fields are based off of queries I'm making so that if something's wrong in the query, it will display red text. I'm only doing this for a few different fields but I want an option to edit and fix those fields and then save them to the database with an UPDATE. Basically, I don't want to wrap the whole page in a form since only a few fields in a few of the tables will need to be editable. Is there a way to do this so that I can edit only the few fields that need to be fixed? Here's a table as example: <div class="testResults" style=" width: 30%; clear:both; float: left;"> <!--Test Results Table--> <table style="width: 100%;"> <tr> <th colspan="2">Test Results</th> </tr> <tr> <td style="text-align: left;">Tested Within AWWA Standards</td> <td><? echo $row['standards'];?> </td> </tr> <tr> <td style="text-align: left;">Meter Failed on Low Side</td> <td><? echo $row['lowFail'];?> </td> </tr> <tr> <td style="text-align: left;">Meter Failed on High Side</td> <td><? echo $row['highFail'];?> </td> </tr> <tr> <td style="text-align: left;">Meter Failed Low and High Side</td> <td><? echo $row['bothFail'];?> </td> </tr> <tr> <td style="text-align: left;">Unable To Test</td> <td><? echo $row['unableTest'];?> </td> </tr> </table> So, for example, say I want to edit the data for just standards row and lowFail row. I tried this but it didn't work: <td><input type="text" name="test8TRGPM" value="<? echo $row['test8TestRateGPM'];?>"> </td> I know once this is done I'll need to have a submit button that attaches to a query to update with the input name, but right NOw i'm trying to find the best way to edit. Is it easiest to just wrap the whole page in a form and just create the few inputs where I need?
  14. Hi look for some help with querying based on todays date. I'm trying to count all the entries in the database based on username, status, date. The date bit is where I' stuck (see screen shot of database) Based on data in database I should get a count of 3 but get nothing?? The result I get is 0 and should be 3 based on date Any help would be a great help Cheers Chris //date bit $d=strtotime("today"); $wholedate2 = date("Y-m-d", $d); //query $query_rsUser = "SELECT COUNT(*) FROM quotes WHERE quotes.quote_user = 'username' AND quotes.quote_complete = '$date2' AND quotes.quote_status = 'Complete'";
  15. I want to display 10 products from each category from database, I started to display the categories but how to make displaying the products from each one. Here is the code I make so far. I'm not sure am I doing it right with doble sql select , or it can be done only with one. <div class="inner shadow"> <?php $query = 'SELECT id, title_bg AS `title_cat` FROM categories'; $result = $this->db->query($query); ?> <?php foreach ($result->result() as $row): ?> <?php $title_cat = stripslashes($row->title_cat); ?> <div class="prod-sec"> <div class="prod-head"> <h2><?= $title_cat?></h2> <div class="clear"></div> </div> <?php $query1 = 'SELECT t1.id, t1.title_bg AS `Title`, t1.text_bg AS `Text`, t1.price, t1.discount, t1.category_id, t1.promo_page, t2.id AS FileID, t2.ext, FROM products t1 LEFT JOIN products_pictures t2 ON t1.id = t2.object_id LEFT JOIN categories t3 ON t3.id = t1.category_id WHERE t1.promo_page = 0 AND t1.is_active = 1 AND t3.title_bg = '$title_cat' ORDER BY RAND() LIMIT 10'; $result1 = $this->db->query($query1); ?> <div id="classeslist2"> <ul class="home_middle_products"> <?PHP foreach($result1->result() as $row1) { $f = 'files/products_first_page/' . $row1->id . '.jpg'; if(is_file(dirname(__FILE__) . '/../../' . $f)) { $img = site_url() . "files/products_first_page/".$row1->id.".jpg"; } else { $img = site_url() . "files/products/".$row1->id."/".$row1->FileID."_2.".$row1->ext; } $title = stripslashes($row1->Title); $text = character_limiter(strip_tags(stripslashes($row1->Text)),250); $title_url = getLinkTitle($title); $link = site_url()."products/product/".$row1->id."/{$title_url}"; ?> <li style="width: 185px; height: 270px; margin-left: 3px; margin-top: 10px;"> <div class="thumb"> <a href="<?=$link?>"><img src="<?=$img?>" alt="<?=$title?>" width="182" /></a> <div class="price"><?PHP echo product_price($row1, array('show_discount' => false,"show_old_price"=>false, 'show_label' => false, 'view' => 'no')); ?> </div> </div> <h2></h2> <h2><a href="<?=$link?>"><?=$title?></a></h2> <? $text = substr($text, 0, 100); ?> <? if (strlen($text) == 100) $text .= '...' ; ?> <p><?=$text?></p> </li> <?php } ?> <div class="clear"></div> </ul> </div> </div> <?php endforeach; ?> <div class="clear"></div> </div>
  16. Hi guys so for my website I want to add a feature where a user can upload a zipped folder and send that folder to another user through my Private message system, so I am wondering how this would work, would I need to upload the folder to my database, upload it to a separate folder and use some php code to display a download link to download it?
  17. Hi again, Hopefully the last question as I am not 100% how to solve this one. So on my website someone carried out a search from a search bar using the 'POST' method , teh search results show all whiskies in the databse. I have a number of whiskies with the same name but with different dates and prices. I would like it just to show one of each type that was searched for rather than all of them. I have attahced a clip of the databse. Thanks Index.php </head> <?php $page='index'; include('header.php'); include('navbar.php'); ?> <script type="text/javascript"> function active(){ var search_bar= document.getElementById('search_bar'); if(search_bar.value == 'Search for your whisky here'){ search_bar.value='' search_bar.placeholder= 'Search for your whisky here' } } function inactive(){ var search_bar= document.getElementById('search_bar'); if(search_bar.value == ''){ search_bar.value='Search for your whisky here' search_bar.placeholder= '' } } </script> <body> <div class="third_bar"> <div class="background_image"> </div> <div class="form"><form action= "search.php" method="post"> <input type="text" name="search" id="search_bar" placeholder="" value="Search for your whisky here" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/> </form> </div> </div> </body> </div> <?php include ('footer.php'); ?> Search.php <?php $page='search'; include('header.php'); include ('navbar.php'); echo "<br>"; include ('connect.php'); if (isset ($_POST['search'])) { //the 'search' refers to the 'search' name=search on the index page and makes does something when the search is pushed. $search = $_POST['search']; $search = "%" . $search . "%"; // MySQL wildcard % either side of search to get partially matching results // No wildcard if you want results to match fully } else { header ('location: index.php'); } $stmt = $conn->prepare("SELECT * FROM test_db WHERE name LIKE :name ORDER BY name ASC"); // Use = instead of LIKE for full matching $stmt->bindParam(':name', $search); $stmt->execute(); $count = $stmt->rowCount(); // Added to count no. of results returned if ($count >= 1) { // Only displays results if $count is 1 or more echo "<div class='results_found'>"; echo $count; echo " results found<br>"; echo "</div>"; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "<div class='results'>"; echo "<div class='result_name'>"; echo "<b>Whisky Name:</b><br>"; echo "<a href='details1.php?id={$row['lot_id']}' >{$row['name']}</a>"; echo"<br>"; echo "</div>"; echo "</div>"; } } else { echo " Sorry no records were found"; } ?> </htm
  18. I have a php script that I've been running that seems to have been working but now I'm wondering if some of my logic is potentially off. I select records from a db table within a date range which I put into an array called ```$validCount``` If that array is not empty, that means I have valid records to update with my values, and if it's empty I just insert. The trick with the insert is that if the ```STORES``` is less than the ```Quantity``` then it only inserts as many as the ```STORES``` otherwise it inserts as many as ```Quantity```. So if a record being inserted with had Stores: 14 Quantity:12 Then it would only insert 12 records but if it had Stores:1 Quantity:20 It would only insert 1 record. In short, for each customer I should only ever have as many valid records (within a valid date range) as they have stores. If they have 20 stores, I can have 1 or 2 records but should never have 30. It seems like updating works fine but I'm not sure if it's updating the proper records, though it seems like in some instances it's just inserting too many and not accounting for past updated records. This is the logic I have been working with: if(!empty($validCount)){ for($i=0; $i<$row2['QUANTITY']; $i++){ try{ $updateRslt = $update->execute($updateParams); }catch(PDOException $ex){ $out[] = $failedUpdate; } } }else{ if($row2["QUANTITY"] >= $row2["STORES"]){ for($i=0; $i<$row2["STORES"]; $i++){ try{ $insertRslt = $insert->execute($insertParams); }catch(PDOException $ex){ $out[] = $failedInsertStore; } } }elseif($row2["QUANTITY"] < $row2["STORES"]){ for($i=0; $i<$row2["QUANTITY"]; $i++){ try{ $insertRslt = $insert->execute($insertParams); }catch(PDOException $ex){ $out[] = $failedInsertQuantity; } } } } Let's say customer 123 bought 4 of product A and they have 10 locations customerNumber | product | category | startDate | expireDate | stores ---------------------------------------------------------------------------------- 123 1 A 2018-08-01 2019-03-01 10 123 1 A 2018-08-01 2019-03-01 10 123 1 A 2018-08-01 2019-03-01 10 123 1 A 2018-08-01 2019-03-01 10 Because they purchased less than their store count, I insert 4 records. Now if my ```$validCheck``` query selects all 4 of those records (since they fall in a valid date range) and my loop sees that the array isn't empty, it knows it needs to update those or insert. Let's say they bought 15 this time. Then I would need to insert 6 records, and then update the expiration date of the other 9 records. customerNumber | product | category | startDate | expireDate | stores ---------------------------------------------------------------------------------- 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 123 1 A 2018-08-01 2019-03-11 10 There can only ever be a maximum of 10 (store count) records for that customer and product within the valid date range. As soon as the row count for that customer/product reaches the equivalent of stores, it needs to now go through and update equal to the quantity so now I'm running this but it's not running and no errors, but it just returns back to the command line $total = $row2['QUANTITY'] + $validCheck; if ($total < $row2['STORES']) { $insert_count = $row2['QUANTITY']; $update_count = 0; } else { $insert_count = $row2['STORES'] - $validCheck; // insert enough to fill all stores $update_count = ($total - $insert_count); // update remainder } for($i=0; $i<$row2['QUANTITY']; $i++){ try{ $updateRslt = $update->execute($updateParams); }catch(PDOException $ex){ $failedUpdate = "UPDATE_FAILED"; print_r($failedUpdate); $out[] = $failedUpdate; } } for($i=0; $i<$insert_count; $i++){ try{ $insertRslt = $insert->execute($insertParams); }catch(PDOException $ex){ $failedInsertStore = "INSERT_STORE_FAILED!!!: " . $ex->getMessage(); print_r($failedInsertStore); $out[] = $failedInsertStore; } }```
  19. I have a login session where it checks the user name and displays it to the form (it displays FirstName LastName). That username is also being used as a variable to pull up data in db. Now I also have another page where user's can update the db, I dont have a problem if the user will update it with a complete FirstName LastName entry because it will just be the same as the one's being used by the login session, but sometimes they just update it with FirstName. The problem starts when I have values in TEST db under Tester column and in USERS db under User column that is of different values. It would have two diff values when a user did not enter the full FirstName LastName. For example, FirstName1 LastName1 is the value in USERS db User column - this is fixed and is being used in a login session User updated Tester column in TEST db with just FirstName1 - this is different from the User column above Here is what I am trying to do, Getting list of tickets from the TEST db where datefrom and dateto and using a variable for the values that is in User column under USER DB If User column under USERS db = Tester column under Test db which is FirstName1 LastName1 - it will be good as I will be able to get tickets under FirstName1 LastName1. But I will not be able to get ticket which is still assigned to that same person because the value in Tester column under Test db is just FirstName1. If User column under USERS db (FirstName1 LastName1) is not equal to Tester column under Test db which is just FirstName1 - I will not get tickets assigned to FirstName1 as my variable is equal to FirstName1 LastName1. I hope that I explained it clearly, here is my code, Here is the variable that I am posting, $uid = false; if(isset($_POST['uid'])){ $uid = $_POST['uid']; } And here is the query, $sql = 'SELECT `id`, `date_implemented`, `tester`, `comments` FROM `tracker` WHERE `tester` = :uid AND `scheduled_start_date` BETWEEN :d1 AND :d2'; $stmt = $conn->prepare($sql); $stmt->bindParam(':uid', $uid, PDO::PARAM_STR); $stmt->bindParam(':d1', $date['from'], PDO::PARAM_STR); $stmt->bindParam(':d2', $date['to'], PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); I would need help in passing that variable (uid) such that I can use `WHERE tester LIKE uid`. In that case whether the tester column just contains FIRSTNAME1 or a complete FIRSTNAME1 LASTNAME1, I would be able to get all tickets assigned to FIRSTNAME1.
  20. Hi, Here is my SQL, its build with a loop, and looks correct to what I think it should be. I believe the output "$data" below should only be 4 records.. though its a lot more, and some data is duplicated and shown twice in the array. Lot of stuff removed for simplicity. SELECT usr.usr_login, app.app_name, acs.acs_read, acs.acs_add, acs.acs_edit, acs.acs_delete, acs.acs_admin FROM acs LEFT JOIN usr ON usr.ID = usr.ID LEFT JOIN app ON app.ID = app.ID if it matters here's the code that generated the statement above from an array. <?php // ===================================================================================================== // preperation // ===================================================================================================== foreach($fldarray as $fld){ // get readable names and stick em into an array $nm[] = $fld['human']; // Field name, and joins (if the join is using the option table) if($fld['opt'] == 1 and ($fld['opt_table'] == "" or $fld['opt_field'] == "")){ $jn[] = array('table' => "opt", 'field' => "opt_value"); $fd[] = "opt.opt_value"; // Field name, and joins (if the join is using a table other than options) }elseif($fld['opt'] == 1 and ($fld['opt_table'] <> "" and $fld['opt_field'] <> "")){ $jn[] = array('table' => $fld['opt_table'], 'field' => $fld['opt_field']); $fd[] = $fld['opt_table'].".".$fld['opt_field']; // a field directly written no foreign keys.. }else{ $fd[] = $ap.".".$fld['fieldname']; } $sa[] = array('human' => $fld['human'], 'field' => $fld['fieldname'], 'opt_table' => $fld['opt_table'], 'opt_field' => $fld['opt_field']); } // ===================================================================================================== // Start building the SQL // ===================================================================================================== $sql = "SELECT ".implode(", ", $fd)." FROM ".$ap; // ===================================================================================================== // Add the joins if any.. // ===================================================================================================== if (isset($jn)){ foreach($jn as $j){ $sql .= " LEFT JOIN ".$j['table']." ON ".$j['table'].".ID = ".$j['table'].".ID"; } } // ===================================================================================================== $stmt = $db->query($sql); $data = $stmt->fetchAll(); echo $sql; echo "<pre>"; print_r($data); echo "</pre>"; // ===================================================================================================== ?> Tables acs ID | acs_usr | acs_app | acs_read | acs_add | acs_edit | acs_delete | acs_admin ======================================================================================== 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 app ID | app_name ============= 1 | Applications 2 | Users usr ID | login ============= 1 | joe 2 | fred 3 | carlie 4 | lisa outputs this array.. Array ( [0] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [1] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [2] => Array ( [usr_login] => fred [0] => fred [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [3] => Array ( [usr_login] => fred [0] => fred [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [4] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [5] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [6] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [7] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Applications [1] => Applications [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [8] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [9] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [10] => Array ( [usr_login] => fred [0] => fred [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [11] => Array ( [usr_login] => fred [0] => fred [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [12] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [13] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [14] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [15] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Users [1] => Users [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [16] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [17] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [18] => Array ( [usr_login] => fred [0] => fred [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [19] => Array ( [usr_login] => fred [0] => fred [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [20] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [21] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [22] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [23] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Permissions [1] => Permissions [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [24] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [25] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [26] => Array ( [usr_login] => fred [0] => fred [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [27] => Array ( [usr_login] => fred [0] => fred [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [28] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [29] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [30] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [31] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Benchmark [1] => Benchmark [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [32] => Array ( [usr_login] => Joe [0] => Joe [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [33] => Array ( [usr_login] => Joe [0] => Joe [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [34] => Array ( [usr_login] => fred [0] => fred [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [35] => Array ( [usr_login] => fred [0] => fred [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [36] => Array ( [usr_login] => carlie [0] => carlie [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [37] => Array ( [usr_login] => carlie [0] => carlie [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [38] => Array ( [usr_login] => lisa [0] => lisa [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [39] => Array ( [usr_login] => lisa [0] => lisa [app_name] => News [1] => News [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [40] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [41] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [42] => Array ( [usr_login] => fred [0] => fred [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [43] => Array ( [usr_login] => fred [0] => fred [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [44] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [45] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [46] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [47] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Passwords [1] => Passwords [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [48] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [49] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [50] => Array ( [usr_login] => fred [0] => fred [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [51] => Array ( [usr_login] => fred [0] => fred [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [52] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [53] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [54] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [55] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Fields [1] => Fields [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [56] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [57] => Array ( [usr_login] => Joe [0] => Joe [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [58] => Array ( [usr_login] => fred [0] => fred [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [59] => Array ( [usr_login] => fred [0] => fred [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [60] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [61] => Array ( [usr_login] => carlie [0] => carlie [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) [62] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 1 [3] => 1 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 1 [6] => 1 ) [63] => Array ( [usr_login] => lisa [0] => lisa [app_name] => Settings [1] => Settings [acs_read] => 1 [2] => 1 [acs_add] => 0 [3] => 0 [acs_edit] => 1 [4] => 1 [acs_delete] => 1 [5] => 1 [acs_admin] => 0 [6] => 0 ) )
  21. Im struggling with how to filter items that have multiple categorises say if i wanted to search for a shoe that is good for walking and hiking in my database? Shoe_id Shoe name color_id type_id colors color_id color type type_id type My problem is what do i do in a situations like this? say a shoe is good for walking and running? aka type 1 and 2 shoe id 1 shoe name nike color id 1 type id 1 and 2
  22. I have an html table with some numerical values in each data row. There are 8 columns representing 8 tests. At the bottom of each column is a corrected accuracy cell which represents a math formula from the three rows above it. Basically, it divides the meter volume by the tester volume, multiplies that result by the tester accuracy, and divides that result by 100. I have attempted something with the following code: <table style="width:100%; border:none; border-collapse:collapse;"> <? php $test1FormA = $row['test1MeterVol'] / $row['test1TesterVol']; $test1FormB = $test1FormA * $row['test1Accuracy']; $test1FinalForm = $test1FormB / 100; ?> <tr> <td style="border:none; text-align: left;">Meter Volume: </td> <td><? echo $row['test1MeterVol'];?> </td> </tr> <tr> <td style="border:none; text-align: left;">Tester Volume: </td> <td><? echo $row['test1TesterVol'];?> </td> </tr> <tr> <td style="border:none; text-align: left;">Tester Accuracy: </td> <td><? echo $row['test1Accuracy'];?> </td> </tr> <tr> <td style="border:none; text-align: left;">Corrected Accuracy: </td> <td><? echo $test1FinalForm;?> </td> </tr> </table> However, my page no longer loads with this so I'm assuming I'm doing something wrong with my variables in the top, maybe with syntax. I just need it to take the values for those three data rows and use them in the formulas so that I can put the final result in the corrected accuracy field.
  23. If i check more than one checkbox. I dont get any value from database. HTML <form method="post"> <input type="checkbox" name="receiver[]" value="cheater">CHEATER <input type="checkbox" name="receiver[]" value="un-verified">UN-VERIFIED <input type="checkbox" name="receiver[]" value="inactive">INACTIVE <input type="checkbox" name="receiver[]" value="active">ACTIVE <input type="submit" name="submit" value="ADD"> </form> PHP $errors = array(); $success = NULL; $error = NULL; $var['receiver'] = isset($_POST['receiver']) ? $_POST['receiver'] : NULL; ................. if(!empty($_POST['submit'])){ // FORM VALIDATION // } if(!empty($_POST['submit']) and empty($errors)){ $status = array_map('strval', $var['receiver']) + array(0); $statusSql = implode(',', $status); $query = 'SELECT email FROM users WHERE status IN("'.$statusSql.'")'; $select = $db->prepare($query); $select->execute(); $arrayData = array(); while($row = $select->fetch(PDO::FETCH_ASSOC)){ $arrayData[] = $row['email']; } $errors[] = implode(',', $arrayData); } require_once 'includes/antiCsrf/index.php'; $csrf = new antiCsrf(); $smarty->assign('success', $success); $smarty->assign('error', $error); $smarty->assign('errors', $errors); $smarty->assign('csrfKey', $csrf->csrfKey()); $smarty->assign('csrfToken', $csrf->csrfToken()); $smarty->assign('var', $var); .................
  24. Is this allowed in mysql transactions;Can i insert conditionally into different tables by different users to insert data : i have tried this inside a stored procedure,but can someone correct me if it is good approach: START TRANSACTION; INSERT INTO minderstbl(m_date,m_notes )VALUES(in_date,in_remindernotes); SELECT Rm_id INTO l_rem_id FROM minderstbl where m_date=in_date and m_notes=in_remindernotes limit 1; IF in_status = 1 THEN INSERT INTO i_ndertbl(id,Doc_id,frq_no,eq_text )VALUES(l_rem_id,in_doctitleid,in_freq_no,in_freq_text); ELSEIF in_status = 2 THEN INSERT INTO nderstbl(ct_id,em_id,eq_no,q_text )VALUES(in_compid,l_rem_id ,in_freq_no,in_freq_text); ELSEIF in_status = 3 THEN INSERT INTO rstbl(m_id,q_no,q_text )VALUES(l_rem_id ,in_freq_no,in_freq_text); END IF; if l_rem_id !='' then SELECT l_rem_id ; end if; COMMIT;
  25. update super set `name` = REPLACE(`name`, ',' , ' ') I have the following code that removes the comma in a MySQL database column & replaces it with a blank. In the above example, the database is named super & the column is named name. This code works great but currently I'm running the script each day & changing it to also remove periods, question marks, etc. Is there a way I can edit the above code that will not only find & replace the , with a blank space, but edit it so it will find the periods, commas, question mark, exclamation mark, etc all in one run? Please help as I am currently editing the above code to numerous other things to find & replace daily. Thank
×
×
  • 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.