sorry if this is a bit vague although I really don't know how to explain this one.
Basically I already have a listing page that lists all of the rows in my database into a html template that lists each row into an eCommerce style category page using PHP.
I am using this code for the listing page using PDO:
<?php while($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo '
<div class="listing-container">
<h3 class="model-listing-title clearfix">'.$row["Make"].' '.$row["Model"].' '.$row["Variant"].'</h3>
<h3 class="price-listing">£'.number_format($row['Price']).'</h3>
</div>
<div class="listing-container-spec">
<img src="'.(explode(',', $row["PictureRefs"])[0]).'" class="stock-img-finder"/>
<div class="ul-listing-container">
<ul class="overwrite-btstrp-ul">
<li class="diesel-svg list-svg">'.$row["FuelType"].'</li>
<li class="saloon-svg list-svg">'.$row["Bodytype"].'</li>
<li class="gear-svg list-svg">'.$row["Transmission"].'</li>
<li class="color-svg list-svg">'.$row["Colour"].'</li>
</ul>
</div>
<ul class="overwrite-btstrp-ul other-specs-ul h4-style">
<li>Mileage: '.number_format($row["Mileage"]).'</li>
<li>Engine size: '.$row["EngineSize"].'cc</li>
</ul>
<button href="#" class="btn h4-style checked-btn hover-listing-btn"><span class="glyphicon glyphicon-ok"></span> History checked
</button>
<button href="#" class="btn h4-style more-details-btn hover-listing-btn tst-mre-btn"><span class="glyphicon glyphicon-list"></span> More details
</button>
<button href="#" class="btn h4-style test-drive-btn hover-listing-btn tst-mre-btn"><span class="test-drive-glyph"></span> Test drive
</button>
<h4 class="h4-style listing-photos-count"><span class="glyphicon glyphicon-camera"></span> 5 More photos</h4>
</div>
';
} ?>
</div>
Now what I want to do is create a page for each of the SQL rows however I am unsure how I can do this, just like an eBay product page really.
My main question is what method could I do to create individual pages that are dedicated to each SQL row?
If anyone could shed a bit of light on this for me it would be much appreciated.
Knowing you can extract data from a page to another using $_POST['name-of-your-element'], I would say to do something like this :
Creating a php page dedicated to display information of one specific row
Putting some $_POST['...'] call to display the exact data
To do this, instead of just displaying your row in your actual page, you should create form for each row, and then adding a submit button for each row which will launch the "display row page" with the correct information. I would see something like this for each row :
<form method = "post" action = "displayData_Make.php">
<div id = "Make" name = "Make">
Make : <?php echo $row['Make'] ?>
</div>
<input type = "submit" value = "more information..." />
</form>
Then in you "displayData_Make.php" receive your information and display them like you want :
<?php
$info = $_POST['Make'];
// Do what you want with this data
// Display, etc...
?>
<!--
Some html code
-->
Related
Just wondering, I'm creating a multi-vendor website. So far it has all been going well, however we have a need to display icons as badges if a field contains data.
Here is an example of the code:
<li class="location clearfix">
<div class="pull-left">
<span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span>
</div>
<div class="pull-right">
<?php echo $abn; ?>
</div>
</li>
When displaying the field abn it appears fine, although we are wanting an icon displayed if abn contains data. We are needing the Echo to be an IF statement, that if the profile ``abn``` field contains data, that an icon is displayed.
Just wondering, is there any examples that anyone would have using an existing script?
Thanks for helping!
Try this,
add if condition with !empty()
<?php if(!empty($abn)) {?>
<li class="location clearfix">
<div class="pull-left">
<span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span>
</div>
<div class="pull-right">
<?php echo $abn; ?>
</div>
</li>
<?php } ?>
you can add this if condition wherever you want to hide or display data.
I am trying to figure out why my pagination stops working as soon as I apply it to a user model. Here is the scenario: I am making a website which is a note takes, a user can take notes save them and all that. On a page /notes all notes made can be seen used for me to see weather each user is able to save notes. Pagination works there without a problem. Once I made a user Dashboard and I show notes they made with their user id I get this error:
Method links does not exist
…\vendor\laravel\framework\src\Illuminate\Support\Traits\Macroable.php
96
I have no clue why this is happening. When I delete the code from view: {{$notebooks->links()}} - the error goes away and so does pagination. The moment I put it in the error happens all over again.
Here is the code from my view and controllers.
DashboardController:
public function index()
{
$user_id = auth()->user()->id;
$user = User::find($user_id);
$notebooks = DB::table('notebooks', $user->notebooks)->paginate(4);
return view('dashboard')->with('notebooks', $user->notebooks);
}
}
Dashboard View (with paginate links code):
#extends('layouts.app')
#section('content')
<!-- Main component for call to action -->
<div class="container text-center">
<!-- heading -->
<h1 class="pull-xs-left">Your Dashboard</h1>
<br>
<div class="pull-xs-right">
<a class="btn btn-primary" href="/notebook/create" role="button"> New Note +</a>
</div>
<div class="pull-xs-right">
<a class="btn btn-primary" href="/contacts/create" role="button"> New Contact +</a>
</div>
<div class="pull-xs-right">
<!--the dropdown menu -->
<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Sort Notebooks By
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="{{action('NotesController#ascendingId')}}">Note Number A - Z</a>
<a class="dropdown-item" href="{{action('NotesController#descendingId')}}">Note Number Z - A</a>
<a class="dropdown-item" href="{{action('NotesController#descendingTime')}}">Latest Time Posted</a>
<a class="dropdown-item" href="{{action('NotesController#ascendingTime')}}">Oldest Time Posted</a>
</div>
</div>
</div>
<div class="clearfix">
</div>
<br>
#if(count($notebooks) > 0)
#foreach ($notebooks as $notebook)
<div class="col-sm-3 col-md-3 col-sm-6">
<div class="card" style="width: 26rem;">
<div class="card-header" >
Client: {{$notebook->client_name}}
</div>
<div class="card-block" >
<h4 class="card-title " style="height: 5rem;"><strong><a href="/notebook/{{$notebook->id}}" >{{$notebook->name}}</a></strong></h4>
<p class="card-text" style="height: 7rem;">{{$notebook->note_description}}</p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"><b>Last Updated:</b> {{$notebook->updated_at->format('d-m-Y')}}</li>
<li class="list-group-item">
Edit Note
</li>
</ul>
<div class="card-block">
{!!Form::open(['action' => ['NotesController#destroy', $notebook->id], 'method' => 'POST'])!!}
{{Form::hidden('_method', 'DELETE')}}
{{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
{!!Form::close()!!}
</div>
</div>
</div>
#endforeach
</div>
<!-- /container -->
<hr>
<div class="container text-center">
{{$notebooks->links()}}
</div>
</div>
#else
<div>
<div class="col-lg-12 no-notes">
<p>No notes found, go ahead and make your first note! :)</p>
<a class="btn btn-primary" href="/notebook/create" role="button"> Make My First Note</a>
</div>
</div>
#endif
#endsection
Just a reminder this works perfectly without the user model. I am lost as how to fit it. Using Laravel 5.5.26.
Change the code to:
$notebooks = auth()->user()->notebooks()->paginate(4);
return view('dashboard')->with('notebooks', $notebooks);
Also, you do not need to get a user from DB since you can access auth()->user() instance in a view.
I want to add tab id to the URL and also want to activate the current tab which tab id in the URL.
If I hit the URL with tab id from another system then the same tab will be active.
I have the added my code:
<div id="faq-accordion">
<ul class="tabs">
<li class="tab-link current" data-tab="tab-1"><a href="#tab-2">About us</li>
<li class="tab-link" data-tab="tab-2"><a href="#tab-2">Ordering</li>
<li class="tab-link" data-tab="tab-3"><a href="#tab-2">Payment</li>
</ul>
<div id="tab-1" class="tab-content current">
<div class="accordion-block close">
<div class="accordion-trigger close">
<span>Can order be placed on phone?</span>
</div>
<div class="accordion-content">
<ul>
<li>Yes, we do take orders on the phone</li>
<li>We also take orders via Whatsapp. </li>
</ul>
</div>
</div>
</div>
<div id="tab-2" class="tab-content">
<div class="accordion-block close">
<div class="accordion-trigger close">
<span>Only Part of my order has arrived. Why?</span>
</div>
<div class="accordion-content">
<p>In rare occasions, few of the ordered products are unavailable. In such situations, we try to deliver the orders in parts. In such situations, you will be duly informed by our customer service executive.</p>
</div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function(){
jQuery('ul.tabs li').click(function(){
var tab_id = jQuery(this).attr('data-tab');
jQuery('ul.tabs li').removeClass('current');
jQuery('.tab-content').removeClass('current');
jQuery(this).addClass('current');
jQuery("#"+tab_id).addClass('current');
});
});
</script>
it's so simple, you can handle it yourself with pushstate (to update your URL) or you can use this library which made it piece of a cake already :)
I create a drop down button for Wordpress plugin ultimate member login form. It's working correctly inside the content page, but when i paste these codes outside i mean in header.php it's not show login form.I'm also using restricted content code of ultimate member.Please any one help me.
Thanks in Advance.
Problem
Inside content page of wordpress working 100% correct
<div style="width:120px; background:lightgrey;" class="ld-en">
<div class="col-md-1"><h4>Hello</h4></div>
<div class="col-md-2">[um_loggedin show_lock=no] <h4 style="color:red;padding-left:15px;">{first_name} </h4>
[/um_loggedin]</div>
<div class="col-md-2">[um_loggedout] <div class="dropdown"> <button class="login-drop dropdown-toggle" id="menu1" type="button" data-toggle="dropdown"> Log In<span class="caret"></span></button>
<div class="dropdown-menu login-dropdown" role="menu" aria-labelledby="menu1"> [ultimatemember form_id=287]
<ul class="login-dropdown">
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="">Register</a></li>
</ul></div>
</div> [/um_loggedout]</div>
</div>
You have to use do_short_code() for each short code you have used in your file
check this out check how to use it
for example
<div style="width:120px; background:lightgrey;" class="ld-en">
<div class="col-md-1"><h4>Hello</h4></div>
<div class="col-md-2"><?php echo do_shortcode( '[um_loggedin show_lock=no]' ); ?> <h4 style="color:red;padding-left:15px;">{first_name} </h4>
<?php echo do_shortcode( '[/um_loggedin]') ?></div>
How do I achieve the following?
I have a list of entries.
I want to be able to delete a single entry via the right "x"
But also I would like to be able to select multiple entries via the checkboxes on the left. After that, obviously clicking the "delete selected entries" at the bottom.
At the moment, all of this is in one form. Everything is links at the moment, not really what I want at all because it doesnt work.
Can anyone help me with a strategy or implementation that would enable me to get this working?
Heres the html code at the moment, I create it dynamically with some PHP, request if you want to see: :)
<form class="learnfest_form" method="post" action="">
<h2>Delete a Learnfest Entry <small>Select an entry to delete</small></h2>
<hr>
<ul class="list-group checked-list-box">
<li class="list-group-item"><input type="checkbox" value="c1e42a9f9cfbdad684fa5a107a9967cef96a8a6e"> L01<a class="pull-right" href="c1e42a9f9cfbdad684fa5a107a9967cef96a8a6e" onclick="return confirm('Are you sure?');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></li>
<li class="list-group-item"><input type="checkbox" value="0c0203b6b6d5105a3e72deac0b61be61236b1ff7"> L02<a class="pull-right" href="0c0203b6b6d5105a3e72deac0b61be61236b1ff7" onclick="return confirm('Are you sure?');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></li>
<li class="list-group-item"><input type="checkbox" value="99a5cbf3ff728b5d6f3f524d301edc6a5d38feb9"> L03<a class="pull-right" href="99a5cbf3ff728b5d6f3f524d301edc6a5d38feb9" onclick="return confirm('Are you sure?');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></li>
<li class="list-group-item"><input type="checkbox" value="31729ebd6fa5fcb0f17cdc1e3e5fe3c861149782"> L04<a class="pull-right" href="31729ebd6fa5fcb0f17cdc1e3e5fe3c861149782" onclick="return confirm('Are you sure?');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></li>
</ul>
<div class="panel panel-default">
<div class="panel-body">
Delete Selected Entries <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</div>
</div>
</form>
When you click on Delete Selected Entries retrieve all .list-group-item checkbox:checked elements and make an AJAX request to your php page to delete all of them. Your request will be something like this:
{
elementstodelete: [
'c1e42a9f9cfbdad684fa5a107a9967cef96a8a6e',
'0c0203b6b6d5105a3e72deac0b61be61236b1ff7'
]
}
On server side you use json_decode() to read all the elements and you'll make the magic query to delete them.