Thanks. Works like a charm. Using your loop code for spouses and siblings is throwing up a RESOURCE / BOOLEAN error but I think that's because of a lack of error trapping.
I'm well on my way!
Thank you again.
Search found 196 matches
- Wed Feb 20, 2013 9:44 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
- Sat Feb 16, 2013 11:05 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
I should point out I ran your code exactly as you wrote it and the prefix for each name was 17!! That's the reason I've tried moving that section of the code slightly!
- Sat Feb 16, 2013 11:02 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Christopher. You're a star fella. Your code, with a few tweaks (owing to some unexpected errors caused I think by my hosting company) works almost perfectly. Here it is in its final form: <?php include_once("../../*************.php"); $cxn = mysql_connect($host,$user,$password) or die (&qu...
- Thu Feb 14, 2013 10:08 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Thank you. I really appreciate your help. My problem is I learned PHP and MySQL from a "For Dummies" book, built my website (http://www.didymus.org.uk) on a trial and error basis and although the site works fine I'm updating it and want to refine and improve my code and knowledge as I do s...
- Thu Feb 14, 2013 6:08 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
The strings $sibling1urn to $sibling16urn have already been fetched earlier in my page. The database is queried before the HTML starts with SELECT * from the $mainurn. At the point you see my code I break the HTML to have PHP fetch further details from the database relating to the individual's sibli...
- Thu Feb 14, 2013 5:12 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Right. I've confirmed the problem. All I need now is to work out how to solve it. And I'm gonna need some help! I've echoed the query being sent for both the manual and looped versions of my code. Using: $query = "SELECT $fields FROM tree WHERE urn = '$sibling1urn'"; I get: SELECT urn,surn...
- Thu Feb 14, 2013 4:36 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Christopher. Thank you for the amended code which has greatly simplified and reduced the size of this section of my PHP. I think perhaps, as you suggested, I should go back and explain exactly what I'm doing. My genealogy site uses a file called "display.php" which is passed a Unique Refer...
- Wed Feb 13, 2013 4:01 pm
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
I never meant for you to share my misery but sadly that didn't work either. Tomorrow I'm going to change the query back to a manual entry of $sibling1urn to see if it fetches the details of the first sibling. If it DOES, then I'll know for certain that the problem lies with the way PHP is handling t...
- Wed Feb 13, 2013 10:21 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Had a brainwave then. But it STILL doesn't work!
If I echo $sibquery it still shows $sibling1urn etc. but in terms of running the MySQL query, not a chance.
Kris.
Code: Select all
$sibquery = '$' . 'sibling' . $i . 'urn';Kris.
- Wed Feb 13, 2013 10:08 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Nope. Still no luck. Here's the new version of the code: ... <body> URN: $mainurn<br/>$forename $middlenames $surname ($yearofbirth)<br/><br/>"; // JUST TO TEST THAT dB IS ACCESSED AND WORKING for ($i=1;$i<=16;$i++) { $sibquery = '$sibling' . $i . 'urn'; // THIS ECHOES FINE $fields = "urn,...
- Wed Feb 13, 2013 7:28 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Or would I need to use a new string such as: $sibquery = '$sibling' . $i . 'urn'; $query = "SELECT $fields FROM tree WHERE urn = '$sibquery'; or $sibquery = '$sibling' . $i . 'urn'; $query = "SELECT $fields FROM tree WHERE urn = $sibquery; Any thoughts would be greatly appreciated.
- Wed Feb 13, 2013 7:25 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Done that. Giving $i a value of 6 the code echo '$sibling' . $i . 'urn'; gives me $sibling6urn Which is exactly what I need in my MySQL query. Could it really be that simple? By my reckoning my code for this needs to be: $query = "SELECT $fields FROM tree WHERE urn = '$sibling' . $i . 'urn'&quo...
- Wed Feb 13, 2013 7:11 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
I'll try this as soon as I get home this evening and let you know. It's frustrating because it's such a simple thing and once I work out how to produce the query using the correct syntax, the rest of my code will work fine.
Thanks for all of your help so far.
Thanks for all of your help so far.
- Wed Feb 13, 2013 6:43 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
am i correct in saying that you don't want $sibling to act as a variable but as part of a string called i.e $sibling14urn ? Yep. Spot on. I want $sibling to act as the first part of the string followed immediately by the value of $i and then the word urn. You mention AND. I've read the PHP manual b...
- Wed Feb 13, 2013 3:35 am
- Forum: PHP - Code
- Topic: Problems with FOR loop
- Replies: 32
- Views: 4839
Re: Problems with FOR loop
Would:
<?php
$sibsearch = "$sibling".$i."urn";
?>
work?
<?php
$sibsearch = "$sibling".$i."urn";
?>
work?