I'm really a beginner in php. We are having a thesis and my project was web based voting system for student. Here's my problem. I have to add a partylist that will automatically put in the select(option). What would be the codes. Please I'm begging you to help me Please.
Insert my data in option(select) or combobox to other programming language in php
Collapse
X
-
Really!!! this is how you are going to study, by asking other people to do your research. You could just Google the php manual online.
What other language do you want to put the option list. I suspect you are trying to create a HTML list box.
By now you should have learned how to drop in and out of php/HTML when streaming out your code.
1. php runs only on the web server.
2. HTML and javaScript only runs on the client (user's) computer.
3. when executing php code you surround the code with <?php ?> tags
notice the <?php echo .... ?> tags where the option value and text are inserted into the HTML code.
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <?php //put some php code here to connect to server and get the data you want. ?> <!-- now you are streaming HTML code --> <html> <head> </head> <body> <select name="aListBox"> <?php //now you are inserting php code into your HTML page //make some kind of loop to repeat each option in your list //or if you don't know how to do that just make one option line for each of your choices foreach ($your_Array_Of_Values as $each_Value_In_The_Array) { ?> <option value="<?php echo $each_Value_In_The_Array?>"><?php echo $each_Value_In_The_Array?></option> <?php } unset($each_Value_In_The_Array); ?> </select> </body> </html>
Comment