Edit option from Radio Buttons in PHP - php

I am VERY new to PHP and editing some code
Currently it has two radio buttons. Selecting either will bring up some options.
I am wanting to get rid of one option (pick up) and have the page just show the delivery option.
Any help would be ace, I have tried playing with the code but no luck!
<div class="top10 row">
<div class="col-xs-6 ">
<?php echo CHtml::radioButton('trans_type',false,array(
'class'=>"trans_type",
'value'=>'pickup',
'required'=>true
));
?>
<span><?php echo Driver::t("Pickup")?></span>
</div>
<div class="col-xs-6 ">
<?php echo CHtml::radioButton('trans_type',false,array(
'class'=>"trans_type",
'value'=>"delivery"
));
?>
<span><?php echo Driver::t("Delivery")?></span>
</div> <!--col-->
</div> <!--row-->
<div class="delivery-info top20">
<div class="row">
<div class="col-sm-6">
<?php echo CHtml::textField('contact_number','',array(
'class'=>"mobile_inputs",
'placeholder'=>Driver::t("Contact nunber"),
'maxlength'=>15
))?>
</div> <!--col-->
<div class="col-sm-6 ">
<?php
echo CHtml::textField('email_address','',array(
'placeholder'=>Driver::t("Email address")
))
?>
</div> <!--col-->
</div> <!--row-->
<div class="row top10">
<div class="col-sm-6 ">
<?php echo CHtml::textField('customer_name','',array(
'placeholder'=>Driver::t("Name"),
'required'=>true
))?>
</div>
<div class="col-sm-6 "><?php echo CHtml::textField('delivery_date','',array(
'placeholder'=>Driver::t("Delivery before"),
'required'=>true,
'class'=>"datetimepicker"
))?></div>
</div> <!--row-->
<div class="row top10">
<div class="col-sm-12 ">
<?php
$map_provider = Driver::getMapProvider();
?>
<?php if ($map_provider =="mapbox"):?>
<div id="mapbox_delivery_address" class="mapbox_geocoder_wrap"></div>
<?php elseif ( $map_provider=="google.maps"):?>
<?php
echo CHtml::textField('delivery_address','',array(
'class'=>'delivery_address geocomplete delivery_address_task',
'placeholder'=>Driver::t("Delivery Address"),
'required'=>true
));
?>
<?php endif;?>

Remove the lines of code below (or comment them out while you try it). Make a copy of the file before you make any changes in case you need to back out the attempt.
<div class="col-xs-6 ">
<?php echo CHtml::radioButton('trans_type',false,array(
'class'=>"trans_type",
'value'=>'pickup',
'required'=>true
));
?>
<span><?php echo Driver::t("Pickup")?></span>
</div>

Related

I have an error in my code that does not allow me to show the results and/or show an error message in php

