PHP - Programming Site Skin Changes With Php
I`ve seen sites, such as ones using Drupal and other open source codes, where skin changes can be done at the click of a button and the site can look drastically different. I have one in place where it`s very basic for my users to select which skins they want but it`s so basic that just colour changes are made (such as text colour, background colour of content boxes, etc). And the code I`m is all custom code I`ve been doing myself.
I downloaded Drupal in hopes of being able to look at it`s codes and see how they do things (it`s how I learn, by seeing codes). But unfortunately the way they write their codes, I don`t understand it at all. I probably only understand about 5% of what they have. I was even looking into how they do blocking but couldn`t get that either. Examples of what I`m looking for: Skin 1 may have the navigation menu on the top of the page Skin 2 may have the navigation menu on the left of the page and are just text links Skin 3 may have the navigation menu on the left of the page and are pictured tabs All of which may also have their own colour codes for texts and background changes and how content boxes are done, etc. How will I be able to write up codes to have my site`s skin change in a total fashion and in a way that I can work with where it`s simple and I can edit it at any time if I choose to (though it may not be needed)? Similar Tutorialshello, 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 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> 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 ?
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.. 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 ?> 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..... Okay... so I am loading some content into my page from the database... I know how to do this normally... but here is the sticking point... I want to load the content from one of 5 options (so there are multiple pages with 5 different options for body copy) depending on what the value of the cookie is... Here is what I tried, but it did not work: //Determin which page ID to use in our query ---------------------------------------------------------------------------------------------- if (!$_GET['pid']){ $pageid = '1'; } else { $pageid = $_GET['pid']; } //Query the Main Content and Titles for the proper page --------------------------------------------------------------------------------------------- $sqlCommand="SELECT process_mainContent_vers1, process_mainContent_vers2, process_mainContent_vers3, process_mainContent_vers4, process_mainContent_vers5, process_pagetitle FROM pages_process WHERE process_id='$pageid' LIMIT 1"; $query=mysqli_query($myConnection, $sqlCommand) or die (mysql_error()); $body = ''; $title = ''; while ($row = mysqli_fetch_array($query)) { if (isset($_COOKIE['career_status'])) { $carreerStatus = ($_COOKIE['career_status']); if ($carreerStatus=="Starting Residency/Graduating Medical School") $body = $row["process_mainContent_vers1"]; if ($carreerStatus=="Ending Residency/Starting Fellowship") $body = $row["process_mainContent_vers2"]; if ($carreerStatus=="Practicing Physician") $body = $row["process_mainContent_vers3"]; if ($carreerStatus=="Practicing Physician") $body = $row["process_mainContent_vers4"]; if ($carreerStatus=="Hospital/Practice Administrator") $body = $row["process_mainContent_vers5"]; } else { $carreerStatus = ($_SESSION['career_status']); if ($carreerStatus=="Starting Residency/Graduating Medical School") $body = $row["process_mainContent_vers1"]; if ($carreerStatus=="Ending Residency/Starting Fellowship") $body = $row["process_mainContent_vers2"]; if ($carreerStatus=="Practicing Physician") $body = $row["process_mainContent_vers3"]; if ($carreerStatus=="Practicing Physician") $body = $row["process_mainContent_vers4"]; if ($carreerStatus=="Hospital/Practice Administrator") $body = $row["process_mainContent_vers5"]; } $title = $row["process_pagetitle"]; } mysqli_free_result($query); //----------------------------------------------------------------------------------------------------------------------------------------- I am at a crossroads. I want to have our website both redesigned graphically as well as need the backend code recoded, retooled, updated, tweaked, etc. I am not a programmer, but I can make decent graphics myself. However, with that said, the graphical redesign I want to give my site, would still involve coding to move objects around, something of which I am not capable of. The decision I face is which to do first? Do I do a graphical redesign first, so that the graphics and layout are already there so that when I want my programmer to add features, they are adding them where they are going to stay. Or do I do a code redesign, tweak where I am adding new features to existing code, and have code that is old rewritten for better function, but put it in spots that may not look as good or as pleasing to the eye, until the graphical design comes? Which is better as far as user experience? Which is going to be cheaper and more cost effective? On the one hand, if I do a graphical redesign first, then things should be in place for where I want new features to end up, and the site looks good, even if it lacks features and may feature open spots where somethings aren't appearing, simply because they haven't been coded yet. Also, I can tell the programmer right where I want the feature they're coding to appear, and once it's inserted, it's where it's going to stay. On the other hand, if I have the coding done first, then as the features are coded, I can have them put in approximate places where I want them, and the features will be coded, but may need to be moved later on to make it more appealing, or be made more visible by being moved. BUT, if the features are already coded, I will know what types of pages I need to have designed, and what all I need to have pages for. Is it cheaper to have a programmer come back and move the code around, or to have a design moved around so that the feature is where I want it to be? I know more/better features will bring more visitors to my site, but so can that initial first time you visit a webpage and the graphical design really looks appealing. It hasn't escaped me that you may need to know what condition the actual site is in that I'm talking about. If so, it's www.gamesforwork.com It lacks both features and a very Web 2.0 design with all the css and ajax bells and whistles. Can any programmers or graphical designers out there give me some ideas, on which direction I should take? I already have my ideas for features, I don't need ideas like that. I am more looking for if it's going to cost a lot more for me to do the graphics first, or the programming first. Thanks for any insight you may have on this. (If it makes any difference our recode would be php,mysql,css,ajax/javascript with quite a bit of database driven pages that organize and display the content the user is interested in) 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> Hi everybody,
So I used to be a pretty decent PHP developer, but I haven't done much with programming for the last 8 years. I switched to the healthcare industry after the big dot-com boom and I'm finishing up a doctorate in nursing this spring. I decided to try and get back into programming to pursue some online teaching projects I want to take on and wow, have I forgotten a lot!
I've got a WordPress site up and I've manged to teach myself some decent animation skills in Flash and After Effects. Now I'm looking to try and build a set of database tables to house medication calculation equations, answers, and some metadata. I've been looking around to try and find some WordPress addons that will let me edit database tables, but everything I've been able to find turns out to be a table editor in the "Microsoft Word" sense of the word, and not actually usable to manage database tables. Is there anything out there that could save me a big chunk of time?
Looking forward to some development after a long break though. I don't plan on working through a shell, so I'm going to be using a text editor on a PC. Any suggestions for making the writing and syncing easily that might make my life easier?
Thanks,
-Bart
Edited by NerdDoc, 09 September 2014 - 07:21 PM. Hello guys,
I require a suggestion about how shall I proceed as when I am about to set a goal for my future in programming world, Just so that you could suggest me better, I urge you to please read about a little background history of mine. And please stay neutral in regards of language, dont say PHP because you are a PHP developer and dont say Java because you are a Java developer.
Thanks.
I stepped into programming when I was in school (below A-levels at 14, now I am 29) and I started to bunk school and went to internet cafe and would sit there reading sources of HTML pages in year 2000. I would observe their programming styles, I would learn about the tags they used and then search internet (it was IE6 then and Yahoo searching at its peak) so I could learn about it.
Years passed, and having my family related to medical professions, I took admission in Pharmacy in University and quit after 2 years and entered working class. My development slowed down but passion always stayed the same.
Now I am in Spain and working as a technician of mobile repairing with a company, but I still have this passion of programming and when I learn that etc etc friend of mine now is working with CISCO in Germany, now is working as a game developer in America, I become really sad. I could have been one of those. But the fact is that I am not. So I restarted again with development and started learning PHP on my work desk using online resources and tutorials and asking silly questions.
Nothing I could become but an obsolete language programmer with a mess.
Now when I havent been able to become someone, till now, I still have passion and I want to be somewhere.
-----------------------------
I am confused for some days now, shall I continue with PHP (apart from the fact that i am a MYSQL learner, haven't learned PDO or MYSQLi till now) or shall I step into Java learning, using the online resources ofCourse, but if I step into Java, It will be a fresh start and I will be able to organize it better on my way with guidance of professionals like you.
The Things confusing me: (as I am imagining in my mind)
PHP:
A great web development language being used on billions of website, have an extraodinary support, well documented, World is moving online, so future is e-commerce in these terms.
JAVA:
Feels a giant to me, and impresses me at times, a myth to me, I am speaking illogical I know, and after android, I see a great potential in this language.
Edited by Digitizer, 28 August 2014 - 06:03 PM. Hey,
I have really looked around and done the research on books and video tutorials about object oriented programming, though I am having difficulties to find something good which gets myself started.
Could somebody recommend me a good book or video tutorials, where I could get started with when it comes to Object Oriented Programming. I am looking to use Object Oriented Programming for building a blog website.
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=332907.0 Hello! I'm making a program in C++ which has some variables that I need to show inside my .php page. So, I have 2 main questions 1) Is there a possible way to detect when my .php page is being requested 2) After this to inform the C++ program that the page is being requested (editing a file or writing to files would be preferable to be avoided) and 3) After this the C++ program to give to php the variables that I want to show (again writing to files isn't preferable) Perhaps question (3) is not for these forums, but I'd like to know if someone has an idea about the issue.... Unfortunately I have the impression that PHP is a simple script language and cannot do s0 high-level things... Prove me wrong, please I have this report that I have written and it looks fine on the screen but the printed output is to big for the page and very ugly. How would I reformat it so it prints better.
<html> <head> <title>Load Report</title> </head> <body> <h1>Load Report</h1> <?php $load=$_POST["Load_ID"]; $connect =odbc_connect("removed"); if(!$connect) { exit("Connection Failed: " . $connect); } $sql="SELECT m1_DC.dbo.SalesOrders.UOMPDROPSEQUENCE ,m1_DC.dbo.organizationlocations.cmlPhoneNumber ,m1_DC.dbo.organizationlocations.cmlName ,m1_DC.dbo.organizationlocations.UCMLSTOREHOURSTXT ,m1_DC.dbo.SalesOrders.OMPSHIPPINGMETHODID ,m1_DC.dbo.SalesOrders.UOMPTRUCKNUMBER ,m1_DC.dbo.SalesOrders.ompCustomerPO ,m1_DC.dbo.SalesOrders.UOMPTOTALBOXCOUNT ,m1_DC.dbo.SalesOrders.UOMPVOLUMETOTAL ,m1_DC.dbo.organizationlocations.CMLADDRESSLINE1 ,m1_DC.dbo.organizationlocations.CMLADDRESSLINE2 ,m1_DC.dbo.organizationlocations.CMLCITY ,m1_DC.dbo.organizationlocations.CMLSTATE ,m1_DC.dbo.organizationlocations.CMLPOSTCODE ,m1_DC.dbo.SalesOrders.OMPREQUESTEDSHIPDATE ,m1_DC.dbo.SalesOrders.ompSalesOrderID ,m1_DC.dbo.SalesOrders.ompOrderTotalBase ,convert(varchar(10),m1_DC.dbo.SalesOrders.uompbuilddate,110) as BuildDate FROM m1_DC.dbo.SalesOrders LEFT OUTER JOIN m1_DC.dbo.organizationlocations ON ompshiporganizationid = cmlorganizationid AND ompshiplocationid = cmllocationid WHERE m1_DC.dbo.SalesOrders.UOMPTRUCKNUMBER='$load' Union All SELECT m1_KF.dbo.SalesOrders.UOMPDROPSEQUENCE ,m1_KF.dbo.organizationlocations.cmlPhoneNumber ,m1_KF.dbo.organizationlocations.cmlName ,m1_KF.dbo.organizationlocations.UCMLSTOREHOURSTXT ,m1_KF.dbo.SalesOrders.OMPSHIPPINGMETHODID ,m1_KF.dbo.SalesOrders.UOMPTRUCKNUMBER ,m1_KF.dbo.SalesOrders.ompCustomerPO ,m1_KF.dbo.SalesOrders.UOMPTOTALBOXCOUNT ,m1_KF.dbo.SalesOrders.UOMPVOLUMETOTAL ,m1_KF.dbo.organizationlocations.CMLADDRESSLINE1 ,m1_KF.dbo.organizationlocations.CMLADDRESSLINE2 ,m1_KF.dbo.organizationlocations.CMLCITY ,m1_KF.dbo.organizationlocations.CMLSTATE ,m1_KF.dbo.organizationlocations.CMLPOSTCODE ,m1_KF.dbo.SalesOrders.OMPREQUESTEDSHIPDATE ,m1_KF.dbo.SalesOrders.ompSalesOrderID ,m1_KF.dbo.SalesOrders.ompOrderTotalBase ,convert(varchar(10),m1_KF.dbo.SalesOrders.uompbuilddate,110) FROM m1_KF.dbo.SalesOrders LEFT OUTER JOIN m1_KF.dbo.organizationlocations ON ompshiporganizationid = cmlorganizationid AND ompshiplocationid = cmllocationid WHERE m1_KF.dbo.SalesOrders.UOMPTRUCKNUMBER='$load' order by UOMPDROPSEQUENCE"; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } $data= ''; while (odbc_fetch_row($result)) { $UOMPDROPSEQUENCE=odbc_result($result,"UOMPDROPSEQUENCE"); $cmlName=odbc_result($result,"cmlName"); $cmlPhoneNumber=odbc_result($result,"cmlPhoneNumber"); $UCMLSTOREHOURSTXT=odbc_result($result,"UCMLSTOREHOURSTXT"); $ompCustomerPO=odbc_result($result,"ompCustomerPO"); $UOMPTOTALBOXCOUNT=odbc_result($result,"UOMPTOTALBOXCOUNT"); $UOMPVOLUMETOTAL=odbc_result($result,"UOMPVOLUMETOTAL"); $CMLADDRESSLINE1=odbc_result($result,"CMLADDRESSLINE1"); $CMLADDRESSLINE2=odbc_result($result,"CMLADDRESSLINE2"); $CMLCITY=odbc_result($result,"CMLCITY"); $CMLSTATE=odbc_result($result,"CMLSTATE"); $CMLPOSTCODE=odbc_result($result,"CMLPOSTCODE"); $ompSalesOrderID=odbc_result($result,"ompSalesOrderID"); $ompOrderTotalBase=odbc_result($result,"ompOrderTotalBase"); $uompbuilddate=odbc_result($result,"BuildDate"); { { if($UOMPDROPSEQUENCE % 2 == 0 ) {$style = '#FFFAFA';} else {$style = '#D3D3D3';}} } $data .= "<tr bgcolor=$style><th>$UOMPDROPSEQUENCE</th>"; $data .= "<th style='text-align:left' height='10'>$cmlName</th>"; $data .= "<td style='text-align:left' height='10'>$UCMLSTOREHOURSTXT</td>"; $data .= "<td style='text-align:center' height='10'>$ompCustomerPO</td>"; $data .= "<td style='text-align:center' height='10'>$UOMPTOTALBOXCOUNT</td>"; $data .= "<td style='text-align:center' height='10'> $UOMPVOLUMETOTAL</td>"; $data .= "<td style='text-align:center' height='10'> $CMLADDRESSLINE1</td>"; $data .= "<td style='text-align:center' height='10'> $CMLADDRESSLINE2</td>"; $data .= "<td style='text-align:center' height='10'> $CMLCITY</td>"; $data .= "<td style='text-align:center' height='10'> $CMLSTATE</td>"; $data .= "<td style='text-align:center' height='10'> $CMLPOSTCODE</td>"; $data .= "<td style='text-align:center' height='10'>$ompSalesOrderID</td>"; $data .= "<td style='text-align:center' height='10'>$ompOrderTotalBase</td>"; //$data .= "<td style='text-align:center'>$uompbuilddate</td>"; $data .= "<td style='text-align:center' height='10'>$cmlPhoneNumber</td></tr>"; } echo "<table><tr>"; echo "<th>Load $load</th><tr>"; echo "<th>Drop</th>"; echo "<th>Name</th>"; echo "<th>Note</th>"; echo "<th>PO</th>"; echo "<th>Box_count</th>"; echo "<th>Cubes</th>"; echo "<th>ADDRESSLINE</th>"; echo "<th>ADDRESS2</th>"; echo "<th>CITY</th>"; echo "<th>STATE</th>"; echo "<th>ZIP</th>"; echo "<th>Order_ID</th>"; echo "<th>Order_Total</th>"; //echo "<th>Build-Date</th>"; echo "<th> Phone </th></tr>"; echo $data; odbc_close($connect); ?> </body> </html> So long story short im trying to read a text file line by line and do a cpl db tests agains that one line my file size is about 1300 lines long so I cut it down to 600 and the page is stil stuck loading, can anyone tell me why, my code is below.: (it was working fine I must have just changed something without knowing it) Code: [Select] <?php include ("include/session.php"); $file_handle = fopen ( "To Do.txt", "rb" ); while ( ! feof ( $file_handle ) ) { $line_of_text = fgets ( $file_handle ); $parts = explode ( '=', $line_of_text ); //get the course infomation //Examples: //$Course_info[0] = GEOL //$Course_info[1] = 1002 //$title = Introduction To Geology $Course_info = explode ( ' ', $parts [0] ); $length = strlen ( $Course_info [0] ) + strlen ( $Course_info [1] ) + 2; $title = substr ( $parts [0], $length ); //check to see if this course is already in the database $sql = "SELECT * FROM courses WHERE course = '$Course_info[0]' AND code = '$Course_info[1]'"; $res = mysql_query ( $sql ) or die ( mysql_error () ); if (mysql_num_rows ( $res ) == 0) { //course doesnt exist //lets get the program ID for this course $id_sql = "SELECT id FROM catagories WHERE code = '$course_info[0]'"; $res = mysql_query($id_sql) or die (mysql_error()); $row = mysql_fetch_array ( $res ); echo $row ['code']; } else { //course is already in the database } exit (); } I have this image upload script he
<?php if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image $target_path = $_SERVER['DOCUMENT_ROOT'] . "/ubergallery/multiple_image_upload/uploads/"; //Declaring Path for uploaded images for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $target_path = $target_path . md5(uniqid()) . "." . $ext[count($ext) - 1];//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } ?>This script also uses javascript for multiple uploading of images. I am looking to add a query to this where I am looking to have the image file names stored in the database. The original image file name should get stored as well, yet the file name itself should get a unique id. I may have to build this query inside this upload script. I was wondering if I can keep that separately with Object Oriented Programming, if somebody just could show me "how it could look like", when it comes to having this done with Object Oriented Programming, I would appreciate it a lot. This is just for fun/exploring. The normal way of iterating over a array is using a for() loop. The functional way is to use array_map . I am trying to write/emulate the array_map function in a functional way. Emulating the array_map using a for loop is easy: function array_map_me_normal($callback,$arr){ $returnArr = []; for ($i =0 ; $i < count($arr);$i++){ $returnArr[] = $callback($arr); } return $returnArr; } But emulating array_map using a functional approach seems to be tricky. Not sure if its even possible. I think it should be possible.. function array_map_me_functional($callback,$arr){ if (empty($arr)){ return false; } return [$callback(array_pop($arr)), $callback($arr)]; } The above is incorrect ofcourse. Returns increasing nested array. But I couldn't do better. Is there a way ? or will an array_map function always be using for loop under its hood ? Thanks Hi I am currently mostly learning procedural PHP but had a question about security.
Are hackers able to see connections to databases in procedural programming? Would connections to databases need to be called from classes and methods instead? Or does it not matter that much? |