Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Linking PHP to Javascript


Message #1 by "Peter White" <apis@g...> on Wed, 7 Aug 2002 20:23:17
Hi Nik

Yes, the echo statements were just a debugging exercise.  I'll investigate
your suggestions and I may see you in the PHP forum!

Very many thanks

PJ


----- Original Message -----
From: "Nikolai Devereaux" <yomama@u...>
To: "JavaScript HowTo" <javascript_howto@p...>
Sent: Wednesday, August 07, 2002 8:29 PM
Subject: [javascript_howto] RE: Linking PHP to Javascript


>
> This is more a PHP question... in the future, you might get try asking in
> one of the PHP forums.
>
> That said, you're going about things a little awkwardly..  try using
while()
> instead of for(), and use mysql_fetch_array() instead of mysql_result().
>
>
> I don't think the column names are case sensitive, but you're selecting
the
> 'xref' and 'yref' columns, but trying to get the data out of 'xRef' and
> 'yRef'.  Make sure the column names in your PHP code match the column
names
> in your DB.
>
> I don't know if you're echoing the values to the client as a debugging
> purpose, but there's no whitespace between your echo statements.  That's a
> problem.
>
> Suppose $sitename2 is "hello", $sitename3 is "world", and $siteID is
> "nikolai".
>
> Your echo statements would produce this output:
>
> XRef: helloYRef: worldsiteID: nikolai
>
>
> Lastly, each time you iterate through the loop, you're overwriting the
value
> of $sitename2 and $sitename3, so really the only xref and yref values you
> have are from the last row returned from the database.
>
> If you're not echoing your results to the client directly, you'll want to
> use array(s) to store the values to use later; that way you're not
throwing
> away the data you just received the last iteration of the loop.
>
>
>
> Here's an example of using while() with fetch_array():
>
>
> if($result)
> {
>     while($row = mysql_fetch_array($result)
>     {
>         $xref = $row['xref'];
>         $yref = $row['yref'];
>     }
> }
>
>
> hope this helps,
>
> Nik
>
>
> p.s.  see you on pro_php, beginning_php, php_howto, and/or
> php_configuration!
>
>
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
>


  Return to Index