Dynamic Dropdown option in a list with image - php

I was trying get Dropdown option result in a list with respective image, but that gives other than picture...here is my partial codes, any suggestion Bro?
<?php
$university=$_GET['university'];
$sql=mysql_query("SELECT univ FROM university WHERE univ='$university'");
while($row=mysql_fetch_assoc($sql)){
?>
<li>
<select>
<option value='<?php echo $row['univ'] ;?>'>
<?php echo $row['univ'] ;?> <?php echo '<img src=abu.png width:"20"height="20">';?>
</option>
</select>
</li>
<?php
}
?>

As the comments already said, your code formation is not correct. See example below for the right formation. Also a note: DONT use mysql_* anymore because it's deprecated, use mysqli_* or PDO.
<?php
$university=$_GET['university'];
$sql=mysql_query("SELECT univ FROM university WHERE univ='$university'");
?>
<select>
<?php
while($row=mysql_fetch_assoc($sql)){
?>
<li>
<option value='<?php echo $row['univ'] ;?>'>
<?php echo $row['univ'] ;?> <?php echo '<img src=abu.png width:"20"height="20">';?>
</option>
</li>
<?php
}
?>
</select>

Related

How to create custom attribute to be a child of other attribute as dropdown catalog input type

I'm trying to create something like part finder (product finder).
I was thinking to edit layered navigation.
So now I have drop-boxes instead of list using this code for
app/design/frontend/default/carpoint/template/catalog/layer/filter.phtml
<select onchange="setLocation(this.value)">
<?php $count = 0; ?>
<?php foreach ($this->getItems() as $_item): ?>
<?php $count++; ?>
<?php if($count == 1): ?>
<option value='' disabled selected style='display:none;'>Choose <?php echo $attribute_code = $_item->getFilter()->getName();?> </option>
<?php endif; ?>
<option <?php if ($_item->getCount() > 0): ?> value="<?php echo $this->urlEscape($_item->getUrl()) ?>">
<?php echo $_item->getLabel() ?> <?php else: echo '>' . $_item->getLabel() ?> <?php endif; ?> (<?php echo $_item->getCount() ?>) </option>
<?php endforeach; ?>
</select>
How can I edit custom attribute eg "Type" so he is associated with parent attribute eg "Brand".
I something like this:

ZF2 form formatting?

I am using ZF2 and have a form which defines a bunch of elements, and then I render it in my phtml like this:
<?php
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formlabel($form->get('description'));
echo $this->formRow($form->get('radioButton'));
echo $this->form()->closeTag();
?>
Which draws a label and a radio button.
My question is how can I then format these elements to my liking? For example make the radio buttons displayed horizontally rather than vertically and maybe change the location of the label.
There's nothing stopping you from formatting them as you have there, you could put the elements inside a list, or andd any additional markup you want to style as you wish.
<?php
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
?>
<ul class="form-list">
<li>
<div class="form-control">
<?php echo $this->formlabel($form->get('description')); ?>
<?php echo $this->formElementErrors($form->get('description')) ?>
<?php echo $this->formElement($form->get('description')); ?>
</div>
<div class="form-control">
<?php echo $this->formlabel($form->get('radioButton')); ?>
<?php echo $this->formElementErrors($form->get('radioButton')) ?>
<?php echo $this->formElement($form->get('radioButton')); ?>
</div>
</li>
</ul>
<?php echo $this->form()->closeTag() ?>
If you wanted to have control over the actual elements/inputs themselves you could do something like this:
<label>
<?php echo $form->get('radioButton')->getLabel() ?>
<input class="bob" type="radio"
name="<?php echo $form->get('radioButton')->getName() ?>"
value="<?php echo $form->get('radioButton')->getValue() ?>"
/>
</label>

How to hide php echo in a dropdown menu?