I have a little problem that might be syntax (since I'm not that good at php). Basically, I'm de-wrapping a code where there will be records where there will be a date (in this case, a foundation date, for example; 20-08-2027). So I created an "if". If there are records with the date, for example, 2027, the records appear. If there is not, then an error message will be displayed saying that there is still no record made with that date. I've tried a few things, but nothing worked. At this point, an error appears. Below will be the error. Please try to help me. It's no use saying more technical things, because I'm not that good at php. Thank you.
Error: "Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/host/public_html/template/year/2027.php on line 300"
2027.php
<section class="content products">
<div class="container">
<h1 class="hidden">Eventos</h1>
<div class="row">
<div class="col-sm-10">
<div class="row grid" id="products">
<div class="releated-products">
<div class="row grid" id="products">
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0) {
while($regi=mysqli_fetch_array($resu)){
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php
} else{
?>
<p>Nada!</p>
<?php
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
The reason you are getting the error because you have while loop in your if block that you are not closing.
Check the code below for this fixed version.
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0):
while($regi=mysqli_fetch_array($resu)):
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php endwhile; else: ?>
<p>Nada!</p>
<?php
endif;
?>
Move the last } bracket above }else{
<section class="content products">
<div class="container">
<h1 class="hidden">Eventos</h1>
<div class="row">
<div class="col-sm-10">
<div class="row grid" id="products">
<div class="releated-products">
<div class="row grid" id="products">
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0) {
while($regi=mysqli_fetch_array($resu)){
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php
} // while()
} else{
?>
<p>Nada!</p>
<?php
}
// } //wrong bracket
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
For your own sanity it is a good idea leave a comment after closing bracket of a long code, so you know which block it belongs to.
Compiler can't be wrong, if it says there's syntax error then there is. The bracket before the else is closing the while loop - hence else cannot be used there, close the if condition. Here's the corrected code:
<section class="content products">
<div class="container">
<h1 class="hidden">Eventos</h1>
<div class="row">
<div class="col-sm-10">
<div class="row grid" id="products">
<div class="releated-products">
<div class="row grid" id="products">
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0) {
while($regi=mysqli_fetch_array($resu)) {
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
/* 2 brackets { */
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php
} // while loop
} // if condition
else {
?>
<p>Nada!</p>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
hope this helps. 👍

Html is still visible in CodeIgniter using if else

I'm here trying to make if else condition to hiding the html part if $addons_facts var is empty. I am making the addon visible on the food item if the $addons_facts var is not empty.
<?php $addon_data = $this->addons_model->get_addon_by_menu_id($menu_details['id']);
$addons_facts = json_decode($addon_data->addon_fact, true);
?>
<?php if(!empty($addons_facts) && $addons_facts !=='') : ?>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<?php
foreach ($addons_facts as $key => $addon_fact) : ?>
<div class="row">
<div class="col-md-1">
<div class="checkbox">
<label for="check">
<input type="checkbox" id="check" />
<span class="fake-input"></span>
</label>
</div>
</div>
<div class="col-md-7 text-left">
<?php echo sanitize($key); ?>
</div>
<div class="col-md-3">
<?php echo currency(sanitize($addon_fact));?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
When data is present in $addons_facts
When data is absent $addons_facts
As you can clearly see that when data is not present and the html is still visible (checkbox or $). I already tried if else both but unable to figure it out what is going wrong and why if condition not hiding the whole content within if{}.
I figure it out the solution by this: <?php if(!empty($key)) : ?>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<?php
foreach ($addons_facts as $key => $addon_fact) : ?>
<?php if(!empty($key)) : ?>
<?php $randomNum = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ"), 0, 10); ?>
<div class="row">
<div class="col-1">
<div class="checkbox">
<label for="<?php echo $randomNum; ?>">
<input type="checkbox" id="<?php echo $randomNum; ?>" />
<span class="fake-input"></span>
</label>
</div>
</div>
<div class="col-7 text-left">
<?php echo sanitize($key); ?>
</div>
<div class="col-3">
<?php echo sanitize($addon_fact) ? currency(sanitize($addon_fact)) :'';?>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
</div>

bootstrap 4 with codeignitor form with validation

Not showing responsive in safari browser Responsive issue
I am unable to control to responsive this code, working fine in windows chrome and Mozilla, but not on mac. can anyone help me?
<?php echo form_open('user/signup');?>
<div class="form-row">
<div class="form-group">
<div class="col-md-6 col-xs-12 col-sm-12">
<div class="form-label-group">
<?php echo form_input(['name'=>'firstname','id'=>'firstname','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('firstname')]);?>
<?php echo form_label('Enter your first name', 'firstname'); ?>
<?php echo form_error('firstname',"<div style='color:red'>","</div>");?>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-xs-12 col-sm-12">
<div class="form-label-group">
<?php echo form_input(['name'=>'lastname','id'=>'lastname','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('lastname')]);?>
<?php echo form_label('Enter your last name', 'lastname'); ?>
<?php echo form_error('lastname',"<div style='color:red'>","</div>");?>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<?php echo form_input(['name'=>'emailid','id'=>'emailid','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('emailid')]);?>
<?php echo form_label('Enter valid email id', 'emailid'); ?>
<?php echo form_error('emailid',"<div style='color:red'>","</div>");?>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<?php echo form_input(['name'=>'mobilenumber','id'=>'mobilenumber','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('mobilenumber')]);?>
<?php echo form_label('Enter Mobile Number', 'mobilenumber'); ?>
<?php echo form_error('mobilenumber',"<div style='color:red'>","</div>");?>
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<div class="form-label-group">
<?php echo form_password(['name'=>'password','id'=>'password','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('password')]);?>
<?php echo form_label('Password', 'password'); ?>
<?php echo form_error('password',"<div style='color:red'>","</div>");?>
</div>
</div>
<div class="col-md-6">
<div class="form-label-group">
<?php echo form_password(['name'=>'confirmpassword','id'=>'confirmpassword','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('confirmpassword')]);?>
<?php echo form_label('Confirm Password', 'confirmpassword'); ?>
<?php echo form_error('confirmpassword',"<div style='color:red'>","</div>");?>
</div>
</div>
</div>
</div>
<?php echo form_submit(['name'=>'Register','value'=>'Register','class'=>'btn btn-primary btn-block']); ?>
<?php echo form_close(); ?>
How do I solve this issue
Responsive issue on safari
100% working in windows chrome

Looping posts of a custom post type in diffrent columns

I have a custom post type "case_studies" i want posts from this, to arrange in a following way.
<div class="col-sm-3 nopadding">
IMAGE
</div>
<div class="col-sm-3 ">
TEXT
</div>
<div class="col-sm-3 nopadding">
IMAGE
</div>
<div class="col-sm-3 ">
TEXT
</div>
<!--
Column Ends
3rd & 4th posts
-->
<div class="item">
<div class="col-sm-6 nopadding">
IMAGE
</div>
<div class="col-sm-6">
TEXT
</div>
</div>
<div class="item">
<div class="col-sm-6 nopadding">
IMAGE
</div>
<div class="col-sm-6">
TEXT
</div>
</div>
<!--
Column Ends
-->
Then again first & second post type column after that again 4th & 5th post type column same loop goes on. note that each column ends after 2 posts & styles are diffrent. how can i achieve this
in short odd columns must have 2 posts which wrapped with col-sm-3, even columns also have 2 posts each one wrapper with col-sm-6.
Try this code.
<?php
$loop = new WP_Query( array( 'post_type' => 'case_studies') );
$Inc = 1;
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if($Inc==1){ ?>
<div class="col-sm-3 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-3 ">
<h2><?php echo get_the_title(); ?></h2>
</div>
<?php }else if($Inc==2){ ?>
<div class="col-sm-3 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-3 ">
<h2><?php echo get_the_title(); ?></h2>
</div>
<?php }else if($Inc==3){ ?>
<div class="item">
<div class="col-sm-6 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-6">
<h2><?php echo get_the_title(); ?></h2>
</div>
</div>
<?php }else if($Inc==4){ ?>
<div class="item">
<div class="col-sm-6 nopadding">
<?php the_post_thumbnail(); ?>
</div>
<div class="col-sm-6">
<h2><?php echo get_the_title(); ?></h2>
</div>
</div>
<?php } ?>
<?php
if($Inc==4){
$Inc =1;
}
$Inc++;
endwhile;
endif;
wp_reset_postdata();
?>

How to retrieve more data from mysql in another php page

how to retrieve data from mysql by id to another page?
Example:
<div class="col-md-12">
<div class="row">
<?php while($posts = mysqli_fetch_assoc($featured)): ?>
<div class="col-xs-12 col-md-6">
<div class="thumbnail">
<img src="<?=$posts['image']; ?>" alt="<?=$posts['title']; ?>">
<span class="pull-right"><?=$posts['date_info'];?></span>
<div class="caption">
<h3><?=$posts['title']; ?></h3>
<p><?php echo substr($posts['description'],0,300); ?></p>
<p>More..</p>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
When i click More button, it would be display more information in another page.

Categories