-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
PHP/MySql: Show parent and childrens from a table
Muddy_Funster replied to LBernoulli's topic in PHP Coding Help
+1, I just like it to be made obvious On another nit-picky note - the sample ordering of the OP shows order by ID, not order by Parent, as they have parent X at the top and parent W at the bottom... so nah nah na na nah -
PHP/MySql: Show parent and childrens from a table
Muddy_Funster replied to LBernoulli's topic in PHP Coding Help
I don't think changing the use of PDO to mysql_* is strictly an improvment -
try using foreach ($productitemsearch->ProductItemSearchResult->productdata as $key => $att){ echo "$key --- $att<br>"; } to generate a list of the items returned. You'll not need to display all of them, so pick out the ones that you need and then present it as you desire.
-
PHP/MySql: Show parent and childrens from a table
Muddy_Funster replied to LBernoulli's topic in PHP Coding Help
Assuming that this is a single level Parent/Child relationship, and that the parents will never be children themselves, then something like the following: <?php $results = array(); $dsn = "mysql:host=<hostname>;dbname=<dbname>"; $con = new PDO($dsn, "dbUserName", "dbPassword"); $sql = "SELECT `parent`, `child` FROM Test"; $recordset = $con->query($sql); foreach($recordset as $row){ if(!array_key_exists($results, $row['parent'])){ $results[$row['parent']] = array($row['child']; } else{ array_push($results[$row['parent']], $row['child']); } } foreach($results as $parent =>$children){ echo "<span style=\"font-weight:bold;\">$parent</span><br>"; foreach ($children as $child){ echo $child."<br>"; } echo "<br>"; } ?> This is off the cuff and untested, but it's not too far from the mark. -
Fetching data/formula from mysql and inserting into form
Muddy_Funster replied to tylerancell's topic in PHP Coding Help
well yeah, information on what you actualy have would be a couple of notches above handy, but basicly you would get the information out of the database, performing the miltiplication within the query if at all possible, and then echo the contents out as you render the form page. -
can you show us the output of print_r( $client->__getFunctions() ); ?><br /><br /><br /><? print_r( $client->__getTypes() );
-
shouldn't it be : $query = "INSERT INTO table (percent, deviation) VALUES ($percent, STDDEV_SAMP($percent))"; with $percent sent to both values?
-
So does something like the following help? for($i=1;$i<=700;$i++){ $rawLog= log($i); $roundedLog = round($x, 2); $roundedLogOneHundred = $y * 100; if($roundedLogOneHundred == $i){ echo $roundedLogOneHundred." - ".$i." <<<--- This one!!<br>"; } else{ echo $roundedLogOneHundred." - ".$i."<br>"; } }
-
have you tried echoing the contents of the $fullpath variable once it's set?
-
your link doesn't work, and your information is a little sparse. Is this a php coding quertion or a php math question?
-
That's MS Excel embeds it's own meta data into the file. You just need to accept that this message will apear and that you will need to click to open anyway when the propt comes up. You could just save as CSV and have Excel open the CSV, that would avaoid the warning.
-
commonly this comes from malformed heredoc statements - you can have NO whitespace on the line of the opening heredoc decleration after the name of the heredoc and you can have NO whitespace on the closing line of the heredoc before the heredoc name. Make absoloutly certain that there are no tabs or spaces on these lines that shouldn't be.
-
you can't - as far as I am aware - change the header with PHP once it's been set without rendering the entyre page again. You could maybe get away with calling header('Title: '.$row['bizname']); But that's untested and I would say unlikely as well. The way PHP works it that it is processed on the server before any information is displayed in the browser, this meens that all PHP code on a page is run through before a single element is shown on the screen (unless you use something like output buffers), to change things after the page has been "drawn" then you need something client side, like javascript. You could theoreticly have javascript/jquery change the DOM for the page title - but again, that's not something I have ever played about with.
-
Your welcome - and we were all newbies once upon a time
-
the page title is defined in the html header. If you want to change it you need to write out the whole page, including the header, when you are displaying the results of the query - so else{ $row = mysql_fetch_assoc($data); $html = <<<HTML <!DOCTYPE html> <html lang="en"> <head> <title> {$row['bizname']} </title> </head> <body> <table> <tr border="1"> <td class="td1"><h1>{$row['bizname']}</h1></td> </tr> <tr> <td class="td3">{$row['bizhours']}</td> </tr> <tr> <td class="td2">{$row['bizdescription']}</td> </tr> <tr> <td class="td2">{$row['bizaddress']}</td> </tr> <tr> <td class="td2">Phone : {$row['bizphone']}</td> </tr> <tr> <td class="td2">Fax : {$row['bizfax']}</td> </tr> <tr> <td class="td2>Email : {$row['bizemail']}</td> </tr> <tr> <td></td> </tr> </table> </body> </html> HTML; echo $html; You can't loop multiple results, as you can only have 1 title per page.
-
look into the use of isset() - to check if login has occured - and unset() and session_destroy() for the logout.
-
Uploading file and sending as attachment in e-mail
Muddy_Funster replied to ayushkhemka's topic in PHP Coding Help
why not just use the file loading script from the first page with the non phpMailer script? -
yeah I got that bit, but we kinda need to know what the desired condition of the rotation should be Vs what it actualy is?
-
I don't understand what the problem is - mainly because you havn't explained what the script should be doing.
-
that's the server telling you that your servers IP is not on the "authorised to do this kind of thing" list. You should have been given a sandbox server to connect to for development, once this is complete you will need to register the IP of the server running the completed script with the people who you are trying to access the live data from so that they can authorise it.
-
Embeded Web Page Leaves My Site When Links Are Clicked
Muddy_Funster replied to azpaul's topic in PHP Coding Help
Yeah, seriously. My statement was not intended to acuse you of directly and intentionaly trying to missuse somone elses content, only to draw awareness to the fact that in 99.9% of the times people try to do this sort of thing they are in fact doing so in contrivention to the original hosts conditions. The fact of the matter is, if charges are pressed against someone who does this kind of thing against a hosts usage agreament, and there is evidence that can tie other people to the fact that they aided and abettet that person....you get the idea. I have checked the PM and am convinced that this is an instance of colaberative acceptance from both parties involved. The issue you are experiancing is this - cURL loads the content of the page into a variable, allows for some manipulation of the page data (case in point : your application of the preg_replace) and then lets you display the returned result on your page as though that's where the content came from. Unfortunately it's not a "tunnel" to the sites content, just a preloading of the remote page data which you can then load into your own page. This meens that any and all relative linking done within the presented document (ie. css files attached and loaded through something like [<link rel=stylesheet" type="text/css" href="/css/dispTemp/main.css" />] or [<img title="" alt="image1" src = "/images/pageContent/image1.png" />] is no longer valid - unless you happen to load the cURL script within a clone of the original sites file structure. That's what your preg_replace() fixes, it changes any relaitve addressing to absoloute url addressing, alowing the css and images to load properly, however, it doesn't stop there, all anchors will also be changed to point to http://theirsite.com/ This is why all the links still send people back to the original remote site when they are clicked. To fix this you will either need to alter the preg_replace so that it ignores anchor tags (and then find something that will re-write the links seporately), or change it out for a DOMdocument parser that you can then change the attributes on specific elements as needed. Unfortunately I know the theory, but have never tried the practice - not an area I have ever been involved in. However others here are more than a little bit good at these kinds of things. -
No, I meant the actual code content of the page. The main reason I can think of is if something somewhere has either a javascript "window.location" or a php "header('Location: ...')" in it that is being called from the destination as well, thus it is constantly re-sending the browser back to itself every time it loads. this gives the effect of a loop without actualy coding a litteral loop. As guestbook.html is the constant between both code samples it seemd a likely place to start.