Reply to Re: I guess there is a way to make a function out of this but i don't know how :)

Your name:

Reply:


Posted by Tyrone Slothrop on 10/12/91 11:29

On Sat, 15 Oct 2005 14:49:47 +0200, none <""neri\"@(none)"> wrote:

>As i said... I have several calls to the same "action" which i guess
>could be resolved as a function: but i'm learning and i have no idea how
>to do that.
>
>I post the code, extremely boring i suppose. It's in italian, but it
>shouldnt make such a difference, right?
>
>The idea is that of making a form where the select options are taken
>straight out of a mysql table, actually, a single column.
>

You can do something like this:

function options ($table, $field) {
$qy = "SELECT $field FROM $table";
$rs = mysql_query ($qy) or die (mysql_error());
while ($r = mysql_fetch_array($rs)) { ?>
<option value="<?=$r[0]?>">$r[0]?></option>
?> }
}

This way you can just pass the field and table to the function and
display the results for all of your options.

[Back to original 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

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