PHP - Moved: Web Programming Ebook / Tutorial
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=332907.0 Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=308352.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=130332.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343600.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=351363.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=330907.0 This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=334310.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316360.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=334229.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348851.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=351535.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321530.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342211.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347977.0 hello, im trying to read the database and store values into an array list. when i run the script it says undefined variable prodcode, name, price in the function prod details. any help pliz. appreciate the help. thnaks! require("dbfunctions.inc.php"); $count; class Product { // The following are the attributes of the Product class, that is, var $prodcode = array(); var $name = array(); var $price = array(); /* CONSTRUCTOR Every class has at least one constructor method. We create an instance of a class using the class's constructor */ function AllProducts() { $qry = "Select ProdCode, Name, Price, Image from products"; //execute query $products = execute_query($qry); if (!$products) {die('query failed.'); } $i = 0; global $count; $count= mysql_num_rows($products); while ($line = mysql_fetch_array($products, MYSQL_ASSOC)) { $prodcode =array ($line['ProdCode']); //$name[$i] = $line['Name']; //$desc[$i] = $line['Desc']; //$price[$i] = $line['Price']; //$category[$i] = $line['Category']; $i++; } } // Method to print the Shopping Cart details to the screen function ProdDetails() { global $count; echo $count; echo $count; for ($i = 0; $i <= $count; $i++) { //echo "<tr><td>"; echo "<br>Product Code: <a href=DisplayProduct.php?prodcode=" . $prodcode[$i]. ">" .$prodcode[$i]. "</a>"."<br>"; echo "Product Name: ".$name[$i]." <br>". "Price: FJD$ " .$price[$i]."<br>"; } } // Method to print the Shopping Cart details to the screen function getProdCode() { echo "Product Code: " . $this->prodcode . "<br>"; } } // END OF CLASS Its like an elusive goal of mine. To be able to write big pieces of code that are reusable in multiple projects.
For example: Lets say we are coding a simple 'Membership system'- login / signup etc.
How would for instance something like routing would be handled in this so that it remains modular. Reusable in multiple projects that may be using a different router for their projects.
Any guidance please ? Is there a book that shows how its done ?
Hii.... I simply want to know the answer of a simple question "Is it possible to do Window Programming in PHP?", like C++, .net, etc.....and if so then where I can find links for the tutorials..... Hi all, I am trying to create a socket that can read from and write to a client. This is my first attempt at it and the code in question is based more or less on a python script a friend sent me as well as some php tutorials google supplied. The problem is (and this seems to be a reoccurring one) when I run it from the command line Code: [Select] php -q server.php nothing visibly happens. Can anyone see what the problem might be? Code: [Select] <?php $host = "localhost"; $port = 50007; set_time_limit(0); // no timeout $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); // create $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // bind $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // listen echo "Waiting for connections...\n"; $contact = socket_accept($socket) or die("Could not accept incoming connection\n"); // accept $input = socket_read($contact, 1024) or die("Could not read input\n"); // read $input = trim($input); // clean $output = "Greetings, you have connected to a socket.\n"; socket_write($contact, $output, strlen ($output)) or die("Could not write output\n"); // return socket_close($contact); // close socket socket_close($socket); // close socket ?> Alright.. I guess to start this off I am looking to sometime in the near future start building a web based or browser based application that I want to build a part of the interface to be a gps module. this will be for a self hosted application likely on tablets or laptops where it will use the data for tracking information amongst other things. Any way most of the application is being handled in PHP, mySQL, jQuery. So with that my question is, is there any way to build a gps application with that as the core languages used. If it is possible, whats the best gps unit I can use? remember im not nessisarily looking for a fancy gps unit to do this with.. just a transmitter/reciever is fine so long as I can build software of my own around it, also is it actually possible to do this with something like php/jquery? or is this something I would have to go the route of maybe java to handle the hardware transactions of which I can tie php/jquery into that.. I am adding a comments "wall" (similar to facebook or youtube) on my site, and here is the condition it's currently in: http://www.trancetrackonline.com/index.php I am not a very good programmer, but I just need to make a couple small changes to the script. I don't want to include "email" or "homepage" fields, since they are not relevant for me. Also, if possible (though the first thing is more important), I'd like to figure out how to make the advertisement at the bottom of the board ("...provided by gentlescript...") a little bit small, since right now it is very obtrusive. many thanks in advance to anyone who can figure this out!!!!!! The scripts are attached, but Here is the comments.tpl.html script: {call_module trigger="frontend_content_footer" data="$page_data"} <!-- Comment List Start --> <a name="c5t_comment"></a> <h2 class="c5t_headline">{$txt_comment_headline} ({$result_number})</h2> <div class="c5t_comment_list"> {foreach from=$comment_list item=item} <div class="c5t_comment_item_background"> <div class="c5t_comment_item"> <div class="c5t_comment_item_title">{$item.comment_title}</div> <div class="c5t_comment_item_text">{$item.frontend_text}</div> <div class="c5t_comment_item_details">#{$item.comment_number} - {if $item.comment_author_homepage != '' and $item.comment_author_homepage != 'http://'}<a href="{$item.comment_author_homepage}">{$item.comment_author_name}</a>{else}{$item.comment_author_name}{/if} - {$item.comment_date} - {$item.comment_time}</div> </div> </div> {/foreach} </div> <!-- Comment List End --> <!-- Pagination Form Start --> {if $comment_list and $display_pagination} <div class="c5t_frontend_pagination"> {if $browse_previous == 2} <form {$startpage.attributes}>{$startpage.hidden}{$startpage.start.html}</form> <form {$previouspage.attributes}>{$previouspage.hidden}{$previouspage.previous.html}</form> {else} <span>{$txt_start}</span> <span>{$txt_previous_page}</span> {/if} {if $browse_next == 2} <form {$nextpage.attributes}>{$nextpage.hidden}{$nextpage.next.html}</form> <form {$endpage.attributes}>{$endpage.hidden}{$endpage.end.html}</form> {else} <span>{$txt_next_page}</span> <span>{$txt_end}</span> {/if} </div> {/if} <!-- Pagination Form End --> <!-- Comment Form Start --> <a name="c5t_form"></a> <div class="c5t_comment_form_background"> <form {$form.attributes}> <table class="c5t_comment_form_table"> <tr> <td colspan="2" class="c5t_error_message"> {foreach from=$message item=item} <div class="c5t_error_message_item">{$item}</div> {/foreach} </td> </tr> {if $show_form == "yes"} <tr> <td class="c5t_comment_form_label"> {if $form.name.error} <span class="c5t_error_message">{$form.name.error}</span> {else} {$form.name.label} {/if} </td> </tr> <tr> <td class="c5t_comment_form_field"> {$form.name.html} </td> </tr> <tr> <td class="c5t_comment_form_label"> {if $form.email.error} <span class="c5t_error_message">{$form.email.error}</span> {else} {$form.email.label} {/if} </td> </tr> <tr> <td class="c5t_comment_form_field"> {$form.email.html} </td> </tr> <tr> <td class="c5t_comment_form_label">{$form.homepage.label}</td> </tr> <tr> <td class="c5t_comment_form_field"> {$form.homepage.html} </td> </tr> <tr> <td class="c5t_comment_form_label">{$form.title.label}</td> </tr> <tr> <td class="c5t_comment_form_field"> {$form.title.html} </td> </tr> <tr> <td class="c5t_comment_form_label"> {if $form.$comment_field_name.error} <span class="c5t_error_message">{$form.$comment_field_name.error}</span> {else} {$form.$comment_field_name.label} {/if} </td> </tr> <tr> <td> {call_module trigger="frontend_textarea" field=$comment_field_name} </td> </tr> <tr> <td class="c5t_comment_form_field"> {$form.$comment_field_name.html} </td> </tr> <tr> <td class="c5t_comment_form_field"> {call_module trigger="frontend_comment_form"} </td> </tr> <tr> <td class="c5t_comment_form_label"></td> </tr> <tr> <td class="c5t_comment_form_submit">{$form.save.html}{$form.hidden}</td> </tr> {/if} </table> </form> </div> <!-- Comment Form End --> and here is the layout.tpl.html script: <div id="c5t_body"> <div id="c5t_bodycontent"> <!-- Language selection (link list or dropdown menu) --> {include file='default/language.tpl.html'} {foreach from=$system_messages item=item} <div class="c5t_system"> <div class="c5t_index">{$item.title}</div> <div class="c5t_code"><br />{$item.message}</div> </div> {/foreach} {foreach from=$error_messages item=item} <div class="c5t_system"> <div class="c5t_index">{$item.title}</div> <div class="c5t_code"><br />{$item.message}</div> </div> {/foreach} {call_module trigger="frontend_page_header"} {include file=$detail_template} {call_module trigger="frontend_page_footer"} {foreach from=$debug_messages item=item} <div class="c5t_system"> <div class="c5t_index">{$item.title}</div> <div class="c5t_code"><br />{$item.message}</div> </div> {/foreach} </div> </div> This is probably less of a language-specific question and more one related to logic, but since it's written in PHP and it's been vexing me for a few hours now, I figured I'd take a shot asking about here! Simple problem I'm trying to figure out for a class; I have a simple string of characters in the form "111-AAA" (three digits, hyphen, three letters) and I'm supposed to increment the string in a particular order. I increment the digits first, and after they've passed 999, I reset them to 000, increment the right-most column on the letters' side, and start again. I assumed this would be pretty simple, but the code I've written executes with some fairly strange results. With the file posted below, eight iterations into the outermost for() loop ought to echo "119-AAA", but I get "129-AAA" instead. And that's just the beginning - I started off with a thousand iterations so I could see just how drastically this little issue snowballs down the line. I see what's happening: before the value in the column being incremented is reset to 0 or A, the next column to be changed jumps the gun and gets incremented early. But no matter where I stick the increment expression, the same thing happens. I'm sure the problem is right here under my very nose, but I'm completely missing it...could anyone possibly show me what I'm not seeing? <html> <title>Test</title> <body> <?php $oldString = "111-AAA"; echo "Below this line is the string to be modified:<p>"; echo $oldString; echo "<p>And below this line is the modified string:<p>"; $newString = array($oldString[2], $oldString[1], $oldString[0], $oldString[6], $oldString[5], $oldString[4]); for($i=0; $i<1000; $i++) { for ($count = 0; $count < 6; $count++) { $newString[$count]++; if (($newString[$count] > 9) && ($count < 3)) { $newString[$count] = 0; break; } if (($newString[$count] == 'AA') && ($count > 2)) { $newString[$count] = 'A'; break; } if (($newString[$count] != 'AA') && ($newString[$count] != 9)) { break; } } echo $newString[2] . $newString[1] . $newString[0] . '-' . $newString[5] . $newString[4] . $newString[3] . "<br>"; } ?> </body> </html> |