Computers & Internet Logo

Related Topics:

Posted on May 08, 2009

How to write a code of a combobox

Source code for inserting different types of properties in php

1 Answer

Anonymous

Level 1:

An expert who has achieved level 1.

Corporal:

An expert that has over 10 points.

Problem Solver:

An expert who has answered 5 questions.

  • Contributor 6 Answers
  • Posted on May 08, 2009
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

Corporal:

An expert that has over 10 points.

Problem Solver:

An expert who has answered 5 questions.

Joined: May 08, 2009
Answers
6
Questions
0
Helped
1137
Points
15

Hi,

Try this code:

Combo-BOX - Abstraction With function you can retrieve the combo-box
structure with its data
<?php
function GetCombo_Where($db, $nombre, $tabla, $campo_lista, $campo_graba,
$campo_seleccionado,$valor_seleccionado,$where)
{
$query="SELECT * FROM $tabla ";
$query.=($where)?"WHERE ".$where:"";
$db -> query ($query);
$cant_registros = $db -> num_rows ( );
$string = "<select name=".$nombre.">";
if ($seleccionado=="")
$string .="<option></option>";
for ($i=1;$i<=$cant_registros;$i++)
{
$db -> next_record ( );
$value = $db -> Record[$campo_graba];
if ($valor_seleccionado == $db -> Record[$campo_seleccionado])
$string .= "<option selected value = ".$value." >";
else
$string .= "<option value = ".$value." >";
$string .= $db -> Record[$campo_lista];
$string .= "</option>";
}
$string .= "</select>";
return $string;
}
?>
hope this helps.

Thanks
Shafi

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

127 views

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

ADMIN Andrew
ADMIN Andrew

Level 3 Expert

73813 Answers

ADMIN Eric
ADMIN Eric

Level 3 Expert

42247 Answers

Brad Brown

Level 3 Expert

19190 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...