In hiddenModalContent div is it possible to display the database value as once thickbox is opening it just showing nothing
<?php
foreach($this->list_details as $key=>$details)
{?>
<div class="sc_content_subheading"><? echo $this->escape($details['list_name'])?></div>
<div id="hiddenModalContent" style="display:none;">
<span class="content_subheading">List name </span><? echo $details['list_name'];?><br/>
</div>
<?php }?>
It seems all you are only outputting the list name. What else in the array would you like to show?
Related
I have a loop in my view that outputs all the content gathered from the database:
<?php foreach($content as $contentRow): ?>
<?php
echo $contentRow->value;
?>
<?php endforeach; ?>
This works fine for HTML strings like:
<h2><strong>Example Text</strong></h2>
however I have some image content that I would like to display and I have tried the following database entries to no avail:
<img src="<?php echo site_url('pathToImage/Image.png'); ?>" alt="Cover">"
<img src="site_url('pathToImage/Image.png')" alt="Cover\">"
I feel like I am missing a step on how to use PHP values in this way.
How do I access the URL of the image and use that to show the image?
Full Code Edit
<?php
$CI =& get_instance();
?>
<div class="container">
<div class="row">
<div class="col-md-9">
<div class="col-md-2"></div>
<div class="col-md-20">
<!--<form class="form-center" method="post" action="<?php echo site_url(''); ?>" role="form">-->
<!-- <h2 class="">Title</h2>
<h2 class=""SubTitle/h2>-->
<?php echo $this->session->userdata('someValue'); ?>
<!--//<table class="" id="">-->
<?php foreach($content as $contentRow): ?>
<tr>
<td><?php
echo $contentRow->value;
?></td>
</tr>
<?php endforeach; ?>
<!--</table>-->
<!--</form>-->
</div>
<div class="col-md-2"></div>
</div>
</div>
</div><!-- /.container -->
and the values are being read out in $contentRow->value;
I have to verify this, but to me it looks like you are echo'ing a string with a PHP function. The function site_url() is not executed, but simply displayed. You can execute it by running the eval() function. But I have to add this function can be very dangerous and its use is not recommended.
Update:
To sum up some comments: The use of eval() is discouraged! You should reconsider / rethink your design. Maybe the use of tags which are replaced by HTML are a solution (Thanks to Manfred Radlwimmer). Always keep in mind to never trust the data you display, always filter and check!
I'm not going to accept this answer as #Philipp Palmtag's answer helped me out alot more and this is more supplementary information.
Because I'm reading data from the database it seems a sensible place to leave some information about what content is stored. In the same table that the content is stored I have added a "content type" field.
In my view I can then read this content type and render appropriately for the content that is stored. If it is just text I can leave it as HTML markup, images all I need to do is specify the file path and then I can scale this as I see fit.
I have updated my view to something akin to this and the if/else statement can be added to in the future if required:
<?php foreach($content as $contentRow): ?>
<?php if ($contentRow->type != "image"): ?>
<?php echo $contentRow->value; ?>
<?php else: ?>
<?php echo "<img src=\"".site_url($contentRow->value)."\">"; ?>
<?php endif; ?>
<?php endforeach; ?>
I tried several options but they are not working, I have 2 pages, page.php and rating.php, on page.php, I have button with this link
< a href=”rating.php/go.php?id=$rows[$id]”>button</a>
, but on page rating.php I have a div with code.
<div id="review" ><?php echo $rows['id'];?></div>
I want that the $rows[$id]from the link rating.php/go.php?id=$rows[$id] could be displayed on div like this . How can I do that to see this $rows[$id] on div?
On page.php you are using < a href="rating.php?id=$rows[$id]">button</a>
If you want $rows[$id] in your rating.php use $_GET
<div id="review" ><?php echo $_GET['id'];?></div>
Read this tutorials too http://www.tutorialspoint.com/php/php_get_post.htm
you get a param from an url with that code snippet:
<div id="review"><?php echo $_GET['id']; ?></div>
the $row[$id] must be a value, it can't be an object
works as :
<div id="review"><?php echo $_GET['id']; ?></div>
Read this:
http://www.formget.com/php-post-get/
I' trying to pass the dropDownList selected value to this Dialog.
Any ideas on how I can do this?
I tried adding another parameter to the ajaxlink, using array('id'=>'showEventoDialog','tipoaux'=>$data["tipo"]), or only $data->tipo but can't seem to do what I want.
I'm also trying to get the value via $_GET from the Dialog form.
Here's my form and the Dialog link within the form
<?php echo $form->labelEx($model,'tipo'); ?>
<?php echo $form->dropDownList($model,'tipo',Lookup::items('Teste')); ?>
<?php echo $form->error($model,'tipo'); ?>
...
<?php echo $form->labelEx($model,'eventoid'); ?>
<div id="evento">
<?php echo $form->dropDownList($model,'eventoid',CHtml::listData(Evento::model()->findAll(),'id', 'designacao'),array('prompt'=>'Escolha','class'=>'required')); ?>
<?php echo CHtml::ajaxLink(Yii::t('evento','Novo Evento'),$this->createUrl('evento/addnewcom'),array(
'onclick'=>'$("#eventoDialog").dialog("open"); return false;',
'update'=>'#eventoDialog'
),array('id'=>'showEventoDialog'));?>
<div id="eventoDialog"></div>
</div>
Any ideas on how to do this?
Plus will the solution work with any other type of value, like textfield or something else on my form, so I can pass the values to dialogs BEFORE the parent form is submitted.
You can hook up some code to the open event of the dialog that will fire right before the dialog appears. In this code you can query the selected option and write it to the dialog:
<?php echo $form->labelEx($model,'eventoid'); ?>
<div id="evento">
<?php echo $form->dropDownList($model,'eventoid',CHtml::listData(Evento::model()->findAll(),'id', 'designacao'),array('prompt'=>'Escolha','class'=>'required')); ?>
<?php echo CHtml::ajaxLink(Yii::t('evento','Novo Evento'),$this->createUrl('evento/addnewcom'),array(
'onclick'=>'$("#eventoDialog").dialog({open: function(){ $("#selectedvalue").text($("#eventoid").val()); }}) .dialog("open"); return false;',
'update'=>'#eventoDialog'
),array('id'=>'showEventoDialog'));?>
<div id="eventoDialog">
<span>Selected value: </span><span id="selectedvalue" />
</div>
</div>
I have this While loop in my php code where I echo rows inside one div that acts like a button and when I press that "button" I want to hide/show the connected div with the jQuery function "toggle". I only get it to work so that when I click any of the "buttons" it opens all divs and not just that one that's connected.
<script>
$(document).ready(function(){
$(".scorec").click(function(){
$(".scorematcho").slideToggle('slow');
});
});
</script>
That's the jQuery I'm using at the moment.
<?php $RM = mysql_query("SELECT * FROM score ORDER BY ScoreID DESC LIMIT 3");
while ($ScoreD = mysql_fetch_assoc($RM)) {
$a = $ScoreD["ScoreOne"]; $b = $ScoreD["ScoreTwo"];?>
<div class="scorec" >
<?php if($a>$b){;?><font color="green"><?php }else{?><font color="red"><?php }?>
<div class="scorel"><img src="flags/<?php echo $ScoreD["FlagOne"]; ?>.png" style="float:left;">
<?php echo $ScoreD["TeamOne"]; ?> | <?php echo $ScoreD["ScoreOne"]; ?></div>
<div class="scorem">-</div>
<div class="scorer"><?php echo $ScoreD["ScoreTwo"]; ?> | <?php echo $ScoreD["TeamTwo"]; ?>
<img src="flags/<?php echo $ScoreD["FlagTwo"]; ?>.png" style="float:right;"></div></font>
</div>
<div class="scorematcho" >
<div class="scorematch">
de_dust2
16-2
</div>
<div class="scorematch">
de_nuke
16-2
</div>
<div class="scorematch">
de_dust
16-2
</div>
</div>
<?PHP } session_destroy()?>
That's the HTML/PHP I'm using. The div "scorec" is the "button" and "scorematcho" is the div I wan't to toggle.The text inside "scorematcho" shall be PHP also, just haven't changed it yet. I have searched and tested some things but can't get anything to work properly, I have noticed that some put all their PHP code inside an "echo", why is that and could that be the problem? Hope that's enough information, please tell if not. Also, if you have some other improvements you think I should make to the code, please tell.
I have added this jfiddle Hope it helps!! http://jsfiddle.net/H77yf/
$(".scorec").click(function(){
$(this).next().slideToggle('slow');
});
I am trying to load pictures from database to jquery slider
infact what is stored at database is the name of the picture
i implemented this code, it's working without errors but it showing me nothing at slider all is empty
<div id="slider">
<?php
while ($result = mysqli_fetch_object($banner)):
?>
<img src="images/banner/<? $banner['picture'];?>/" width="950" height="400"alt="" title="<strong><? echo $banner['title'];?></strong><span><? echo $banner['description'];?> </span>" />
<?php
endwhile
?>
</div>
name of the table at database is banner in which i have id(INT), picture(varchar 50) title(varchar(100), description(longblob)
query is working and returning number of selected rows
but nothing is shown
You need to echo the result rather than just use the variable...
<div id="slider">
<?php
while ($result = mysqli_fetch_object($banner)):
?>
<img src="images/banner/<?php echo $banner['picture'];?>" width="950" height="400" alt="" title="<strong><? echo $banner['title'];?></strong><span><?php echo $banner['description'];?></span>" />
<?php
endwhile;
?>
</div>