Jump to content

Search the Community

Showing results for tags 'php'.

  • 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 (PhpStorm, VS Code, 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

  1. Hello to everybody. I built a House Booking System site with this theme that i bought. BYT. They don't do custom coding. http://themeforest.net/item/book-your-travel-online-booking-wordpress-theme/5632266 We need to modify the PHP to add some capabilities. 1-The BYT search engine for now only filters some of the input fields (Accomodation details) like Where (location), When (dates in and out), and some other we don't need. We need to filter by number of people too. That is; Where, When, How many people. 2- Add a booking button in some sidebar. The booking is performed from the House page but i would like to copy the code to another php file (sidebar) Easy if u know how to do it. 3- Synch the BYT reservations with iCal or Google calendar. But BYT doesn't support APIs.... so i imagine is not possible. And sure expensive. But there is a big need for that apart from myself. I'm sure tha anyone that does it will become fameous.... I'm ready to pay for it. stayinahouse.com
  2. Hi! I have created a script (more like a system) that uses expect. The idea is actually simple: you press a button, PHP opens an expect stream to a telnet, expect_expectl waits for specific output, PHP reads output, based on output PHP sends more data. (Im refering to this PHP module - http://php.net/manual/en/book.expect.php ) I have ran into multiple problems, one of them is that the expect extention seems to be really unstable, it crashes apache and can't really figure out why. Another problem is that sometimes it likes to simply skip an output for no reason and gets stuck in a while loop. Obviously this is happening randomly and I can't find the cause of it (its not the client's fault, the client processes command as it should). Even worse, I can't seem to compile the exepect module on any x64 machine, it seems that the code is not meant to be for 64-bit machine. I have tried a lot of things and basically I'm tired of this module (even gentoo seems to have removed it since PHP 5.3) and I don't think there is anything that can make the expect module work properly on current PHP versions. So my question is: can anyone give an alternative way to deal with these shell interactions? I'm looking at Python's "pexpect", I don't like that its bit tricky to read output from a Python script inside PHP and I don't like that I must use popen. Also found that TCL also has "exepect" which is very similar to Python's "pexepect" and also Perl has it too, haven't really dealt with either of those languages, but it is not anything "out of this world". The best way I can think of is using cgi-bin scripts, I send a request with parameters (IP, command etc.) to a Python/TCL/Perl script which then gives an output. And I can do this in 2 ways, either open a stream and fetch the output (like with popen, still don't like it) or with ajax (since the current page is based on ajax, not a big problem). Whats wrong with SSH? Its slow because of the encryption, telnet is able to proccess commands a lot faster (and on slower devices SSH creates a notable lag). Anyone has any advice?
  3. I want to see your opinion about OOP and Procedural. Which method has more easier to code in PHP? I'm using Procedural, but I notice PHP can read OOP as C++. Which is better for PHP? Thanks, Gary
  4. I am only new to php (getting there) but have a wordpress site that is using freshizer images resizing. All of the images are being cached as 100% black images instead of their original colours. Has anyone had this before?
  5. $subtotal = $row[0]; $delivery = $row[1]; $discount = $row[2]; $vatrate = $row[3]; $totalex = str_replace(",","",$subtotal) + str_replace(",","",$delivery); $vatamount = ($totalex - $discount) * ($vatrate/100); $vatamount = number_format($vatamount, 2, '.', ','); $total = $row[4]; $centinel_total = $total * 100; $centinel_delivery = $delivery * 100; $centinel_vatamount = $vatamount * 100; I've got a custom written cart system which for some reason is not passing the correct amounts to our 3D secure processor (Cardinel commerce). I'm not a programmer but looking at how it seems to work I think the issue is with this code. From the processor logs we are passing the tax value with a negative amount and the total is always £1 when the total is above £1000. It all works fine as it should if the total amount is LESS than £1000! Anyone got any ideas what's going on? I'm more than happy to pay someone to fix this!!
  6. I am trying to remove folders and its files and sub folders using php. This is how I tried it. $dir = "../../images/$category_id/$delId"; $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); foreach($files as $file) { if ($file->isDir()){ rmdir($file->getRealPath()); } else { unlink($file->getRealPath()); } } rmdir($dir); This is working on php 5.5+, but is doesn't work in php 5.2.17. This is the error can I get when it running on php 5.2.17 Can anybody tell me how I get it to work on 5.2 also. Thank you.
  7. Hi Im trying to put a link on to upload an image.. I have the code and its working fine.. BUT.. i want to change it slightly so the image file is changed so it does not give the error "Sorry, file already exists." i manage to remove this but then it just over writes the existing image... Can some one help with a simple piece of code that will change the image file name on upload even if its just a number after the file name will suffice... Here is my current code: thanks in advance! Stu <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 10000000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if ( move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "upload/".$username.".".$extension)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?>
  8. Hello, I've just started to use 2.1.0.2 and I'm trying to convert over some of my own extensions I built for my 1.5.6.4 store. I have started with a fresh install of 2.1.0.2 and I built a very basic extension, I'm wanting to move over to the extension installer to install my future additions to my store instead of using vqmod. I have made my testerextension.ocmod.zip, inside this is: install.xml /upload/ /admin/ /catalog/ However when I use the installer to upload testerextension.ocmod.zip I'm getting the following error: Directory containing files to be uploaded could not be found I have tracked this down to the ftp() class as I can see this error can be trigged in another class. I've also looked into the storage temp folder to find a folder unzipped called: testerextension.ocmod NOT upload. To rule out if there was an issue with OC system I have uploaded another extension from the extension store with the similar directory structure and similar ocmod.zip name only for it to correctly install. Therefore i'm unsure as to why this would be happening, I understand the system is looking for the upload folder in the temp folder but it's not there as it's one level deeper in the testerextension.ocmod - but as you can see from the directory structure above this shouldn't be happening. Does anyone have any idea where I could be going wrong?
  9. Hi everyone I am building a CRM system/invoicing system in my spare time and on this system I have 2 login pages (there is a reason but its long). one for the CRM system and one for the invoicing section. They bother work perfectly well but I have a really annoying issue, If I were to store the login information to chrome passwords for example to the CRM system It would auto suggest to the other login and vice versa. This wouldn't be a problem but the CRM login is username based, the invoicing section is login by email for additional security. they're both called login.php the two files are /htdocs/login.php and /htdocs/invoicing/login.php I added a remember me cookie to the CRM system in hope that this would get around the issue but unfortunately the chrome saved information over rides this, I also tried autocomplete="off" as I am using bootstrap as a framework. How can I get around this?
  10. Hello Mate, I would like to seek help... i have this json script which gets the names of the users from my database: $sql=mysql_query("SELECT firstname FROM tblusers WHERE usertype=1"); $u = array(); while($rs=mysql_fetch_array($sql)){ $u[] = $rs['firstname']; } print json_encode($u); And getting this to javascript function through ajax: function uList(){ $.ajax({ type: "POST", url: "techs.php", success: function(data) { console.log(data); return data; } }); } my console.log shows the correct format i want to get, but it doesn't display on my calendar page.... ["user1","user2","user3","user4","user5"]... im using this code to send data to my calendar script. users:uList, Any help is very much appreciated. Thank you
  11. Why at the beginning keeps saying undefined index with a session variable Hello. I want to calculate the average age of the people that submit the form. So I got 2 counters (I apologize for my english). One that stores the addition of the age and the other one that stores the number of people that submit the form. Then I need to calculate the average.Everytime I load the page for the first time it says "undefined index conted" and "undefined index contper". But it does what I want: it shows the correct addition of the age and the counting of the people that submit the form. The error appears only when I load the page the first time. Then everything goes well. Also I wanted to know how to delete those values stored in the session variables with a button, so when I hit the button displays the average and stops counting. (I apologize for my english) Thanks. This is my code: <?php session_start(); if(isset($_POST['btn1'])) { $_SESSION['conted'] = $_SESSION['conted'] + $_REQUEST['ed']; $_SESSION['contper'] = $_SESSION['contper'] + 1; echo "El contador de edad va en " . $_SESSION['conted']; echo '<br>'; echo "El contador de personas va en " . $_SESSION['contper']; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" > <title>Encuesta</title> </head> <body> <form action="encuesta.php" method="post"> <table> <tr> <td>Nombre</td><td><input type="text" placeholder="Nombre" name="nom"></td> </tr> <tr> <td>Apellido</td><td><input type="text" placeholder="Apellido" name="ape"></td> </tr> <tr> <td>Edad</td><td><input type="text" placeholder="Edad" name="ed"></td> </tr> <tr> <td>Dirección</td><td><input type="text" placeholder="Dirección" name="dir"></td> </tr> <tr> <td>Barrio</td><td><input type="text" placeholder="Barrio" name="bar"></td> </tr> <tr> <td>Teléfono</td><td><input type="text" placeholder="Teléfono" name="tel"></td> </tr> <tr> <td colspan = 2 align="center"><input type="submit" value="Procesar" name="btn1"></td> </tr> <tr> <td colspan = 2 align="center"><input type="submit" value="Terminar" name="btn2"></td> </tr> </table> </form> </body> </html>
  12. Hi everyone, It's been awhile since I was here in autumn time. How are everyone here? I'm good. I want to know, which best and cheaper host to create website with PHP? include Phpmyadmin or SQLBuddy. Please let me know... Thanks, Gary
  13. Hello everyone, I'm going to create my school project and I really need your advice. My Project Summary I need to create a new website where the user can add new schools in my site. After creating, they can add students, add teachers, add principal and hell lot of things from their admin panel. And in the frontend they will get their own urls and can display their schools. Ex1: example.com/st_sebastians/ <------- School name. Ex2: example.com/st_augustin/ <------- School name. When the user will visit those url they will see all the contents of their respective schools. My Questions How can I create those database. For that I've thought of two methods. 1) I will create multiple database for every user/school dynamically using php and saves the record in it. (I searched on google that it is very prone to mysql injection.) 2) I will create a single database with everything related to their (school id) and stores in the single database. Example Student table id | school_id | name | roll | ---------------------------------------------- 1 | 1 | Subho | 123456 ---------------------------------------------- 2 | 5 | xyz | 236566 ---------------------------------------------- 3 | 45 | asfgf | 778219 . . . . . . . . Please note that the database are going to store whole lot of records and I don't want to it slow down. Any Help will be highly appreciated. Thank You In advance...
  14. Hello I'm trying to check if 2 values exist in the database using php, Google didn't help... I need something like this : if($stmt = mysqli_prepare($db_connect,'QUERY TO CHECK IF USERNAME AND EMAIL EXIST')){ mysqli_stmt_bind_param($stmt, "ss", $user,$email); mysqli_stmt_execute($stmt); /* if username exist echo username exist if email exist echo email exist */ } else{/*error*/} thanks !
  15. Hi all, I am trying to make a list of users where two rows in a mysql database exist. My attempt so far: "SELECT * FROM mail_list INNER JOIN rosters ON mail_list.Code = rosters.Code WHERE rosters.SectorDate = '2016-01-04' AND EXISTS (SELECT * FROM rosters WHERE rosters.SectorDate = '2016-01-24' IS NOT NULL)" So basically, I want to select all the users information from mail_list table only if in the rosters table the user has a row that exists with the date 2016-01-04 and a second row 2016-01-24. I have tried several types of EXIST statements as above but no luck so far :/ Please help!! Thanks
  16. Hi Mate, I need advice on my query any inputs is highly appreciated. i have this query on the system that im developing, im using a jquery autosearch api here. $sql = 'SELECT referrals.clientid,fullname, firstname, lastname,email,referredby,hearaboutus,gatecode, address1,city,state,zip, homephone, workphone, cellphone,company FROM referrals INNER JOIN address ON address.clientid=referrals.clientid WHERE referrals.firstname is not null '; for($i = 0; $i < $p; $i++) { $sql .= ' AND fullname LIKE ' . "'%" . mysql_real_escape_string($parts[$i]) . "%' "; } My query seems making the search function slow to respond... is there any adjustments on that sql statemet that you can advice to make it search faster. im searching of about 20K of clients on my database. Thanks in advance Neil
  17. Hello! I'm starting to learn php and for practice I tried to resolve a simple exercise. the idea is to write a php function that inputs a tabe and returns +1 if positive numbers in the table are more than the negative ones. and return -1 if negative numbers in the table are more than the positive ones. 0 if they are equal. this is my code for the function starting from line 8 function plusmin ($tab) { $n = count($tab); $plus = 0; $min = 0; for ($i = 0; $i <= $n; $i++) { if ($tab[$i] > 0){ $plus++; } elseif ($tab[$i] < 0){ $min++; } } if ($plus > $min) { $result = "+1"; } elseif ($plus < $min) { $result = "-1"; } elseif ($plus == $min){ $result = "0"; } return $result; } and just to test it I created a table manually $tab[0] = 1; $tab[1] = -5; $tab[2] = -4; $tab[3] = 7; $tab[4] = -8; $tab[5] = -3; $tab[6] = 2; $tab[7] = 0; $tab[8] = -6; $tab[9] = -9; $k = plusmin($tab); echo $k; when I execute it It works, it shows for the case -1 but the browser shows this error Notice: Undefined offset: 10 in C:\Users\ahmed\PhpstormProjects\Exam 2013\tab.php on line 13 line 13 is this one if ($tab[$i] > 0){ Notice: Undefined offset: 10 in C:\Users\ahmed\PhpstormProjects\Exam 2013\tab.php on line 16 line 16 is this one elseif ($tab[$i] < 0){ I dunno what's the problem. and I know it will turn out to be a stupid problem but hey that's how we all learn. could anyone help? Thanks in advance
  18. Hi all, I currently have an array that is shown like this when I use print_r(array_values($temperature)); Array ( [0] => SimpleXMLElement Object ( [0] => 9.29 ) [1] => SimpleXMLElement Object ( [0] => 11.37 ) [2] => SimpleXMLElement Object ( [0] => 13 ) [3] => SimpleXMLElement Object ( [0] => 14 ) [4] => SimpleXMLElement Object ( [0] => 8 ) [5] => SimpleXMLElement Object ( [0] => 13.81 ) [6] => SimpleXMLElement Object ( [0] => 19.84 ) [7] => SimpleXMLElement Object ( [0] => 22 ) ) I want to find the highest and lowest value from the above array such as here 8 is the lowest and 22 being the highest value. I am not sure how I can order the array inside an array to do this. Thanks
  19. Hi all, I am trying to get information from mysql by firstly joining a couple of tables such as: "SELECT Latitude, Longitude FROM airports INNER JOIN rosters ON airports.IATA = rosters.Dep WHERE rosters.Dep = 'BGY'"; I would also however like to select another airports.Latitude and airports.Longitude in the same query. Something like... "SELECT Latitude AS departure_lat, Longitude AS depatrure_lng FROM airports INNER JOIN rosters ON airports.IATA = rosters.Dep WHERE rosters.Dep = 'BGY' AND SELECT airports.Latitude AS arrival_lat, airports.Longitude AS arrival_lng FROM airports INNER JOIN rosters ON airports.IATA = rosters.Arr WHERE rosters.Arr = 'CRL'"; So basically, I am trying to get the departure and destination latitude and longitudes from an airport where departure = BGY and arrival = CRL using one query. Thanks for any help!
  20. Last year ended with major releases in Web development specially related to PHP. There is a list of updates including Magento 2, Drupal 8, Laravel 5.2, WordPress 4.4 and the most revolutionary release of PHP 7. We conducted a survey at various forums and even contacted influencers to share their expectation from PHP in 2016. Read the post containing expectations or predictions about php trends 2016. Also Node.Js impact on market share of PHP is discussed in details.
  21. Is there a better way to do this? $p = 3; $a = 3; $b = 3; $arr = [$p,$a,$b]; if (in_array(0, $arr)) { return 'Pending'; } if ((in_array(2, $arr)) && !in_array(0, $arr)) { return 'Incomplete'; } if ((in_array(1, $arr)) && !in_array(0, $arr) && !in_array(1, $arr)) { return 'Approved'; } if (in_array(3, $arr) && !in_array(0, $arr) && !in_array(1, $arr) && !in_array(2, $arr)) { return 'Declined'; }
  22. <?php include_once("init.php"); // Use session variable on this page. This function must put on the top of page. if(!isset($_SESSION['username']) || $_SESSION['usertype'] != 'admin'){ // if session variable "username" does not exist. header("location: index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php } else { error_reporting(0); if(isset($_GET['sid'])) { echo $_GET['sid']; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>Simple invoice in PHP</title> <style type="text/css"> body { font-family: Verdana;; } div.invoice { border:1px solid #ccc; padding:10px; height:740pt; width:570pt; } div.company-address { border:1px solid #ccc; float:left; width:200pt; } div.invoice-details { border:1px solid #ccc; float:right; width:200pt; } div.customer-address { border:1px solid #ccc; float:right; margin-bottom:50px; margin-top:100px; width:200pt; } div.clear-fix { clear:both; float:none; } table { width:100%; } th { text-align: left; } td { } .text-left { text-align:left; } .text-center { text-align:center; } .text-right { text-align:right; } </style> </head> <body> <div class="invoice"> <div class="company-address"> <?php $sid = $_GET['sid']; $line = $db->queryUniqueObject("SELECT * FROM stock_sales WHERE transactionid='$sid' "); $mysqldate = $line->date; $phpdate = strtotime($mysqldate); $phpdate = date("d/m/Y", $phpdate); echo $phpdate; ?><?php echo $sid; ?> <?php $line4 = $db->queryUniqueObject("SELECT * FROM store_details "); ?> <?php echo $line4->name; ?> <br /> <?php echo $line4->address; ?>,<?php echo $line4->place; ?> <br /> LPhone <strong>:<?php echo $line4->phone; ?></strong> <br /> </div> <div class="invoice-details"> Invoice no : <?php echo $sid;?> <br /> Date: <?php $sid = $_GET['sid']; $line = $db->queryUniqueObject("SELECT * FROM stock_sales WHERE transactionid='$sid' "); $mysqldate = $line->date; $phpdate = strtotime($mysqldate); $phpdate = date("d/m/Y", $phpdate); echo $phpdate; ?> </div> <div class="customer-address"> To: <br /> <?php echo $line->customer_id; $cname = $line->customer_id; $line2 = $db->queryUniqueObject("SELECT * FROM customer_details WHERE customer_name='$cname' "); echo $line2->customer_address; ?> <br /> 123 Long Street <br /> London, DC3P F3Z <br /> </div> <div class="clear-fix"></div> <table border='1' cellspacing='0'> <tr> <th width=250>Description</th> <th width=80>Quantity</th> <th width=100>Unit price</th> <th width=100>Total price</th> </tr> <?php $db->query("SELECT * FROM stock_sales where transactionid='$sid'"); while ($line3 = $db->fetchNextObject()) { ?> echo("<tr>"); echo("<td><?php echo $line3->stock_name; ?></td>"); echo("<td class='text-center'><?php echo $line3->quantity; ?></td>"); echo("<td class='text-right'><?php echo $line3->selling_price; ?></td>"); echo("<td class='text-right'><?php echo $line3->amount; ?></td>"); echo("</tr>"); } ?> echo("<tr>"); echo("<td colspan='3' class='text-right'>Sub total</td>"); echo("<td class='text-right'><?php $subtotal = $line3->subtotal;?></td>"); echo("</tr>"); echo("<tr>"); echo("<td colspan='3' class='text-right'>VAT</td>"); echo("<td class='text-right'><?php $discount = $line3->discount;?></td>"); echo("</tr>"); echo("<tr>"); echo("<td colspan='3' class='text-right'><b>TOTAL</b></td>"); echo("<td class='text-right'><b><?php $payment = $line3->payment;?></b></td>"); echo("</tr>"); </table> </div> </body> </html> <?php } else "Error in processing printing the sales receipt"; } ?>
  23. Hey Guys, I know it's possible with .Net & ActiveX Controllers but I haven't seen anything like this for PHP / Linux Based Coding and hoping something like this is available. I would like to be able to GENERATE a document (MS Word) based on MySQL queries data. Example. Generate Contact Letter for clients and be able to edit that MS Word Doc and when I click Save, which is the most important part, it would save on the server and in the system. Can anyone advise on where I can at least begin to do something like that? Thanks! Best Regards, Alexander Mirvis
  24. first off i know all 4 headers im using are same its temporary for now eventually i will have 4 different confirmation pages The issue im having is all 4 are processing form correctly into the db but the confirmation pages are redirecting to a new tab here is the php code if needed i can supply the html code as well but seeing the header is being pulled from the php file i think thats where it is what i want is that when the html form processes that it redirects the page to one of the four confirmation pages instead of in a new tab $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } if(isset($_POST['choices']) && !empty($_POST['choices'])){ if($_POST['choices'] == 'four'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; $sql1 = "INSERT INTO ballot (username, useremail, randomnumber) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber3"]."')"; if (mysqli_query($conn, $sql)) ; if (mysqli_query($conn, $sql1)) ; mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get2ticketconfirm.php") ; } } }elseif($_POST['choices'] == 'twoorless'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; if (mysqli_query($conn, $sql)) ; mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get1ticketconfirm.php") ; } } }elseif($_POST['choices'] == 'sixseven'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; $sql1 = "INSERT INTO ballot (username, useremail, randomnumber) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber3"]."')"; if (mysqli_query($conn, $sql)) ; if (mysqli_query($conn, $sql1)) ; { { header("Location: http://justtheway.com/wb/events/pawn/get2ticketconfirm.php") ; } } }elseif($_POST['choices'] == 'fiveorless'){ $sql = "INSERT INTO ballot (username, useremail, randomnumber, neptune) VALUES ('".$_POST["username2"]."','".$_POST["email"]."','".$_POST["randomnumber"]."','".$_POST["neptune"]."')"; if (mysqli_query($conn, $sql)) ; mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get1ticketconfirm.php") ; } } } }else{ echo "Please select once choice for submit query!"; } mysqli_close($conn); { { header("Location: http://justtheway.com/wb/events/pawn/get1ticketconfirm.php") ; } } ?>
  25. I have 2 equal arrays. 1 has ID values for the database table and the other has the corresponding update data. The array lengths keep changing as new data at different times is updated. However they will always be equal. How do I go about updating my mysql database table by extracting each ID from the array and then use that to commit the necessary update with the corresponding data in another array. Below is what I have tried but It only updates the last element and nothing else: $arraysIDs; //array containing database table IDs $arrayVALUES; // array containing update data for ($x = 0; $x < count($arraysIDs); $x++){ $element = "UPDATE TableToUpdate SET newUpdateData = '$arrayVALUES[$x]' WHERE ID = $arraysIDs[$x])"; } Thank you for your help.
×
×
  • 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.