I have a drop down box that shows the weight of the item and how much extra the heavier items cost. I also have javascript that updates the price on the page based on the value selected in the dropdown. Since the javascript updates the price shown on the page, I would like to remove the additional price shown next to the option choices.
the code is:
<?php if ($options) { ?>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'select') { ?>
<span id="option-<?php echo $option['product_option_id']; ?>" class="option">
<select name="option[<?php echo $option['product_option_id']; ?>]">
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><span id="newPrice"><?php echo $option_value['price']; ?></span>)
<?php } ?>
</option>
<?php } ?>
</select>
</span>
I only want to show the product_option_id in the drop down, I don't want to show the added price for increases; I don't want this part of the code to be visable:
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><span id="newPrice"><?php echo $option_value['price']; ?></span>)
<?php } ?>
however, I have some javascript that updates price based off the $option_value['price']. So I can't just erase it.
Is there a way to keep the output from echoing onto the screen, but still have javascript be able to find it?
Yes:
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><span style="display:none" id="newPrice"><?php echo $option_value['price']; ?></span>)
<?php } ?>
Also you should consider not using an ID on that span, unless you are generating a unique id for each one, as it will cause you problems when you try to grab it with document.getElementById()

Brand wise searching in product orderer report

I am trying to extend product order
report and add one Attribute of
product brand and put into
grid.phtml.
when i select brand and click on
refresh button.
report will not display brand wise
searching what can i do?
product order report image link
Visit
http://imageshack.us/photo/my-images/405/productorder.jpg/
grid.phtm Code
<?php
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
->setCodeFilter('brand')
->getFirstItem();
$attributeOptions = $attributeInfo->getSource()->getAllOptions(false);
?>
</div>
--><div class="f-left">
<?php echo $this->__('Brand') ?>:
<select name="brand" id="brand" style="width:6em;">
<?php foreach ($attributeOptions as $_value=>$_label): ?>
<option value="<?php echo $_value ?>" <?php if($this->getFilter('brand')==$_value): ?> selected<?php endif; ?>><?php echo $_label['label'] ?></option>
<?php //error_log("Lable".print_r($_label,TRUE));?>
<?php endforeach; ?>
</select>
</div>

Dynamically populating an UnOrdered List

I am attempting following code to populate an UnOrdered List dynamically. The same type of code I am successfully using to populate a DropDown. But when I changed the tags to UnOrdered List, it is not working. When run, it just displays some tags instead of the actual output.
Where is the error:
<?php
require("dbconnection.php");
require("dbaccess.php");
$divName = $_GET['DivName'];
$ulName = $_GET['ControlName'];
$query = $_GET['SqlQuery'];
echo $query;exit;
dbconnection::OpenConnection();
$result = dbaccess::GetRows($query);
?>
<ul id="<?php echo $ulName; ?>" name="<?php echo $ulName; ?>">
<?php while($row=mysql_fetch_array($result))
{ ?>
<li><?php echo $row[1]; ?>"></li>
<?php } ?>
</ul>
The code that I used to populate a DropDown is below: It works absolutely fine:
<?php
require("dbconnection.php");
require("dbaccess.php");
$dropdownControlName = $_GET['DropDownControlName'];
$query = $_GET['SqlQuery'];
dbconnection::OpenConnection();
$result = dbaccess::GetRows($query);
?>
<select id="<?php echo $dropdownControlName; ?>" name="<?php echo $dropdownControlName; ?>">
<option>Select from the list</option>
<?php while($row=mysql_fetch_array($result))
{ ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>
<?php } ?>
</select>
The error is here:
<li><?php echo $row[1]; ?>"></li>
should be this:
<li><?php echo $row[1]; ?></li>
Don't know Php but what this line doing :
echo $query;exit;
Are you sure that you have to use the second field of the result set?
<li><?php echo $row[1]; ?>"></li>
There is an extra >" there.
Can you show us the resulting html code ?
SORRY: I was away from the PC for some minutes before posting, just saw that I answered the same as the following answer.
HI,
I used your code and gave some constant values and i got the following out put.
Out Put:
1">
2">
3">
4">
Used code:
`
">
`
and final Conclusion is, this prints the unordered list and i think yo may check your
echo $row[1]; part for any html out puts.
Note: "> This tag comes because of in your code having this value

Categories