Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 118/1708 | < Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >

  • How to develop Online Shopping Portal Application using PHP ?

    - by Sarang
    I do not know PHP & I have to develop a Shopping Portal with following Definition : Scenario: Online Shopping Portal XYZ.com wants to create an online shopping portal for managing its registered customers and their shopping. The customers need to register themselves first before they do shopping using the shopping portal. However, everyone, whether registered or not, can view the various products along with the prices listed in the portal. The registered customers, after logging in, are allowed to place order for one or more products from the products listed in the portal. Once the order is placed, the customer gets a reference order number and the order status should be “order in process”. The customers can track their order using the given reference number. The management of XYZ.com should be able to modify the order status of a particular reference order number to “shipped” once the products are shipped to the shipping address entered by the customer at the time of placing the order. The Functionalities required are : Create the interface for the XYZ.com shopping portal using HTML/XHTML and CSS. Implement the client side validations using JavaScript. Create the tables using MySQL. Implement the functionality using the server side scripting language, PHP. Integrate all the above tasks and make the XYZ.com shopping portal functional. How do I develop this application with following proper steps of development ?

    Read the article

  • I'm confused about encryption and SSL

    - by ChowKiko
    while my friends and I planning to run our own website, we're confused about the encryption where hackers can TAPPING or in social engineering it's WIRE TAPPING, but I don't know how do they call it in Computers today... Well guys, I just want to know how encryption works with websites if we are using PHP+MYSQL? Is it ok to use user login ---- (PHP) encrypt inputted value then (PHP) will decrypt and validate it going to (MySQL) user login ---- (PHP) encrypt inputted value and decrypt the (MySQL) data if they are similar... Is it similar if we use $_SESSION without encryption inside PHP going to MySQL?or PHP encryption also helps the manipulation of binaries?..I'm so confused T_T... In regards to what I stated above, can a hacker hook the data if the server uses $_SESSION? Is $_SESSION safe?... IF THE HACKER CAN HOOK it? is it necessary to use SSL on our website? and why do some Merchandise websites use SSL and likewise facebook also uses SSL? what is the best suit for you if there is no SSL? encrypting the DATA using PHP going to MySQL or even without encryption while the PHP server uses $_SESSION?...

    Read the article

  • Is there a way to add unique items to an array without doing a ton of comparisons?

    - by hydroparadise
    Please bare with me, I want this to be as language agnostic as possible becuase of the languages I am working with (One of which is a language called PowerOn). However, most languanges support for loops and arrays. Say I have the following list in an aray: 0x 0 Foo 1x 1 Bar 2x 0 Widget 3x 1 Whatsit 4x 0 Foo 5x 1 Bar Anything with a 1 should be uniqely added to another array with the following result: 0x 1 Bar 1x 1 Whatsit Keep in mind this is a very elementry example. In reality, I am dealing with 10's of thousands of elements on the old list. Here is what I have so far. Pseudo Code: For each element in oldlist For each element in newlist Compare If values oldlist.element equals newlist.element, break new list loop If reached end of newlist with with nothing equal from oldlist, add value from old list to new list End End Is there a better way of doing this? Algorithmicly, is there any room for improvement? And as a bonus qeustion, what is the O notation for this type of algorithm (if there is one)?

    Read the article

  • Do objects maintain identity under all non-cloning conditions in PHP?

    - by Buttle Butkus
    PHP 5.5 I'm doing a bunch of passing around of objects with the assumption that they will all maintain their identities - that any changes made to their states from inside other objects' methods will continue to hold true afterwards. Am I assuming correctly? I will give my basic structure here. class builder { protected $foo_ids = array(); // set in construct protected $foo_collection; protected $bar_ids = array(); // set in construct protected $bar_collection; protected function initFoos() { $this->foo_collection = new FooCollection(); foreach($this->food_ids as $id) { $this->foo_collection->addFoo(new foo($id)); } } protected function initBars() { // same idea as initFoos } protected function wireFoosAndBars(fooCollection $foos, barCollection $bars) { // arguments are passed in using $this->foo_collection and $this->bar_collection foreach($foos as $foo_obj) { // (foo_collection implements IteratorAggregate) $bar_ids = $foo_obj->getAssociatedBarIds(); if(!empty($bar_ids) ) { $bar_collection = new barCollection(); // sub-collection to be a component of each foo foreach($bar_ids as $bar_id) { $bar_collection->addBar(new bar($bar_id)); } $foo_obj->addBarCollection($bar_collection); // now each foo_obj has a collection of bar objects, each of which is also in the main collection. Are they the same objects? } } } } What has me worried is that foreach supposedly works on a copy of its arrays. I want all the $foo and $bar objects to maintain their identities no matter which $collection object they become of a part of. Does that make sense?

    Read the article

  • How do I get away from PHP in the web industry?

    - by Kurtis
    I'm just looking for some tips on getting away from using PHP for web development. I'm self-employed but it seems like all of the work I find deals with PHP. I'm not complaining about the work -- just the poor choice of a language that is incredibly popular. I'd love to do my web development in Python, Perl, C#, or even a fun and fancy functional language. There's the old saying that you don't tell a carpenter what kind of a hammer to use. At the same time, you do tell them what kind of material to build your house out of and how much you're willing to spend. The problem I am running in to is that I don't know how to get out of this spiral. I can't just turn down work because then I wouldn't have any. I really don't want to go work for another company -- and even if I did, I'd probably still be stuck using something I don't enjoy. I'm hoping someone has "been there" before and might have some good ideas on how to get out of this situation. Thanks!

    Read the article

  • why does array initialization in function other than main is temporary? [on hold]

    - by shafeeq
    This is the code in which i initialize array "turn[20]" in main as well as in function "checkCollisionOrFood()",the four values turn[0],turn[1],turn[2],turn[3] are initialized to zero in main function,rest are being intialized in "checkCollisionOrFood()".This is where fault starts.when i initialize turn[4]=0 in "checkCollisionOrFood()" and then access it anywhere,it remains 0 in any function,but! when i initialize next turn[] i.e turn[5],the value of turn[4] gets depleted .i.e turn[4] have garbage value.turn[20] is global variable,its index"head" is also global.I'm stuck.Plz help me get out of it.Ishall be highly obliged for this act of kindness.This is my excerpt of code unsigned short checkCollisionOrFood(){ head=(head+1)%20; if(turn[head-1]==0){ turn[head]=0; /this is where turn[] is iniliazized and if i access turn[head] here i.e just after iniliazition then it gives correct value but if i access its previous value means turn[head-1]then it gives garbage value/ rowHead=(rowHead+1)%8; if(!(address[colHead]&(1<<rowHead)))return 1; else if((address[colHead]&(1<<rowHead))&& (!((colHead==foody)&&(rowHead==foodx))))gameOver(); else return 0; } if(turn[head-1]==1){ turn[head]=1; colHead=(colHead+1)%8; if(!(address[colHead]&(1<<rowHead)))return 1; else if((address[colHead]&(1<<rowHead))&& (!((colHead==foody)&&(rowHead==foodx))))gameOver(); else return 0; } } void main(void) { turn[0]=0;turn[1]=0;turn[2]=0;turn[3]=0; /these values of turn[] are not changed irrespective of where they are accessed./ while (1) { if(checkCollisionOrFood()) { PORTB=(address[colHead] |=1<<rowHead); turnOffTail(); blink(); } else { PORTB=address[colHead]; createFood(); blink(); } } } Plz help me.

    Read the article

  • PHP FPDF PDF Page Break Question

    - by Michael
    I am using PHP and FPDF to generate a PDF with a list of items. My problem is if the item list goes on to a second or third page, I want to keep the Item Name, Quantity and Description together. Right now, it will go to a second page, but it may split up all of the details for a particular item. PLEASE HELP! <?php require_once('auth.php'); require_once('config.php'); require_once('connect.php'); $sqlitems="SELECT * FROM $tbl_items WHERE username = '" . $_SESSION['SESS_LOGIN'] . "'"; $resultitems=mysql_query($sqlitems); require_once('pdf/fpdf.php'); require_once('pdf/fpdi.php'); $pdf =& new FPDI(); $pdf->AddPage('P', 'Letter'); $pdf->setSourceFile('pdf/files/healthform/meds.pdf'); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx); $pdf->SetAutoPageBreak(on, 30); $pdf->SetTextColor(0,0,0); $pdf->Ln(10); while($rowsitems=mysql_fetch_array($resultitems)){ $pdf->SetFont('Arial','B',10); $pdf->Cell(50,4,'Item Name:',0,0,'L'); $pdf->SetFont(''); $pdf->Cell(100,4,$rowsitems['itemname'],0,0,'L'); $pdf->SetFont('Arial','B',10); $pdf->Cell(50,4,'Quantity:',0,0,'L'); $pdf->SetFont(''); $pdf->Cell(140,4,$rowsitems['itemqty'],0,1,'L'); $pdf->SetFont('Arial','B'); $pdf->Cell(50,4,'Description:',0,0,'L'); $pdf->SetFont(''); $pdf->Cell(140,4,$rowsitems['itemdesc'],0,1,'L'); } $pdf->Output('Items.pdf', 'I'); ?>

    Read the article

  • [solved] PHP-called hyperlink stopped showing when CSS table implemented

    - by Luke
    EDIT: Solved - was not flutter's tag stripping, should work as advertised. I'm using Flutter (which creates custom fields) in Wordpress to display profile information entered as a Post. Before I implemented the CSS tables the link showed up and was clickable. Now I get nothing returned, even when I try to call the link outside the table. If you know anything about this, here's my code in the index.php file and I remain available for any questions. <?php if (in_category('Profile')) { ?> <table id="mytable" cellspacing="0"> -snip- <tr> <th class="row1" valign="top">Website </td> <td>Link: <a href="<?php echo get_post_meta($post->ID, 'FrWebsite', $single=true) ?>"> <?php echo get_post_meta($post->ID, 'FrWebsite', $single=true) ?></a></td> </tr> -snip- </table> Thanks, L Edit: @Josh - there is a foreach looping construct in the table and it is reading and displaying the code correctly, I see what you're getting at now: <tr> <th class="row2" valign="top">Specialities </td> <td class="alt" valign="top"><?php $my_array = get('Expertise'); $output = ""; foreach($my_array as $check) { $output .= "<span>$check</span><br/> "; } echo $output; ?></td> </tr> Edit - @Josh - here's the old code as far as I can remember it, there was no major difference just a <td> tag where there now stands a <th>, there wasn't the class="" and there was no "Link:" and FrWebsite was called Website, but it still didn't work when called Website so I changed to see if that was the error. <tr> <td width="200" valign="top">Website </td> <td><a href="<?php echo get_post_meta($post->ID, 'Website', $single=true) ?>"><?php echo get_post_meta($post->ID, 'Website', $single=true) ?></a></td> </tr>

    Read the article

  • I have a php form dropdown menu that needs to send information

    - by shinjuo
    I have a dropdown menu that is filled by a mysql database. I need to select one and have it send the information for use on the next page after clicking submit. It does populate the drop down menu like it is supposed to it just does not seem to catch the data on the next page. Here is what I have: removeMain.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <form action="remove.php" method="post"> <?php $link = mysql_connect('********', '********', '*********'); if (!$link){ die('Could not connect: ' . mysql_error()); } mysql_select_db("********", $link); $res = mysql_query("SELECT * FROM cardLists order by cardID") or die(mysql_error()); echo "<select name = CardID>"; while($row=mysql_fetch_assoc($res)) { echo "<option value=$row[ID]>$row[cardID]</a></option>"; } echo "</select>"; ?> Amount to Remove: <input type="text" name="Remove" /> <input type="submit" /> </form> <body> </body> </html> remove.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <?php $link = mysql_connect('*********', '*********', '*********'); if (!$link){ die('Could not connect: ' . mysql_error()); } mysql_select_db("***********y", $link); $query = sprintf("UPDATE cardLists SET AmountLeft = AmountLeft - %s WHERE cardID = '%s'", mysql_real_escape_string($_POST["Remove"]), mysql_real_escape_string($_POST["CardID"])); mysql_query($query); mysql_close($link); ?> <br /> <a href="removeMain.php"> <input type="submit" name="return" id="return" value="Update More" /></a> <a href="index.php"> <input type="submit" name="main" id="main" value="Return To Main" /></a> </body> </html>

    Read the article

  • Newbie's problems with MySQL and php

    - by Mirage81
    I'm a real newbie with php and MySQL. Now I'm working on the following code which should search the database for eg. all the Lennons living in Liverpool. 1) How should I modify "get.php" to get the text "no results" to appear if there are no search results. 2) How should I modify "index.php" to get the option values (city and lastname) straight from the database instead of having to type them one by one? 3) Am I using mysql_real_escape_string the right way? 4) Any other mistakes in the code? index.php: <form action="get.php" method="post"> <p> <select name="city"> <option value="Birmingham">Birmingham</option> <option value="Liverpool">Liverpool</option> <option value="London">London</option> </select> </p> <p> <select name="lastname"> <option value="Lennon">Lennon</option> <option value="McCartney">McCartney</option> <option value="Osbourne">Osbourne</option> </select> </p> <p> <input value="Search" type="submit"> </p> </form> get.php: <?php $city = $_POST['city']; $lastname = $_POST['lastname']; $conn = mysql_connect('localhost', 'user', 'password'); mysql_select_db("database", $conn) or die("connection failed"); $query = "SELECT * FROM users WHERE city = '$city' AND lastname = '$lastname'"; $result = mysql_query($query, $conn); $city = mysql_real_escape_string($_POST['city']); $lastname = mysql_real_escape_string($_POST['lastname']); echo $rowcount; while ($row = mysql_fetch_row($result)) { if ($rowcount == '0') echo 'no results'; else { echo '<b>City: </b>'.htmlspecialchars($row[0]).'<br />'; echo '<b>Last name: </b>'.htmlspecialchars($row[1]).'<br />'; echo '<b>Information: </b>'.htmlspecialchars($row[2]); } } mysql_close($conn);

    Read the article

  • Php algorithm - How to achieve that without eval

    - by Marcelo
    I have a class that keeps data stores/access data by using words.separated.by.dots keys and it behaves like the following: $object = new MyArray() $object->setParam('user.name','marcelo'); $object->setParam('user.email','[email protected]'); $object->getParams(); /* array( 'user' => array( 'name' => 'marcelo', 'email' => '[email protected]' ) ); */ It is working, but the method unsetParam() was horribly implemented. That happened because i didn't know how to achieve that without eval() function. Although it is working, I found that it was a really challenging algorithm and that you might find fun trying to achieve that without eval(). class MyArray { /** * @param string $key * @return Mura_Session_Abstract */ public function unsetParam($key) { $params = $this->getParams(); $tmp = $params; $keys = explode('.', $key); foreach ($keys as $key) { if (!isset($tmp[$key])) { return $this; } $tmp = $tmp[$key]; } // bad code! $eval = "unset(\$params['" . implode("']['", $keys) . "']);"; eval($eval); $this->setParams($params); return $this; } } The test method: public function testCanUnsetNestedParam() { $params = array( '1' => array( '1' => array( '1' => array( '1' => 'one', '2' => 'two', '3' => 'three', ), '2' => array( '1' => 'one', '2' => 'two', '3' => 'three', ), ) ), '2' => 'something' ); $session = $this->newSession(); $session->setParams($params); unset($params['1']['1']['1']); $session->unsetParam('1.1.1'); $this->assertEquals($params, $session->getParams()); $this->assertEquals($params['1']['1']['2'], $session->getParam('1.1.2')); }

    Read the article

  • Display all images from outside web root folder using PHP

    - by micmola
    Hello, I want to display all images that are stored outside my web root folder. Please help me. I am only able to display one image repeatedly. For example, if I have 5 images in my folder, only one image is displayed on my browser 5 times. Please help me on this. I've been working on this problem for over a month now. I'm a newbie. Help. Thank you. Here is the code I'm using. images.php <?php // Get our database connector require("includes/copta.php"); // Grab the data from our people table $sql = "select * from people"; $result = mysql_query($sql) or die ("Could not access DB: " . mysql_error()); $imgLocation = " /uploadfile/"; while ($row = mysql_fetch_array($result)) { $imgName = $row["filename"]; $imgPath = $imgLocation . $imgName; echo "<img src=\"call_images.php?imgPath=" . $imgName . "\" alt=\"\"><br/>"; echo $row['id'] . " " . $imgName. "<br />"; } ?> call_images.php <?php // Get our database connector require("includes/copta.php"); $imgLocation = '/ uploadz/'; $sql = "select * from people"; $result = mysql_query($sql) or die ("Could not access DB: " . mysql_error()); while ($row = mysql_fetch_array($result)) { $imgName = $row["filename"]; $imgPath = $imgLocation . $imgName; // Make sure the file exists if(!file_exists($imgPath) || !is_file($imgPath)) { header('HTTP/1.0 404 Not Found'); die('The file does not exist'); } // Make sure the file is an image $imgData = getimagesize($imgPath); if(!$imgData) { header('HTTP/1.0 403 Forbidden'); die('The file you requested is not an image.'); } // Set the appropriate content-type // and provide the content-length. header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: image/jpg"); header("Content-length: " . filesize($imgPath)); // Print the image data readfile($imgPath); exit(); } ?>

    Read the article

  • Included php file calling Javascript function

    - by Illes Peter
    Hi there! Here's the deal. I've got index.php which links to an internal JS file in it's header. index.php then includes another .php file, which outputs this: + add file. addFile() is a Javascript function defined in the external JS file. By doing this nothing happens, the included php does not "see" the JS function. Encapsulating the JS in the included PHP makes it all work. But I don't want to do it that way. Any ideas? EDIT: here's the source <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Archie</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="/screen.css" type="text/css" media="screen"/> <script src="/lib/js/archie.js" type="text/javascript"></script> </head> <body> ... ... //included php starts here <form action="/lib/course.php" method="post"> <fieldset> <div id="addFileLocation"></div> <a href="#" onClick="addFile()">+ add file</a> <input type="hidden" id="addFileCount" value="0"/> </fieldset> </form> //ends here ... ... </body> </html> and the js: <script type="text/javascript"> //Dynamically add form fields //add file browser function addFile() { var location = document.getElementById('addFileLocation'); var num = document.getElementById('addFileCount'); var newnum = (document.getElementById('addFileCount').value -1)+ 2; num.value = newnum; var newname = 'addFile_'+newnum; var newelement = document.createElement('input'); newelement.setAttribute('name',newname); newelement.setAttribute('type','file'); location.appendChild(newelement); } </script>

    Read the article

  • php and asp problem in uploading

    - by moustafa
    i have an ASP web services to change byte array that given from the client and change it to a file and save it in the web server the code is like this : [WebMethod] public string UploadFile(byte[] f, string fileName) { try { MemoryStream ms = new MemoryStream(f); String path="/myfile/"; String location=HttpContext.Current.Server.MapPath(path); FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(path)+fileName, FileMode.Create); ms.WriteTo(fs); ms.Close(); fs.Close(); return "OK"; } catch (Exception ex) { return ex.Message.ToString(); } } the web services need byte array and file name.. i build the client in php upload.php the code is <html> <body> <form action="action1.php" method="post" enctype="multipart/form-data"> Pilih File Anda: <input type="file" name="myfile" /> <input type="submit" value="Upload" /> </form> </body> <html> and action1.php the code is: <?php require_once('nusoap.php'); $client = new nusoap_client('http://192.168.254.160/testuploadah/FileUploader.asmx?WSDL', 'wsdl','','', '', ''); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } if(is_uploaded_file($_FILES['myfile']['tmp_name'])){ $uploadFile = $_FILES['myfile']; ////how can read byte array of $uploadFile so i can send to web services??? ////are php only can send array or string ? $params[]->f=??????????????? $params[]->fileName=$_FILES['myfile']['name']; $result = $client->call('UploadFile', $params,'', '', false, true); if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { //Check for errors $err = $client->getError(); if ($err) { //// Display the error echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { //// Display the result echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } } ?> how can i Send the byte array parameter to the web services,so the web services can started???? i still can resolve this problem,the web services always return an error because i can't send byte array

    Read the article

  • Downloading large file with php

    - by Alessandro
    Hi, I have to write a php script to download potentially large files. The file I'm reporting here works fine most of the times. However, if the client's connection is slow the request ends (with status code 200) in the middle of the downloading, but not always at the very same point, and not at the very same time. I tried to overwrite some php.ini variables (see the first statements) but the problem remains. I don't know if it's relevant but my hosting server is SiteGround, and for simple static file requests, the download works fine also with slow connections. I've found Forced downloading large file with php but I didn't understand mario's answer. I'm new to web programming. So here's my code. <?php ini_set('memory_limit','16M'); ini_set('post_max_size', '30M'); set_time_limit(0); include ('../private/database_connection.php'); $downloadFolder = '../download/'; $fileName = $_POST['file']; $filePath = $downloadFolder . $fileName; if($fileName == NULL) { exit; } ob_start(); session_start(); if(!isset($_SESSION['Username'])) { // or redirect to login (remembering this download request) $_SESSION['previousPage'] = 'download.php?file=' . $fileName; header("Location: login.php"); exit; } if (file_exists($filePath)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); //header('Content-Disposition: attachment; filename='.$fileName); header("Content-Disposition: attachment; filename=\"$fileName\""); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); //header('Pragma: public'); header('Content-Length: ' . filesize($filePath)); ob_clean(); flush(); // download // 1 // readfile($filePath); // 2 $file = @fopen($filePath,"rb"); if ($file) { while(!feof($file)) { print(fread($file, 1024*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } exit; } else { header('HTTP/1.1 404 File not found'); exit; } ?>

    Read the article

  • convert portion of code into a function php

    - by user765368
    This is probably very easy to do but for some reason I can't seem to figure this out. Let's say I have code like this: $elements = array('a', 'b', 'c', 'd'); $myValues = array( 'values' => array( 'a' => array( 'xx' => 3, 'yy' => '' ), 'b' => array( 'xx' => '', 'yy' => '' ), 'c' => array( 'xx' => 8.4, 'yy' => '' ), 'd' => array( 'xx' => 18.4, 'yy' => '' ) ) ); foreach($elements as $elem) { if($myValues['values'][$elem]['xx'] != '') { if($myValues['values'][$elem]['xx'] < 6) { $myValues['values'][$elem]['yy'] = 'less than 6'; } elseif($myValues['values'][$elem]['xx'] >= 6 && $myValues['values'][$elem]['xx'] < 15) { $myValues['values'][$elem]['yy'] = 'between 6 and 16'; } else { $myValues['values'][$elem]['yy'] = 'greater than 15'; } testFunc($myValues['values'][$elem]['xx']); // This is how I would call my function once I replace the code above } } As you can see here what I'm trying to do is to change the value of $myValues['values'][$elem]['yy'] based on some conditions. What I want to do is to replace the if elseif else section of codes by a function that performs the same action. I tried something like: function testFunc($xx) { if($xx < 6) { $yy = 'less than 6'; } elseif($xx >= 6 && $xx < 15) { $yy = 'between 6 and 16'; } else { $yy = 'greater than 15'; } return $yy; } But obviously this won't work because I'm not changing the value of $myValues['values'][$elem]['yy'] inside my function. NOTE I really want to pass ONLY the value of $myValues['values'][$elem]['xx'] inside my function and return the changed value of $myValues['values'][$elem]['yy']. Can anybody help me with this? Thanks in advance

    Read the article

  • how to increment a javascript variable title that is within a php while loop

    - by steve
    I'm building multiple countdown clocks on one page. The number of countdown clocks varies from day to day so I need to call javascript several times from within "while" code in php to produce different clocks. The following code works but it's based on knowing how many clocks are needed before I start: <script language="javascript" src="countdown.js"></script> <script language="javascript"> var cd1 = new countdown('cd1'); cd1.Div = "clock1"; cd1.TargetDate = "<?php echo "$clocktime"; ?>"; cd1.DisplayFormat = "%%D%% days, %%H%% hours, %%M%% minutes, %%S%% seconds until event AAA happens"; </script> <div id="clockwrapper"><div id="clock1">[clock]</div></div> <script language="javascript" src="countdown.js"></script> <script language="javascript"> var cd2 = new countdown('cd2'); cd2.Div = "clock2"; cd2.TargetDate = "02/01/2011 5:30:30 PM"; cd2.DisplayFormat = "%%D%% days, %%H%% hours, %%M%% minutes, %%S%% seconds until event BBB happens..."; </script> <div id="clockwrapper"><div id="clock2">[clock]</div></div> So if I keep on calling the javascript above (the code with cd1 in it) all previous "cd1" clocks change to the latest clock because it is being overwritten. Somehow I need to call javascript from within my "while" loop in php and have cd1 become cd2, then cd3 so that the clocks work as they're supposed to. How do I go about doing this? I don't know how to call the javascript several times and increment the variable cd1 within the javascript. I tried something like this but couldn't get it to work. $id=mysql_result($result,$i,"id"); while($id){ $cd = ("$cd"."$id"); ?> <script language="javascript" src="countdown.js"></script> <script language="javascript"> var <?php echo "$cd"; ?> = new countdown('<?php echo "$cd"; ?>'); .... </script> <div id="clockwrapper"><div id="<?php echo "$cd"; ?>">[clock]</div></div> <?php $id=mysql_result($result,$i,"id"); } ?> Surely there is some easy way of getting around this that I don't know about. Thanks

    Read the article

  • How to send variable to php with ajax?

    - by Dee1983
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript"> function load(thediv, thefile) { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP)'); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(thediv) .innerHTML = xmlhttp.responseText; } } xmlhttp.open('GET', thefile, true); xmlhttp.send(); } </script> </head> <body> <?php //connection to db and mysql query $result = mysql_query($query) or die(mysql_error()); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["idProducts"]; $thing=$row["country"]; $options.="<OPTION VALUE=\"$id\">".$thing.'</option>'; } mysql_close(); ?> <SELECT id="countrySearch" NAME=countrySearch onchange="load('divtest', 'step2.search.php')";> <OPTION VALUE=0>Choose <?=$options?> </SELECT> <div id="divtest"> test </div> </body> step2.search.php consists of: <?php echo "I want it to store the users selection as a variable for php to use"; ?> The problem I have is I want to store what the user selects from the drop down box and use it in php to do a mysql query using the variable from the user select form to form the WHERE part of the mysql statement. Then use ajax to put new data in "divtest". How can I store the user selection into a variable then send it to be used in step2.search.php?

    Read the article

  • Parse error in PHP login form

    - by user225269
    I'm trying to have a login form in php. But my current code doesnt work. Here is the form: <form name="form1" method="post" action="loginverify.php"> <td><font size="3">Username:</td> <td></td> <td><input type="text" name="uname" value="" maxlength="15"/><br/></td> <td><font size="3">Password:</td> <td></td> <td><input type="text" name="pword" value="" maxlength="15"/><br/></td> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" name="Submit" value="Login" /></td> </form> And the verify.php <?php session_start(); ?> <?php $host="localhost"; $username="root"; $password="nitoryolai123$%^"; $db_name="login"; $tbl="users"; $connection=mysql_connect($host, $username, $password) or die("cannot connect"); mysql_select_db($db_name, $connection) or die("cannot select db"); $user=$_POST['uname'] $pass=$_POST['pword'] $sql="SELECT Username, Password from users where Username='$user' and Password='$pass'"; $result=mysql_query[$sql]; $count=mysql_num_rows($result); if($count==1){ $SESSION['Username']=$user; echo"<a href='searchmain.php'> CONTINUE</a>"; } else{ echo"wrong username or password"; echo"<a href='loginform.php'>Back</a>"; } ?> Is there something wrong with my code. I get this parse error at line 15, which is this: $pass=$_POST['pword'] But when I try to remove it.It goes to line 16 or line 17 again. What do I do

    Read the article

  • Page not redirecting properly(php)

    - by user225269
    I want to do the login page this way so that I won't be having trouble posting the username in the userpage. But everytime I try to access login.php. I get an error in firefox, that the page is not redirecting properly. What do I do? This works when I separate them into two. Into something like, login.php and verifylogin.php as the form action. But if I do it like this, I get redirection errors: <?php $host="localhost"; $username="root"; $password="nitoryolai123$%^"; $db_name="school"; $tbl_name="users"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $uname = mysql_real_escape_string($_POST['username']); $pword = mysql_real_escape_string($_POST['password']); $SQL = "SELECT * FROM users WHERE username = '$uname' AND password = '$pword'"; $result = mysql_query($SQL); $num_rows = mysql_num_rows($result); if ($result) { if ($num_rows > 0) { session_start(); $_SESSION['login'] = "1"; header ("Location: userpage.php"); } else { session_start(); $_SESSION['login'] = ""; header ("Location: login.php"); } } else { $errorMessage = "Error logging on"; } ?> <tr> <form name="form1" method="post" action="login.php"> <td> <table> <tr> <td><strong><font size="2">Login User</strong></td> </tr> <tr> <td width="30" height="35"><font size="2">Username:</td> <td width="30"><input name="username" type="text" id="username" maxlength="17"></td> </tr> <tr> <td width="30" height="35" ><font size="2">Password:</td> <td width="30"><input name="password" type="password" id="password" maxlength="17"></td> </tr> <td><td align="right" width="30"><input type="submit" name="Submit" value="Submit" /></td> <td><input type="reset" name="Reset" value="Reset"></td></td> </tr> </form> please help, thanks.

    Read the article

  • How to remove particular element form array

    - by Rahul Mehta
    Hi, I have the following array: Array ( [userid] => 1 [alias] => rahul [firstname] => rahul [lastname] => Khan2 [password] => Ý2jr™``¢(E]_Ø=^ [email] => [email protected] [url] => 4cfe07dbf35d6.jpg [avatar_url] => 4cfe07efd2e1c.jpg [thumb] => 4cfe07ebc8955.jpg [crop_url] => 4cfe07dbf35d6.jpg [crop_position] => [100,100,200,200] [updatedon] => 0000-00-00 00:00:00 [createdon] => 0000-00-00 00:00:00 ) I want to remove the element url ,and crop_url How i can i remove these from array.

    Read the article

  • Sorting an array in PHP based on different values

    - by Jimbo
    I have an array whose elements are name, reversed_name, first_initial and second_initial. A typical row is "Aaron Smith", "Smith, Aaron", "a", "s". Each row in the array has a first_initial or second_initial value of "a". I need to display the rows alphabetically but based on the "a" part, so that either the name or reversed_name will be displayed. An example output would be: Aaron Smith Abbot, Paul Adrian Jones Anita Thompson Atherton, Susan I really have no idea how to sort the array this way so any help will be much appreciated!

    Read the article

  • Function for putting all database to an array

    - by jasmine
    I have written a function to print database to an array like this Array( ID=>1, PARENTID =>1, TITLE => LIPSUM, TEXT =>LIPSUM ) My function is: function dbToArray($db) { $allArrays =array(); $query = mysql_query("SELECT * FROM $db"); $dbRow = mysql_fetch_array($query); for ($i=0; $i<count($dbRow) ; $i++) { $allArrays[$i] = $dbRow; } $txt .='<pre>'; $txt .= print_r($allArrays); $txt .= '</pre>'; return $txt; } Anything wrong in my function. Any help is appreciated about my problem. Thanks in advance

    Read the article

  • Objective-C initial values of created C-array

    - by kpower
    I create an array, similar to classic C (not NSArray or one of it's children) - something like BOOL i[5];. And I want to make all its values to be equal to NO. First of all, I didn't found any information about initial values of such arrays (I know that in classic C they will be undefined, but don't know exactly about Objective-C. I found info about classes and its inner data [after allocation, without initialization], but not about simple data types). And the second, if I should set array values manually - should I use memset(...); or something different? To prevent possible questions... I want to use this construction as array of temporary boolean flags and don't think that it is proved to use something like NSArray here.

    Read the article

  • Array of previous weeks

    - by azz0r
    Hello, I am trying to create an array of weeks for users to select to view stats week on week. What I'm looking for is an array that has the timestamp of week start (monday 00.00 to sunday 11.59) that I can then use in MYSQL queries. Has anyone got an code that might assist? I was thinking of doing something like: $number_of_weeks = 4; $week_array = array(); foreach ($number_of_weeks as $week) { $number_of_weeks--; $value = $number_of_weeks * 604800; $StartOfLastWeek = 6 + date("w",mktime()); $week_array[$number_of_week]['start'] = date('Y-m-d', strtotime("-$StartOfLastWeek day"), $value); $week_array[$number_of_week]['end'] = date('Y-m-d', strtotime("-$StartOfLastWeek day"), $value+ 604800); }

    Read the article

< Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >