Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-29-2010, 02:21 PM The Table Mystery
Chris_123K's Avatar
Super Talker

Posts: 128
Name: Chris Kummelstedt
Trades: 0
Hi Forum,

being a novice I often find myself just trying to spot the difference between something which works, and something that does not.

For some reason that just continues to baffle the hell one column of figures are placed above the table rather than behind. Please can you point me in the right direction of where I should be looking?

On this page you can see the problem in action: http://www.chinese-language-schools.org/

How the function which is troublesome is formed:
Code:
<?php
function display_price ($currency_from, $currency_to,$figure ) {
$url = "http://quote.yahoo.com/d/quotes.csv?s="
. $currency_from . $currency_to . "=X"
. "&f=l1&e=.csv";
$open = fopen($url, "r");
$exchange_rate = fread($open, 2000);
fclose($open);
if ($exchange_rate == "0.00")
   $exchange_rate = "1";
else
$error = "sorry, we could not determine your location and display the prices in your local area,";
echo $exchange_rate*$figure . ' ' . $currency_to;
}

$currency_from="CNY";
?>
The table in question:
Code:
<table class='table_schools' border='hidden' margin='0' padding='0'>
<tr class='tr1'>
<td class='td1'>School</td>
<td class='td2'>Established</td>
<td class='td3'>Class Size</td>
<td class='td1'>Monthly Cost </td>
<td class='td1'>Min age</td>
</tr>



<?php
mysql_connect($server,$user,$password);
@mysql_select_db($database) or die("Sorry, unable to select database");
$result = mysql_query("SELECT * FROM drup_content_type_school ORDER BY field_schoolname_value");
$i=0;
 while($row = mysql_fetch_array($result))
  {
if ($i % 2)
   $class= "tr3";
else 
  $class= "tr2";
  echo "<tr class='" . $class . "'>
<td class='td1'><a href='http://compare-chineselanguageschools.com/content/output-school?school=" . $row['field_schoolname_value'] . "'>" . $row['field_schoolname_value'] . "</a></td>
<td class='td2'>" . $row['field_est_value'] . "</td>
<td class='td3'>" . $row['field_max_class_size_value'] . "</td>
<td class='td1'>" .  round(display_price($currency_from, $currency_to, $row[$price]) , -1)  . "</td>
<td class='td1'>" . $row['field_max_class_size_value'] . "</td>
</tr>
";
$i++;
}

  ?>
</table>
Many thanks,

Chris
Chris_123K is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-29-2010, 03:35 PM Re: The Table Mystery
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
above and behind??

And which column and what browser
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-29-2010, 04:50 PM Re: The Table Mystery
Chris_123K's Avatar
Super Talker

Posts: 128
Name: Chris Kummelstedt
Trades: 0
Quote:
Originally Posted by chrishirst View Post
above and behind??

And which column and what browser
Sorry that was terribly worded.

Illustration:
X <---- this is where the content* in question (column 4) ends up.
[Column 1][Column 2][Column 3][Column 4][Column 5]



*<td class='td1'>" . round(display_price($currency_from, $currency_to, $row[$price]) , -1) . "</td>

Browser: Safari, Firefox and Chrome, (may also be in others but my current computer does not have any other browser on it at the moment).
Chris_123K is offline
Reply With Quote
View Public Profile
 
Old 12-30-2010, 07:04 AM Re: The Table Mystery
Junior Talker

Posts: 2
Name: Gav
Trades: 0
Have you tried a different CSV file, perhaps the current one is corrupted and the code isn't to blame- I didn't read the code though.
therealgl is offline
Reply With Quote
View Public Profile
 
Old 12-30-2010, 08:42 AM Re: The Table Mystery
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I can't seem to spot it from the PHP code you've posted, but the problem on the client-side is that the HTML is coming out like this:

HTML Code:
</tr>
0 USD<tr class='tr2'>
No text should appear between the table rows. Text should always appear within the TD elements. Therefore the browser is just sticking this text up above the tabular data because there is no standard way to respond to this sort of malformed HTML.

It's somewhat baffling based on the information you're giving us, however, as I don't see anything in your code that indicates output in that area. Are you sure this is all of the relevant code? Is there something else that is doing replacement on the text? Did you write all this code, or are you working on someone else's code?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-30-2010, 08:51 AM Re: The Table Mystery
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Ok, I think I figured it out. in the function "display_price" there is this line:

PHP Code:
echo $exchange_rate*$figure ' ' $currency_to
Change this to:
PHP Code:
return $exchange_rate*$figure ' ' $currency_to
You're using this function as a concatenation, which means it should be returning a value, not echoing it, which must be why it's giving these ususual results.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-30-2010, 07:32 PM Re: The Table Mystery
Chris_123K's Avatar
Super Talker

Posts: 128
Name: Chris Kummelstedt
Trades: 0
Thank you so much,

6-7 minutes?

I declare you a genius,
Chris_123K is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to The Table Mystery
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25306 seconds with 12 queries