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

  • Job Boards
    • Jobs
  • Community Lounge and FAQ
    • Forum News
    • Open Forum
    • New Members Forum - Start Here!
  • Entrepreneurship, Business and Marketing
    • Social Media Marketing & Web Marketing
    • Entrepreneurship
    • Career Questions - Asked and Answered
  • StudioWeb
    • StudioWeb
    • StudioWeb News
    • StudioWeb Projects
  • Programming
    • Python
    • Javascript
    • PHP
  • Web Design
    • Beginners Web Design
    • HTML/XHTML
    • Dreamweaver
    • CSS
    • Advanced Web Design
    • Business of Web Design
    • Web Design News
  • Miscellaneous
    • Cybersecurity
    • Miscellaneous Software
    • Blogs and CMS
    • Web Accessibility
    • Peer-to-Peer Reviews
    • Website Templates
    • Web Design Jobs
    • Test Forum
  • Archives
    • Beginners Web Design
    • Course: The Complete Entrepreneur
    • Web Accessibility
    • Photoshop
    • CSS
    • Forum Rules and Etiquette
    • Flash
    • ASP
    • General Programming
    • Expression Web
    • Beginners Ruby
    • Killersites University
    • Actionscript

Calendars

  • Community Calendar

Categories

There are no results to display.

There are no results to display.

Product Groups

  • Business & Entrepreneur Courses

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website


LinkedIn


Facebook


Twitter


AIM


Yahoo


Other


Location


