This topic is locked

how to integrate php code into the add page?

2/17/2009 6:52:52 PM
PHPRunner General questions
D
Darkwoods author

hello i was hoping someone can help me with this...
i want to integrate a php code into the add and edit page and i want it to work normaly on phprunner

here is the code

echo '

<SELECT MULTIPLE value="multiselect" name="category">

<option value="" disabled="disabled"> - select category - </option>

';



$dbquery2 = mysql_query("SELECT * FROM specialty_categories");

while ($dbrow2 = mysql_fetch_array($dbquery2))

{

$id1 = $dbrow2['id'];

$catname = $dbrow2['catname'];

echo '<option value=" '. $id1 .' "disabled="disabled">'. $catname . '</option>';
$dbquery = mysql_query("SELECT * FROM specialty where speccat = $id1 ORDER BY name;");
while ($dbrow = mysql_fetch_array($dbquery))

{

$id = $dbrow['id'];

$name = $dbrow['name'];



echo ' <option value="' .$id .'">&nbsp;&nbsp;&nbsp;&nbsp;' . $name .'</option> ';

}

}
echo '</SELECT>';


the code is to be able to select multi sub-categories from different parent-categories

D
Darkwoods author 2/18/2009

i worked it out thx u

D
Darkwoods author 2/18/2009

i only have one problem when i go back to the edit page the fields are not selected how can i do that?
Thanks

J
Jane 2/19/2009

Hi,
you need to select records from database and mark it as selected in the dropdown.

echo ' <option value="' .$id .'" selected>&nbsp;&nbsp;&nbsp;&nbsp;' . $name .'</option> ';

D
Darkwoods author 2/19/2009

Hi,

you need to select records from database and mark it as selected in the dropdown.



could you or anyone tell me how to do that please?

(the code is added in different table page)
here is my code:

echo '<input type=hidden name="type_specialitydoc" value="multiselect">

<select size = "15" id="value_specialitydoc" name="value_specialitydoc[]" multiple >

';



$dbquery2 = mysql_query("SELECT * FROM specialty_categories");

while ($dbrow2 = mysql_fetch_array($dbquery2))

{

$id1 = $dbrow2['id'];

$catname = $dbrow2['catname'];

echo '<optgroup label="'. $catname . '">';



$dbquery = mysql_query("SELECT * FROM specialty where speccat = $id1 ORDER BY name;");
while ($dbrow = mysql_fetch_array($dbquery))

{

$id = $dbrow['id'];

$name = $dbrow['name'];



echo ' <option value="' .$id .'" selected>&nbsp;&nbsp;&nbsp;&nbsp;' . $name .'</option> ';

}

}
echo '</SELECT>';
D
Darkwoods author 2/20/2009

come on guys nobody can help me with this?

how can i make this code work in the edit page
your help would be great