So what i'am trying to do is that I have a PHP page that gets the ID for some text stored in a database (Varchar) and I wish to display this content in my HTML page. So I can update the content in the database and the edit take effect across the site.
PHP:
$id = $_GET['id'];
// do some validation here to ensure id is safe
$link = mysql_connect("localhost", "root", "");
mysql_select_db("images");
$sql = "SELECT review FROM reviews WHERE id=$id";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
echo $row['review'];
I wish to display the content where is says "PHP content here"
HTML:
<div class="modal fade" id="albumModal1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Top right close X -->
<div class="close-modal" data-dismiss="modal">
<span class="glyphicon glyphicon-remove"</span>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<p class="modalTitle">The Beatles: Abby Road</p>
<img src="beatles.jpg" class="img-responsive center-block albumImgGrey">
<!-- Album 1's Review -->
<div class="modalText">
<p>Content upon content upon more content
<p>upon more content</p>
Content upon content upon more content
<p>upon more content</p>
<div class="starcolor">
<span>★ ★ ★ ★ ★</span>
</div>
</p>
<!-- PHP content here....... -->
<!-- PHP content here....... -->
<!-- Bottom of the review links -->
<ul class="list-inline item-details">
<li>
Year of release: <strong>3000</strong>
</li>
<li>
Previous Album: <strong>Hippie tree</strong>
</li>
<li>
Following Album: <strong>Backup Plus++</strong>
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Any help or advice would be greatly appreciated.
Add this code:
<?php echo $row['review'];?>
where you have PHP content here, ensure you include the PHP tags.
STOP USING THE MYSQL EXTENSION, A KITTEN AND TWO PUPPIES DIE ANYTIME YOU DO THIS
Learn pdo or mysqli instead.
You can put your database result in a php file and then Web server will parse that php code and generate the required output.
It should be like.
output.php
<?php
<div class="modal fade" id="albumModal1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Top right close X -->
<div class="close-modal" data-dismiss="modal">
<span class="glyphicon glyphicon-remove"</span>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<p class="modalTitle">The Beatles: Abby Road</p>
<img src="beatles.jpg" class="img-responsive center-block albumImgGrey">
<!-- Album 1's Review -->
<div class="modalText">
<p>Content upon content upon more content
<p>upon more content</p>
Content upon content upon more content
<p>upon more content</p>
<div class="starcolor">
<span>★ ★ ★ ★ ★</span>
</div>
</p>
<!-- PHP content here....... -->
$id = $_GET['id'];
$link = mysql_connect("localhost", "root", "");
mysql_select_db("images");
$sql = "SELECT review FROM reviews WHERE id=$id";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
echo $row['review'];
<!-- PHP content here....... -->
<!-- Bottom of the review links -->
<ul class="list-inline item-details">
<li>
Year of release: <strong>3000</strong>
</li>
<li>
Previous Album: <strong>Hippie tree</strong>
</li>
<li>
Following Album: <strong>Backup Plus++</strong>
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
?>
<div class="modal-dialog"> <div class="modal-content"> <!-- Top right close X --> <div class="close-modal" data-dismiss="modal"> <span class="glyphicon glyphicon-remove"</span> </div> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2"> <div class="modal-body"> <p class="modalTitle">The Beatles: Abby Road</p> <img src="beatles.jpg" class="img-responsive center-block albumImgGrey"> <!-- Album 1's Review --> <div class="modalText"> <p>Content upon content upon more content <p>upon more content</p> Content upon content upon more content <p>upon more content</p> <div class="starcolor"> <span>★ ★ ★ ★ ★</span> </div> </p> <!-- PHP content here....... --> <!-- PHP content
<?php echo $row['content']; ?>
here....... --> <!-- Bottom of the review links --> <ul class="list-inline item-details"> <li> Year of release: <strong>3000</strong> </li> <li> Previous Album: <strong>Hippie tree</strong> </li> <li> Following Album: <strong>Backup Plus++</strong> </li> </ul> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </div> </div> </div>
Related
I am using the LiveWire Media component.
Here is my component called in blade file.
Below component called on page load.
<div class="form-group">
<livewire:media title="Browse Image" name="media_image_id" type="select" :options="['image']" :selectedMedias="$course->mediaImage ?? null" :unique-key="$unique_key" :table="$table" id="media_image"/>
</div>
After that on button click one form opened called testform.
In that form below code is written.
<div class="form-group">
<livewire:media title="Browse Image" name="lesson_media_image_id" type="select" :options="['image']" :selectedMedias="$lesson->mediaImage ?? null" :unique-key="$unique_key" :table="$tab" id="lesson_media_image"/>
</div>
Media.blade.php
#section('title','Media')
<div>
<div>
#foreach($selectedMedias as $selectedMedia)
<input type="hidden" name="{{$name}}" value="{{$selectedMedia->id}}" id="{{$name}}"/>
<div class="row">
<div class="col-6">
<div class="card">
#switch($selectedMedia->collection_name)
#case('images')
<img src="{{$selectedMedia->getUrl()}}" class="img-fluid rounded float-left"
alt="{{$selectedMedia->name}}"
style="max-height: 150px;"/>
#break
#endswitch
<div class="card-body">
<h6 class="card-title">
<div>{{$selectedMedia->name}}</div>
</h6>
</div>
</div>
</div>
</div>
#endforeach
</div>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mediaModal-{{$name}}">
{{$title}}
</button>
<!-- The Modal -->
<div class="modal fade" id="mediaModal-{{$name}}">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h5 class="modal-title">Media Library</h5>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<!-- Nav pills -->
<ul class="nav nav-pills mb-2">
#if(in_array('image',$options))
<li class="nav-item">
<a class="nav-link {{$options[0]==='image'?'active':''}}" data-toggle="pill"
href="#image-show">
All Images
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#image-upload"
data-url="{{route('media.upload',['uniqueKey' => $uniqueKey,'table'=>$table,'tenant'=>tenantName()])}}">
Upload Image
</a>
</li>
#endif
</ul>
<!-- Tab panes -->
<div class="tab-content">
#if(in_array('image',$options))
<div class="tab-pane container {{$options[0]==='image'?'active':''}}" id="image-show">
<livewire:media.show-images :type="$type" :select="$select" :name="$name"/>
</div>
<div class="tab-pane container fade" id="image-upload">
<livewire:media.upload-images/>
</div>
#endif
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Now problem is when on page load component is called modal is open and can select and upload image.
When I comment on page load component at that time I able to active upload button tab, but unable to open or drag and drop image as well as strore in database.
when form is show above component is called modal is also open but when click on upload tab it will show selected but upload form is not become active also image is also not able to select from all images.
Good day. In my Laravel App, I have a foreach loop where I display all products. I also have a quickview modal where users can view the products without loading a new page. Furthermore, I am using owlcarousel.js to display the products. Unfortunately, owl.carousel breaks the bootstrap modal unless the modal is placed outside the owl.carousel. But, since the products are loaded on the page dynamically, I can't access the ids of the modals outside the owl carousel div which encompasses the loop.
The $modal_id variable is only returning the last Id in the loop. So, please what is the way out?
How can I access the individual ids within the loop from on click from outside
The code is shown below
<div class="product owl-carousel">
<?php $modal_id = 0; ?>
#foreach($new_arrivals as $new_arrival)
<div class="pro">
<div class="pro-img">
<?php $modal_id = $new_arrival->id?>
<span class="sticker-new">new</span>
<div class="quick-view-pro">
<a data-toggle="modal" data-target="#{{$modal_id}}" class="quick-view modal-view"
href="#{{$modal_id}}" rel="{{$new_arrival->id}}"></a>
</div>
</div>
</div>
#endforeach
</div>
<!-- Modal is shown below !-->
<div class="product-view">
<div class="container">
<div class="modal fade" id="{{$modal_id}}">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="row">
</div>
</div>
<!-- Modal footer -->
</div>
</div>
</div>
</div>
</div>
Try this code:
<div class="product owl-carousel">
<?php $modal_id = 0; ?>
<?php $modal_ids = []; ?>
#foreach($new_arrivals as $new_arrival)
<div class="pro">
<div class="pro-img">
<?php $modal_id = $new_arrival->id?>
<?php $modal_ids[] = $new_arrival->id ?>
<span class="sticker-new">new</span>
<div class="quick-view-pro">
<a data-toggle="modal" data-target="#{{$modal_id}}" class="quick-view modal-view"
href="#{{$modal_id}}" rel="{{$new_arrival->id}}"></a>
</div>
</div>
</div>
#endforeach
</div>
<!-- Modal is shown below !-->
#foreach($modal_ids as $item)
<div class="product-view">
<div class="container">
<div class="modal fade" id="{{$item}}">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="row">
</div>
</div>
<!-- Modal footer -->
</div>
</div>
</div>
</div>
</div>
#endforeach
Hope help you.
I have a problem,
When I tried to list all users, to get their username/and others script didn't continue to read anything, it has stopped just after my echo input.
So when I put echo to get user's info it reads that input but it doesn't read anything after. See bellow there is a echo called 'userEmail' and it reads it with no problems but it doesn't go after signature. Now I have checked any everything works when i put it on a plain page but for some reason it stop readsing here. I'm a newbie in this PHP so yeah. :)
<?php
$query = mysql_query("SELECT userEmail FROM users");
while($userRow= mysql_fetch_array($query)){
echo '<div class="col-md-4">
<!-- Widget: user widget style 1 -->
<div class="box box-widget widget-user">
<div class="widget-user-header bg-blue" style="background-color: center center;">
</div>
<div class="widget-user-image">
<img alt="User Avatar" class="img-circle" src="//">
</div>
<div class="box-footer">
<div class="row">
<div class="col-sm-4 border-right">
<div class="description-block">
</div>
<!-- /.description-block -->
</div>
<!-- /.col -->
<div class="col-sm-4 border-right">
<div class="description-block">
<h5 class="description-header">'.$userRow['userEmail'];'</h5>
<h5 class="description-text">'.$userRow['userSignature'];'</h5>
</div>
<!-- /.description-block -->
</div>
<!-- /.col -->
<div class="col-sm-4">
<div class="description-block"></div>
<!-- /.description-block -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
</div>
<!-- /.widget-user -->
</div>
<!-- /.col -->
</div>';
}
?>
You're ending your echo with a ;. You need to concatenate the string with a . instead:
<h5 class="description-header">'.$userRow['userEmail'];'</h5>
<h5 class="description-text">'.$userRow['userSignature'];'</h5>
This should be:
<h5 class="description-header">'.$userRow['userEmail'].'</h5>
<h5 class="description-text">'.$userRow['userSignature'].'</h5>
in
'.$userRow['
quates are conflict with together
change ' and " with together in all lines of your script
and then :
".$userRow['userEmail']."<
be sure will be ok
<?php include "$_SERVER[DOCUMENT_ROOT]/new/stations/includes/header.php"; ?> /* HEADER */
<div class="content">
<div class="content-padded">
<!-- radio name -->
<h3 class="text-center"> Akwaaba Radio </h3>
<!-- end radio name -->
<!-- start station logo -->
<div class="img-middle">
<img src="img/Akwaaba.png" alt="cmon" width="200px"> /* Station IMAGE*/
</div>
<!-- End Logo -->
<!-- Player -->
<div class="audio-player">
<p>Click the button ( <i class="fa fa-play"></i> ) to play</p>
<audio src="http://149.255.33.74:8002/;.mp3" controls="yes"></audio>
</div>
<!-- End Player -->
<!--
=================
navigation button
=================
-->
<div class="spacer"></div>
<div class="text-center">
<?php include "$_SERVER[DOCUMENT_ROOT]/new/stations/includes/toggle.php"; ?>
</div>
<div class="spacer"></div>
<!--
=================
navigation button
=================
-->
<h4>About :-</h4>
<!-- Station details -->
<div class="well">
001 (703) 395-0534
</div>
<!-- End Detials -->
<center>
<a class=" space-btn btn btn-facebook"><i class="fa fa-facebook"></i> | Share on Facebook</a>
<a class=" space-btn btn btn-twitter "><i class="fa fa-twitter"></i> | Tweet on Twitter</a>
<a class=" space-btn btn btn-google-plus "><i class="fa fa-google"></i> | Share on google+</a>
<div class="spacer"></div>
</center>
<!-- Adsense -->
<img src="http://www.hdwallpapers.in/walls/optimus_prime_hd-HD.jpg" width="100%">
<!-- End Adsense -->
<!-- Phone Number -->
<a href="tel:001 (703) 395-0534" class="btn btn-positive btn-block space-btn">001 (703) 395-0534
<br>
<small>Station Hotline</small>
</a>
<!-- End Number -->
<div class="btm-spc"></div>
</div>
</div>"
<?php include "$_SERVER[DOCUMENT_ROOT]/new/stations/includes/footer.php"; ? >
In the above code image won't load at the first load. The page must refresh in order to load the image correctly.
In desktop browsers the image does load at once but in mobile the Page must be refreshed to load the image.
Please Select the First Option
Replace
<img src="img/Akwaaba.png">
with
<img src="<?php echo$_SERVER[DOCUMENT_ROOT];?>/img/Akwaaba.png">
I'm using the following code on my site. You'll notice that there is a checkbox outside the form (Towards the bottom). I need the value of the checkbox called to send_mail.php without creating a second form, and without placing it inside the form element. Is this even possible with PHP? `
<h2>Search for your dream home<br />
and save now!</h2>
<legend>Which Areas are you interested in?</legend>
<div class="areas row-fluid" style="text-align:left !important;">
<div class='span5' style='margin-left:0px !important;'>
<label>
<input type="checkbox" name="arrayValue[]" id="area[0]" value="test" style='margin-top:-5px !important;'> test</label>
</div>
</div>
<input type="button" onclick="jQuery('#myModal').modal('show')" value="CONTINUE" />
</div>
</div>
</div>
<!--banner area end-->
<!--content area 1 start-->
<div id="content1">
<div class="content1_in"> <span>
<h2 style="line-height:40px;font-size:40px;padding-bottom:10px">SOME CONTENT
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/phone.png" alt="" />
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 1 start-->
<div id="content2">
<div class="content2_in"> <span> SOME CONTENT
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/ipad-img.png" alt="" />
<div class="key"></div>
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 3 start-->
<div id="content3">
<div class="content3_in"> <span>
SOME CONTENT
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/desktop-img.png" alt="" />
</div>
<div class="free"></div>
</div>
</div>
<!--content area 3 end-->
<div id="footer">
<div class="footer_in">
This Website Is Brought To You By: Test</div>
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade modal-survey" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel" class="survey_title">What type of home are you looking for?</h3>
</div>
<form method="post" class="form-horizontal" id="final_form" action="send_mail.php">
<input type="hidden" name="template" id="template" value="Buyers" />
<div class="modal-body" >
<div id="lead_info_1">
<div class="input select">
<div class=""></div>...
I would add a hidden input in your form.
Then, just before your post, assign the of the hidden textbox with the value of the checkbox.
(using jQuery)