Interests

  1. PHP form --> convert to WP form Hi there, I have several (legacy) php forms I'd like to re-use in my wp site. No way I will retype them again... therefore I'm looking for a way to import them directly into wp. Would you recommend any plugin? I understand pasting the original php code into the text editor will save me a lot of time, but it won't be final, since a lot of validation has to be done, etc... Do you have any experience with importing php forms into wp with a kind of 1-click solution? WP's plugins repository is not obvious on this matter...or maybe I've just missed it. txs
  2. What is the difference between statements and functions? For instance why dont we type include('somefile.php') or echo('Hello World') ? Thanks!
  3. Okay this is a newbie question but I know how it works but I just want to know how. So this code for example: if(isset($_POST['submit'])){ // do some stuff } else { // do some else stuff } This if statement will only do its code block if submit button is clicked or in nerds language if $_POST['submit'] is set. So thats means that value of that submit button is NULL before clicking, but when we click that submit button we are giving it a value? For example <input type="submit" name="submit" value="someAwesomeValue"> if I click this button its value will be 'someAwesomeValue' which means I set $_POST['submit'] value to 'someAwesomeValue' or in other words $_POST['submit'] = 'someAwesomeValue' Thanks!
  4. Php Buddies, I'm going to jump into building my own searchengine now. Starting off with the search box, then the index and then finally the crawler. Not too worried about the crawler. Gonna make use of cURL and implode,explode, etc. php functions. It's the Index that I quite can't get my head around. To build the Index, should I have the structure of the mysql tbl like this .... ? Option 1 Columns Url|Keywords Or, should I make the structure like this instead ..... ? Option 2 Columns Keyword|Urls Option 1a Example Columns Url | Keywords ----------------------------------------------------------------------- devshed.com | forum, programming, php Option 1b Example Columns Keyword | Urls -------------------------------------------------------------------------------------------------------------------------- forum | devshed.com, blackhat.com, warriorforum.com --------------------------------------------------------------------------------------------------------------------------- php | devshed.com/forum/php.htm, sitepoint.com/forum/php.php Option 2a Example Columns Urls | Keyword ----------------------------------------------------------------------- devshed.com | forum ----------------------------------------------------------------------- devshed.com | programming ----------------------------------------------------------------------- warriorforum.com | money ----------------------------------------------------------------------- warriorforum.com | forum Option 2b Example Columns Keywords | Urls -------------------------------------------------------------------------------------------------------------------------- forum | devshed.com/forum -------------------------------------------------------------------------------------------------------------------------- forum | blackhat.com/forum --------------------------------------------------------------------------------------------------------------------------- php | devshed.com/forum/php.htm --------------------------------------------------------------------------------------------------------------------------- php | sitepoint.com/forum/php.php Question 1: I have a feeling you won't like Option 1a or 1b atall. But, let's assume you need to do it out of them 2 options. Which one would you choose ? Question 2: I have a feeling you will like Option 2a or 2b. Which one would you choose ? Or, if you don't like any of them 2. Then, let's assume you need to do it out of them 2 options. Which one would you choose ? Question 3: If you don't like the structure of any of the 4 options then which structure would you yourself use or have used ? Best to show an example like I did. Btw, I know that, if I structure my tbl around the way I showed in my examples then users would only be able to make queires for a single keyword and not a phrase. But, dealing with phrases get complicated and so for the time being, as a beginner, let's concentrate one thing at a time. Concentrate on the very first basic of indexing a url. Thanks
  5. Hi people, I have one question about mysqli_fetch_assoc in a while loop. $query = "SELECT * FROM category "; $result = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($result)) { $cat_id = $row['cat_id']; $cat_title = $row['cat_title']; echo $cat_id . " " . $cat_title ."<br>"; } So, how does $row = mysql_fetch_assoc($result) works? So it loops one row at a time from $results and stores that information in $row until it there is no row to return? And this mysqli_fetch_assoc($result) in while loop iterations is this " array(some rows that it got from $result) "? $row = mysqli_fetch_assoc($result) is same as $row = array(all rows from $result that are gathered by mysqli_fetch_assoc) ? And that means $row is actually an array, and every time it loops the information is not overwriten by new instead it is added? Sorry if i confused you with such questions Thanks in advance!
  6. My PHP script for mysqli queries works most of the time, but while running a loop that queries database many times, occasionally I'll get Warning: PHP Warning: mysqli_stmt::execute(): (HY000/2013): Lost connection to MySQL server during query in... blah blah blah Can someone tell me if I need to modify the structure of my queries to make it work better? Here's my example: <?php $host = "localhost"; $username = "blah_blah"; $password = "blah_blah"; $database = "blah_blah"; $mysqli = new mysqli($host, $username, $password, $database,0,'/var/lib/mysql/mysql.sock'); $mysqli->set_charset('utf8'); if ($stmt = $mysqli->prepare("SELECT column_A FROM table_X WHERE column_B=? AND column_C=? LIMIT 1")){ $stmt->bind_param("si", $value_1, $value_2); $stmt->execute(); $stmt->bind_result($column_A_value); $stmt->fetch(); $stmt->close(); } ?>
  7. Hi, I am developing a php-mysql website hosted in an apache. The site is down since yesterday for my IP address, whereas it is visible elsewhere. The web hosting company said they do not see any problems and my IP is not blocked by them. The problem has occured before and was solved by itself after a few days. I simply do not understand the reason behind it. Annoying as I have to stop working on the site till it is restored. Please help. Cheers.
  8. I have received so much help from this site and the amazing people on it. I am humbled by the amount of knowledge everyone here has. I am hoping that you can help me with something that I am struggling to figure out. I have a check box that successfully writes to my db but I can only get it to work with 1 and 0. I would like checked = yes unchecked to = no but I cant figure it out. Here is the code I am currently using. <strong>Active: *</strong> <input type="checkbox" name="Active" value="1" <?php if($Active == 1) echo 'checked="checked"'; ?>"/><br/> and $Active = (int)$_POST['Active'];
  9. Is it possible to have 2 or 3 tables in a database example Table 1 = names Table 2 = address Table 3 = phone numbers and when I fill in my name and number on a form it writes the name to the name table and number to the number table and then I can build a query to pull the phone that goes with the right name? Is it better to spilt it up this way for security or it doesn't really matter? I just feel like I have way to many rows in a single table on my database.
  10. I am using the code from Basic PHP System: View, Edit, Add, Delete records with MySQLi and I am wanting to add some code that will display a total number of results returned from a query. if ($result = $mysqli->query("SELECT * FROM clients where (`clients`.`aftercare` = 'yes')ORDER BY LastName ASC")) My question is how can I display how many records are returned. So for example I run it and it returned 40 names. I would like to add something to the page that says 40 people found. I am sure this is probably very simple, but I am brand new to all of this. Thank you for you help in advance.
  11. Hello Forum: I'm just now trying to learn PHP and read that using PDO was a better way to utilize online databases. I have my Registration page completed, storing client info in a MySQL db, all done using PDO. However, I'm having a little trouble with the Login page. I don't know if I'm using the PDO stuff the right way. $stmt = $db->prepare('SELECT (username, password) FROM members WHERE (username) LIKE ? AND (password) LIKE ?'); $stmt->bindValue(1, "%$uname%", PDO::PARAM_STR); $stmt->bindValue(2, "%$pwd1%", PDO::PARAM_STR); $stmt->execute(); echo $affected_rows = $stmt->rowCount(); I'm not sure if I have the bindValue statements right, and I'm only assuming (hence the echo statement) that, if this is a valid username and password, one row will be affected. Like I said, I'm new to PHP, and this is my second day. So I imagine I have this code all wrong. Can someone set me on the right track? Much appreciated. ~Landslyde
  12. Hello, i try to make an Ajax pagination, but I got error. Here is my code : Here is My Panel Controller : <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Panel extends MY_AuthController { public function __construct() { parent::__construct(); $this->load->model("paneldata"); } public function index() { $this->load->view('template/header/panel.php'); $this->load->view('containt/panel.php'); $this->load->view('template/footer/panel.php'); } public function general_post($awal = 0) { $this->load->library('pagination'); $this->load->model('paneldata'); $config['base_url'] = base_url() . '/panel/general_post'; $config['total_rows'] = $this->paneldata->jumlahpost(); $config['per_page'] = 3; $this->pagination->initialize($config); $data['link'] = $this->pagination->create_links(); $data['row'] = $this->paneldata->postview($awal); //Transkrip Script $this->load->view("section/post.php",$data); } //SOME CODE BELOW HERE } Here is my Panel View for header (template/header/panel.php): <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/mine/panelstyle.css'); ?> <?php echo link_tag('public/css/mine/footer_acl.css'); ?> <?php echo '<script src="' . base_url() . 'public/js/jquery.min.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/kickstart.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/administration.js"></script>'?> </head> <body> And here is for content (containt/panel.php): <body> <div id="wrapper2"> <header id="logo" class="col_4"> <?php echo '<img src="' . base_url() . 'public/css/img/Logo2.png">'?> </header> <div id="tabcont" class="col_12"> <ul class="tabs left"> <li><a href="#tabr1">General</a></li> <li><a href="#tabr2">User</a></li> <li><a href="#tabr3">Gallery</a></li> <li><a href="#tabr4">Construction</a></li> </ul> <div id="tabr1" class="tab-content"> <div id="menu" class="col_3"> <ul class="menu vertical"> <li id="post"><a href="#">Post</a></li> <li id="events"><a href="#">Events</a></li> <li id="pages"><a href="#">Pages</a></li> <li id="user"><a href="#">User</a></li> <li><a href="#">Post</a></li> </ul> </div> <div id="content" class="col_9"> </div> </div> <div id="tabr2" class="tab-content">Tab2</div> <div id="tabr3" class="tab-content">Tab3</div> <div id="tabr4" class="tab-content"> <div id="menu" class="col_3"> <ul class="menu vertical"> <li id="post"><a href="#">Post</a></li> <li id="events"><a href="#">Events</a></li> <li id="pages"><a href="#">Pages</a></li> <li id="user"><a href="#">User</a></li> <li><a href="#">Post</a></li> </ul> </div> <div id="content" class="col_9"> </div> </div> </div> </div> Here is my javascript code for administration.js: $(document).ready(function() { /*UNTUK TABEL GENERAL*/ $('#tabr1 #content').load('panel/general_post'); $('#tabr4 #content').load('panel/construction_post'); $("#tabr1 #events").click(function(event){ $('#tabr1 #content').load('panel/general_event'); }); $("#tabr1 #post").click(function(event){ $('#tabr1 #content').load('panel/general_post'); }); $("#tabr1 #user").click(function(event){ $('#tabr1 #content').load('panel/general_user'); }); /*UNTUK TABEL CONSTRUCTION*/ $("#tabr4 #post").click(function(event){ $('#tabr4 #content').load('panel/construction_user'); }); /*UNTUK PAGINATION*/ $("#pagination a").click(function(event){ event.preventDefault(); /* get some values from elements on the page: */ //var $page = $( this ), // url = $page.attr( 'href' ); /* Send the data using post */ // var posting = load( url ); /* Alerts the results */ //posting.done(function( data ) { // alert("succes"); //$('#tabr1 #content').html(data); //}); alert('succes'); $('#isi').load('panel/general_user'); }); }); As you see, I use ajax to change the content of containt/panel.php. for example, if click at div#tabr1 #post, it will prevendefault and go to panel/general_post. After that, the content will change to section/post.php (because at function general_post on panel controller, it will load view section/post.php). Here is section/post.php : <!----><script type="text/javascript" src="http://localhost/2014/14_10_16_peduli_palu_ajax/public/js/jquery.min.js"></script> <script type="text/javascript" src="http://localhost/2014/14_10_16_peduli_palu_ajax/public/js/administration.js"></script> <!----> <a class="search" href="#">+ Advanced Search</a> <div style="clear:both"> </div> <a class="search" href="#"><i class="icon-refresh"></i> Refresh</a> <div style="clear:both"> </div> <div id="isi"> <table class="striped"> <tr> <td>Id</td> <td>Author</td> <td>Category</td> <td>Title</td> <td>Content</td> <td>Date Created</td> <td>Date Modified</td> <td>Action</td> </tr> <?php foreach($row as $r):;?> <tr> <td><?php echo $r->id; ?></td> <td><?php echo $r->author1; ?> <?php echo $r->author2; ?></td> <td><?php echo $r->category; ?></td> <td><?php echo $r->title; ?></td> <td><?php echo implode(' ', array_slice(explode(' ', $r->content), 0, 10)) . "..."; ?></td> <td><?php echo $r->date_created; ?></td> <td><?php echo $r->date_modified; ?></td> <td><a href="#"><i class="icon-edit"></i></a> <a href="facebook.com"><i class="icon-remove"></i></a></td> </tr> <?php endforeach; ?> </table> </div> <div id="pagination"> <?php echo $link; ?> </div> As you see in first and second line, I input the script. Why do i do this ? Because, section/post.php will not load any script in page, because section/post.php is just called by ajax (Look at admistration.js). But, if I do this, I got errors (I can't click <a> elements, I can't scroll the page, etc). And if i do not input the script (in first and second line on section/post.php), I can click the <a> elements, but the script is not worked (because section/post.php does not identify the script) What should I do ? I Hope you understand my question..
  13. Hi there, i have recieved this notice Warning: Header may not contain more than a single header, new line detected in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 53 and these are my codes. Kindly help me to fix this. <?php session_start(); $session_id = $_SESSION['user_id']; if($session_id == null){ header("location:Student_Edit.php"); die(); } include 'Connect.php'; $flag = "success"; function rollbackData(){ mysql_query(" ROLLBACK "); global $flag; $flag = "error"; if(mysql_error() != null){ die(mysql_error()); } } $student_id = $_POST['student_id']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $gender = $_POST['gender']; $date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth'])); $contact_no = $_POST['contact_no']; $grade = $_POST['grade']; $section = $_POST['section']; $LRN = $_POST['LRN']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $address = $_POST['address']; $description = $_POST['description']; $imagename = ""; $flag= ""; mysql_query("SET AUTOCOMMIT = 0 "); if(mysql_error() != null){ die(mysql_error()); } $query = "UPDATE student_information SET first_name='$first_name',last_name='$last_name',"; $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',"; $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'"; $query .= " WHERE student_id='{$_SESSION['user_id']}'"; $result = mysql_query($query, $link_id); if(mysql_error() != null){ die(mysql_error()); } if($result) { $flag = "success"; } else { $flag = "error"; } header("location:Student_Edit.php?flag=$flag&student_id=student_id=$student_id"); ?> Please advise
  14. Hello everyone, I am confused with these little codes why it keeps error in updating the learner information. These are my codes so far. These are the bits of Student_Info.php which i think would be useful in my query. <?php if(!empty($_GET['flag']) && $_GET['flag'] == "success") { ?> <span class="stylered style1"><span class="style5">Learner Information updated successfully.</span></span> <?php } else if(!empty($_GET['flag']) && $_GET['flag'] == "error") { ?> <span class="stylered style3 style5"><span class="style1">Error while updating Learner Information. Please try again</span></span> <?php } ?> </td> This is the Student_Edit_Handler codes. <?php session_start(); $session_id = $_SESSION['user_id']; if($session_id == null){ header("location:Student_Edit.php"); die(); } include 'Connect.php'; $flag = ""; $student_id = $_POST['student_id']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $gender = $_POST['gender']; $date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth'])); $contact_no = $_POST['contact_no']; $grade = $_POST['grade']; $section = $_POST['section']; $LRN = $_POST['LRN']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $address = $_POST['address']; $description = $_POST['description']; $query = "UPDATE student_information SET learner_id='$learner_id',first_name='$first_name',last_name='$last_name',"; $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',"; $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'"; $query .= " WHERE student_id='{$_SESSION['user_id']}'"; $result = mysql_query($query, $link_id); if(mysql_error() != null){ die(mysql_error()); } else{ $flag="error"; } if($flag == "success"){ mysql_query(" COMMIT "); $flag="success"; if(mysql_error() != null){ die(mysql_error()); } } header("location:Student_Edit.php?flag=$flag&student_id='{$_SESSION['user_id']}'"); ?> It flags the error on else{$flag="error";} I am stuck with these codes guys, please do help me modify it so learner information will be update.
  15. Hello there Admins, I would like to display the image on his/her profile. This is so far the codes i have made. It displays only the outline border of the image but not the student's image itself. <?php session_start(); $session_id = $_SESSION['admin_id']; if($session_id == null){ header("location:Admin_Home.php"); die(); } include 'Connect.php'; $student_id = htmlentities($_REQUEST['id'], ENT_QUOTES); $result = mysql_query("SELECT * FROM student_information where student_id='$_GET[id]'"); $data = mysql_fetch_array($result); $numRows = mysql_numrows($result); $i = 0; while($i < $numRows) { ?> <img src="display_image.php?id=<?php echo mysql_result($data,$i,"id"); ?>" width="175" height="200" <?php $i++; } ?> Please advise me how to modify these codes to make the image display. By the way this is the display_image.php i created. <?php include 'Connect.php'; $flag = ""; $student_id = htmlentities($_REQUEST['id'], ENT_QUOTES); if (IsSet($_GET['id'])){ $result = @mysql_query("select * from student_information where student_id = ".$_GET['id']); header("Content-type: image/jpeg"); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" ); header("Content-Transfer-Encoding: binary"); header("Content-Type: PHP Generated Data"); header("Content-Length: ".filesize($filename)); while ($data = mysql_fetch_array($result)) { print $data['LRCard'];} mysql_free_result($result); } ?>
  16. Good day Php Friends, i have manage to make a searchbox which displayed the student according to their first name. But after it is being displayed i added with view, edit, delete links. Now my problem is when i click the links it will not direct to the specific student. here are the code for your reference. Admin_Home.php </head> <?php include 'Header.php';?> <body> <script language="javascript" type="text/javascript"> function ajaxFunction(){ var ajaxRequest; try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); }catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e){ alert("Your browser broke!"); return false; } } } ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var first_name = document.getElementById('first_name').value; var queryString = "?first_name=" + first_name ; ajaxRequest.open("GET", "ajax.php" + queryString, true); ajaxRequest.send(null); } </script> <table width="547" align="center"> <tr> <td width="135"><button class="submit" type="submit"> <span class="style8"><a href="Admin_Home.php">Home</a> </button> </span></span></td> <td width="173"><button class='submit' type='submit'> <span class="style8"><a href="Admin_Add_Student.php">Add Learner </a> </button> </span></span></td> <td width="126"><button class="submit" type="submit"> <span class="style8"><a href="index.php">Logout</a> </button> </span></span></td> </tr> </table> <div class="center"> <form name='myForm' align='center'> <span class="style5">First Name:</span> <input type='text' id='first_name' class="lab" /> <input type='button' class="search" onclick='ajaxFunction()' value='Search Learner'/> </form> </div> <div class="style4" id='ajaxDiv'> </div> <p> </p> <p> </p> </body> </html> ajax.php include 'Connect.php'; //Connect to MySQL Server mysql_connect($host, $dbusername, $dbpassword); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query $first_name = $_GET['first_name']; // Escape User Input to help prevent SQL Injection $first_name = mysql_real_escape_string($first_name); $query = "SELECT * FROM student_information WHERE first_name = '$first_name'"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = "<table border='1' cellpadding='10' cellspacing='1' align='center'>"; $display_string .= "<tr align='center'>"; $display_string .= "<th>LR Number</th>"; $display_string .= "<th>F i r s t N a m e</th>"; $display_string .= "<th>L a s t N a m e</th>"; $display_string .= "<th>Grade</th>"; $display_string .= "<th>Section</th>"; $display_string .= "<th>View</th>"; $display_string .= "<th>Update</th>"; $display_string .= "<th>Delete</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[LRN]</td>"; $display_string .= "<td>$row[first_name]</td>"; $display_string .= "<td>$row[last_name]</td>"; $display_string .= "<td>$row[grade]</td>"; $display_string .= "<td>$row[section]</td>"; $display_string .= "<td><a href='View_Profile.php'>View</a> </td>"; $display_string .= "<td><a href='Admin_Edit_Student_Info.php'>Update</a></td>"; $display_string .= "<td><a href='Admin_Delete_Student.php'>Delete</a></td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> i think i miss some codes on the ajax.php VIEW/EDIT/DELETE reference links. Please correct and give me some suggestions. If you need other codes in my page which is necessary just tell me so that i can post it.
  17. I am trying to use JSONReader (along with PHP & XPATH) to parse a very large JSON file, then display search results. A stream parser (such as JSONREader) is recommended over JSON_decode when parsing large files. This simple code below is not displaying any results (in the echo statements). Any advice is greatly appreciated. $reader = new JSONReader(); $reader->open('products.json'); $dom = new DOMDocument; $xpath = new DOMXpath($dom); while ($reader->read() && $reader->name !== 'product') { continue; } while ($reader->name === 'product') { $node = $dom->importNode($reader->expand(), TRUE); $name = $xpath->evaluate('string(name)', $node); $price = $xpath->evaluate('string(price)', $node); echo "Name: " . $name . ". "; echo "Price: " . $price . ". "; $reader->next('product'); } Here is a snippet of the JSON file: { "products": { "product" : [ { "name" : "Dell 409", "price" : 499.99}, { "name" : "HP Lap top", "price" : 599.99}, { "name" : "Compaq 11", "price" : 299.99} ] }}
×
×
  • Create New...