You are here: Re: Please help to migrate to PHP from Baserunner.com « PHP Programming Language « IT news, forums, messages
Re: Please help to migrate to PHP from Baserunner.com

Posted by Jerry Stuckle on 05/17/07 18:12

Robertu wrote:
> Hi at all
> It is very difficult for me write in english my qiestions therefore please
> sorry my bad english and try to understand best.
> I have html code that display some datas coming from a dbf file throught
> Baserunner.cgi (see baserunner.com)
> Now I try to mifrate to php
> Therefore first I transformed my databases to mysql and they work well.
> Now I must transform an html page that must dispkay datas from mysql table.
> To try if my code work I must insert with php the mysql fields values into
> my php page that is like this:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> </HEAD>
> <BODY>
> <?php
> /* Connessione e selezione del database */
> $connessione = mysql_connect("00.00.00.00..00", "1111111", "2345678")
> or die("Connessione non riuscita: " . mysql_error());
> mysql_select_db("Sql144961_1") or die("Selezione del database non
> riuscita");
> /* Esecuzione di una query SQL */
> $query = "SELECT sub_tipo, nome, pub, memo, img FROM fs where sub_tipo like
> '%di feltro rosso%'";
> $risultato = mysql_query($query) or die("Query fallita: " . mysql_error() );
> /* Stampa dei risultati in HTML */
> echo "<table border=3><caption>";
> $riga = mysql_fetch_array($risultato, MYSQL_NUM);
> printf ($riga[0]);
> printf ("</caption");
> while ($riga = mysql_fetch_array($risultato, MYSQL_NUM))
> {
> HERE THERE IS A TABLE TO DISPLAY FIELDS VALUES
> BUT THERE IS ALSO A JAVASCRIPT FUNCTION WHERE I MUST PASS WITH PHP A
> PARAMETER LIKE:
> <script type="text/javascript">
> document.writeln("<form onSubmit='return false;'><input type='hidden'
> name='Codice' value='$riga[1]'><input type='hidden' name='Description'
> value='$riga[2]'><input type='hidden' name='Price' value='$riga[3]}'><input
> type='hidden' name='Size' value=''><input type='hidden' name='Color'
> value=''><INPUT type='text' size=4 maxlength=4 name='Qty' onFocus=select()
> onChange='Control(this.form)' value='"+fust($riga[1])+"'></form>");
> </script>
> }
> echo "</table>";
> /* Liberazione delle risorse del risultato */
> mysql_free_result($risultato);
> /* Chiusura della connessione */
> mysql_close($connessione);
> ?>
> </BODY>
> </HTML>
>
> How can I do to insert javascript code into the while PHP loop and to insert
> into the javascript code the field value from mysql table PLEASE?
> Thank you very much in advance
>
>

Robertu,

PHP doesn't call javascript - PHP is server side and javascript is
client-side. But you can use PHP to create your javascript. For
instance, you could echo the entire javascript:

echo "<script type=\"text/javascript\">" .
"document.writeln(\"<form onSubmit='return false;'>" .
"<input type='hidden' name='Codice' value='$riga[1]'>" .
"<input type='hidden' name='Description' value='$riga[2]'>" .
"<input type='hidden' name='Price' value='$riga[3]}'>" .
"<input type='hidden' name='Size' value=''>" .
"<input type='hidden' name='Color' value=''>" .
"<INPUT type='text' size=4 maxlength=4 name='Qty' onFocus=select() " .
"onChange='Control(this.form)' " .
"value='\"+fust($riga[1])+\"'></form>\"); " .
"</script>";

Or, maybe better to your liking, you can put the plain javascript in
there and substitute your PHP values in it, i.e.

?>
<script type="text/javascript">
document.writeln("<form onSubmit='return false;'>
<input type='hidden' name='Codice' value='<?php echo $riga[1];?>'>
<input type='hidden' name='Description' value='<?php echo $riga[2];?>'>
<input type='hidden' name='Price' value='<?php echo $riga[3];?>}'>
<input type='hidden' name='Size' value=''>
<input type='hidden' name='Color' value=''>
<INPUT type='text' size=4 maxlength=4 name='Qty' onFocus=select()
onChange='Control(this.form)' value='"+fust(<?php echo $riga[1]'?>)+"'>
</form>");
</script>

Hope this gives you some ideas.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация