*Ajax is not responding on remote server for Some PC's but working fine on mobile browsers and on PC which i have uploaded on. Please let me know whats the problem with that
This Ajax function.
<pre>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#selTrim').change(function(){
var trim_id1 = $(this).val();
if(trim_id1){
$.ajax({
type:'POST',
url:'<?= base_url();?>H1_specifications/h1_trim_detail',
data:'trim_id1='+trim_id1,
success:function(data){
$('#specContWrap').html(data);
}
});
}
});
});
</script>
</pre>
*This Php Code-igniter Controller response *.
I am using Code-igniter framework please also let me know is this a best practice to echo response .
<pre>
public function h1_trim_detail(){
$id = $_POST['trim_id1'];
if(isset($_POST['trim_id1']) !== NULL){
$this->load->model('Admin_panel');
$rows7 =$this->Admin_panel->select_h1_details_specification($id);
$rows =$this->Admin_panel->select_h1_Cargo($id);
$rows1 =$this->Admin_panel->select_h1_engine($id);
$rows2 =$this->Admin_panel->select_h1_exterior($id);
$rows3 =$this->Admin_panel->select_h1_feul_comsuption($id);
$rows4 =$this->Admin_panel->select_h1_weight($id);
$rows5 =$this->Admin_panel->select_h1_wheels($id);
$rows6 =$this->Admin_panel->select_h1_transmission($id);
echo "<div id='specContWrap'>";
if($rows7 !== false){
echo "<div id='overViewWrap' class='overViewTableCon'>";
echo "<div class='overViewTable on'>";
echo "<div class='tit'>Overview</div>";
echo "<table class='infoTableType'>";
echo "<caption>Overview Table</caption>";
echo "<tbody>";
echo "<tr>";
echo "<th scope='row'>Product label</th>";
echo "<td>Commercial</td>";
echo "</tr>";
foreach($rows7 as $row){
echo "<tr>";
echo "<th scope='row'>Product label</th>";
echo "<td>".$row['name']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th scope='row'>Model name</th>";
echo "<td>". $row['name_car']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th scope='row'>Seats</th>";
echo "<td>". $row['seats']."</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
echo "</div>";
}else{
echo "Not Found";
}
echo "<div class='togListWrap small sepcListWrap' id='overviewh1'>";
echo "<div class='togList'>";
echo "<button class='btnOpenClose'>Performance</button>";
echo "<div class='togCont' id='performanceWrap'>";
echo "<div class='performance on'>";
if($rows1 !== false){
echo "<dl class='specList'>";
echo "<dt>Engine Specification</dt>";
foreach($rows1 as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['descriptions']."</dd>";
echo "</dl>";
echo "</dd>";
}
echo "</dl><br>";
}else{
echo "<dt>Engine Specification Not Found</dt><br>";
}
if($rows3 !== false){
echo "<dl class='specList'>";
echo "<dt>Feul Comsuption Specification</dt>";
foreach($rows3 as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['description']."</dd>";
echo "</dl>";
echo "</dd>";
}
echo "</dl><br>";
}else{
echo "<dt>Feul Comsuption Specification Not Found</dt><br>";
}
if($rows6 !== false){
echo "<dl class='specList'>";
echo "<dt>Transmission Specification</dt>";
foreach($rows6 as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['description']."</dd>";
echo "</dl>";
echo "</dd>";
}
echo "</dl><br>";
}else{
echo "<dt>Transmission Specification Not Found</dt><br>";
}
echo "</div>";
echo "</div>";
echo "</div>";
echo "<div class='togList'>";
echo "<button class='btnOpenClose'>Dimension</button>";
echo "<div class='togCont' id='DimensionWrap'>";
echo "<div class='Dimension on'>";
if($rows2 !== false){
echo "<dl class='specList'>";
echo "<dt>Exterior Specification</dt>";
foreach($rows2 as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['descriptions']."</dd>";
echo "</dl>";
echo "</dd>";
}
echo "</dl><br>";
}else{
echo "<dt>Exterior Specification Not Found</dt><br>";
}
if($rows4 !== false){
echo "<dl class='specList'>";
echo "<dt>Weight Specification</dt>";
foreach($rows4 as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['description']."</dd>";
echo "</dl>";
echo "</dd><br>";
}
echo "</dl><br>";
}else{
echo "<dt>Weight Specification Not Found</dt><br>";
}
if($rows !== false){
echo "<dl class='specList'>";
echo "<dt>Cargo Specification</dt>";
foreach($rows as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['description']."</dd>";
echo "</dl>";
echo "</dd>";
}
echo "</dl><br>";
}else{
echo "<dt>Cargo Specification Not Found</dt><br>";
}
echo "</div>";
echo "</div>";
echo "</div>";
echo "<div class='togList'>";
echo "<button class='btnOpenClose'>Wheels</button>";
echo "<div class='togCont' id='WheelsWrap'>";
echo "<div class='Wheels on'>";
if($rows5 !== false){
echo "<dl class='specList'>";
echo "<dt>Wheels Specification</dt>";
foreach($rows5 as $row){
echo "<dd>";
echo "<dl>";
echo "<dt>".$row['label']."</dt>";
echo "<dd>".$row['descriptions']."</dd>";
echo "</dl>";
echo "</dd>";
}
echo "</dl><br>";
}else{
echo "<dt>Wheels Specification Not Found</dt><br>";
}
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
}
}
</pre>
Related
Following is the code
I want out put as
http://crysol.com/crysol_soft/Test/Screenshot_3.png
With following code I am getting output as
http://crysol.com/crysol_soft/Test/Screenshot_4.png
echo "<table border='1'>";
echo "<th>Name</th>";
echo "<th>Number</th>";
echo "<th>Status</th>";
echo '<tr>';
echo "<td rowspan='5'>Cat</td>";
for($i=1;$i<=5;$i++){
echo '<td>'.$i.'</td>';
echo " </tr>";
}
echo "<td rowspan='10'>Good</td>";
?>
What are the changes required
Here is the code with your desired output
used if condition for print only 1 time good column and used rowspan='5'
<?php
echo "<table border='1'>";
echo "<th>Name</th>";
echo "<th>Number</th>";
echo "<th>Status</th>";
echo '<tr>';
echo "<td rowspan='5'>Cat</td>";
for($i=1;$i<=5;$i++){
echo '<td>'.$i.'</td>';
if($i==1){
echo "<td rowspan='5'>Good</td>";
}
echo " </tr>";
}
?>
and also you can used this code
for($i=1;$i<=5;$i++){
echo '<tr>';
if($i==1){
echo "<td rowspan='5'>Cat</td>";
}
echo '<td>'.$i.'</td>';
if($i==1){
echo "<td rowspan='5'>Good</td>";
}
echo " </tr>";
}
Create Table inside td:
<?php
echo "<table border='1'>";
echo "<tr><th>Name</th>";
echo "<th>Number</th>";
echo "<th>Status</th></tr>";
echo "<tr><td style=''>Cat</td>";
echo "<td><table style='width:100%;'>";
for($i=1;$i<=5;$i++){
echo "<tr>";
echo "<td style='border-bottom:1pt solid black;'>".$i.'</td>';
echo "</tr>";
}
echo "</table></td>";
echo "<td>Good</td></tr>";
?>
My code is working as for my needs. But the only thing bugging me is
the "else" is not working. When i search for a correct record the
record will appear and it was running fine. But if i Incorrectly
search a record nothing will happen. i am expecting "Records not Found" will echo but nothing happen.
}else{
echo "Records not found";
}
This is the whole code.
<?php
$conn = mysqli_connect("localhost", "root", "", "my1stdb") or die("could not connect");
$set = $_POST['search'];
if ($set) {
$show = "SELECT * FROM users where email='$set'";
$result = mysqli_query($conn, $show);
while ($rows = mysqli_fetch_array($result)) {
echo "Registrant Found";
echo "<tr>";
echo "<td>";
echo $rows['username'];
echo "</td>";
echo "<td>";
echo $rows['fullname'];
echo "</td>";
echo "<td>";
echo $rows['password'];
echo "</td>";
echo "<td>";
echo $rows['email'];
echo "</td>";
echo "</tr>";
echo "<br/>";
}
} else {
echo "Records not found";
}
?>
</table>
You need to use mysqli_num_rows() along with mysqli_fetch_assoc():-
<?php
$conn=mysqli_connect("localhost","root","","my1stdb") or die("could not connect");
$set = $_POST['search'];
if($set) {
$show="SELECT * FROM users where email='$set'";
$result=mysqli_query($conn,$show) or die(mysqli_error($conn));
if(mysqli_num_rows($result)>0){ // check data present or not
while($rows=mysqli_fetch_assoc($result)){ // for lighter array due to associative indexes only
echo "Registrant Found";
echo "<tr>";
echo "<td>";
echo $rows['username'];
echo "</td>";
echo "<td>";
echo $rows['fullname'];
echo "</td>";
echo "<td>";
echo $rows['password'];
echo "</td>";
echo "<td>";
echo $rows['email'];
echo "</td>";
echo "</tr>";
echo "<br/>";
}
}else{
echo "Records not found";
}
}else{
echo "Please insert search term";
}
?>
</table>
Note:- Your code is wide-open for SQL INJECTION. to prevent from it use prepared statements
Reference:-
mysqli prepared statements
PDO prepared statements
You could count the number of results returned.
if($set) {
$show="SELECT * FROM users where email='$set'";
$result=mysqli_query($conn,$show);
$recordCount = 0;
while($rows=mysqli_fetch_array($result)){
$recordCount++;
echo "Registrant Found";
echo "<tr>";
echo "<td>";
echo $rows['username'];
echo "</td>";
echo "<td>";
echo $rows['fullname'];
echo "</td>";
echo "<td>";
echo $rows['password'];
echo "</td>";
echo "<td>";
echo $rows['email'];
echo "</td>";
echo "</tr>";
echo "<br/>";
}
if($recordCount==0){
echo "Records not found";
}
}
Anyone can help me out in tabulating this data on PHP/HTML as I am only able to get to raw data which is not formulated. This is the code I am using:
// Price and Flight Select Statements
$pricesql = "select PriceID,RouteID,ClassID,Price from price;";
$printpricesql=mysqli_query($connect,$pricesql);
while($row=mysqli_fetch_array($printpricesql))
{
echo $row['PriceID'];
echo $row['RouteID'];
echo $row['ClassID'];
echo $row['Price'];
}
$flightsql = "select flightid,routeid,departuredate,arrivaldate from
flightschedule;";
$printflightsql=mysqli_query($connect,$flightsql);
while($row=mysqli_fetch_array($printflightsql))
{
echo $row['flightid'];
echo $row['routeid'];
echo $row['departuredate'];
echo $row['arrivaldate'];
}
// Price and Flight Select Statements
$pricesql = "select PriceID,RouteID,ClassID,Price from price";
$printpricesql=mysqli_query($connect,$pricesql);
echo '<table>';
// headers
echo '<tr>';
echo '<th>Price Id</th>';
echo '<th>Route Id</th>';
echo '<th>Class Id</th>';
echo '<th>Price</th>';
echo '</tr>';
while($row=mysqli_fetch_array($printpricesql)) {
echo '<tr>';
echo '<td>'.$row['PriceID'].'</td>';
echo '<td>'.$row['RouteID'].'</td>';
echo '<td>'.$row['ClassID'].'</td>';
echo '<td>'.$row['Price'].'</td>';
echo '</tr>';
}
echo '</table>';
$flightsql = "select flightid,routeid,departuredate,arrivaldate from flightschedule";
$printflightsql=mysqli_query($connect,$flightsql);
echo '<table>';
// headers
echo '<tr>';
echo '<th>Flight Id</th>';
echo '<th>Route Id</th>';
echo '<th>Departure Date</th>';
echo '<th>Arrival Date</th>';
echo '</tr>';
while($row=mysqli_fetch_array($printflightsql)) {
echo '<tr>';
echo '<td>'.$row['flightid'].'</td>';
echo '<td>'.$row['routeid'].'</td>';
echo '<td>'.$row['departuredate'].'</td>';
echo '<td>'.$row['arrivaldate'].'</td>';
echo '</tr>';
}
echo '</table>';
I'm trying to create a row with 3 thumbnails on it, the problem is it is not aligning in a single row, but instead every thumbnail goes in different row.
echo "<table>";
echo "<tr>";
echo "</tr>";
while($row=mysqli_fetch_array($result)){
echo "<div class=\"container\">";
echo "<div class=\"row-fluid\">";
echo "<div class=\"col-md-4\">";
echo "<div class=\"thumbnail\">";
echo "<img alt=\"News\" src=\"images/{$row["image"]}\">";
echo "<div class=\"caption\">";
echo "<h3>{$row["title"]}</h3>";
echo "<p>{$row["caption"]}</p>";
echo "<p align=\"right\">";
echo "<a class=\"btn btn-primary\" href=\"{$row["newsupdate"]}\">Read More</a>";
echo "</p>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
try this it might work
echo "<table>";
echo "<tr>";
while($row=mysqli_fetch_array($result)){
echo "<img alt=\"News\" src=\"images/{$row["image"]}\">";
echo "<div class=\"caption\">";
echo " <td> <h3>{$row["title"]}</h3> </td> ";
echo "<td><p>{$row["caption"]}</p></td>";
echo "<td> <a class=\"btn btn-primary\" href=\{$row["newsupdate"]}\">Read More</a>";
echo "</td>";
}
echo "</tr>";
echo "</table>";
I'm having trouble getting this page (http://ventrilostatus.net/xml/V98.DARKSTARLLC.COM:3789/) to array into php. I'm not very good with xml and I currently can only get it to display:
Server
Channel
Channel
Channel
(etc)
Could anyone help me get it to show the channel name and the users?
if there are not clients when you look at it it will be:
<client admin="1" cid="994" phan="0" ping="186" sec="56935" name="WHERE USER'S NAME HIS HERE" comm=""/>
U can use the simple_xml functions of PHP to load the xml file into a class.
http://php.net/manual/de/book.simplexml.php
Edit with an example:
// XML example
$xmlContent = '<server name="GuiltyofDestruction" phonetic="God" comment="http://guiltyofdestruction.com" auth="1" maxclients="25" uptime="137600" platform="Linux-i386" version="3.0.6" channelcount="36" clientcount="1" voicecodec="GSM 6.10" voiceformat="44 KHz, 16 bit"><channel cid="0" pid="-1" prot="0" name="Lobby" comm="">
<channel cid="1033" pid="0" prot="1" name="Admin" comm=""/>
<channel cid="1030" pid="0" prot="0" name="AFK Channel" comm="AFK">
<client admin="1" cid="1030" phan="0" ping="182" sec="67575" name="US_ChairForce" comm=""/>
</channel>
</channel>
</server>';
// Loading XML information as object
//$xml = simplexml_load_file('http://ventrilostatus.net/xml/V98.DARKSTARLLC.COM:3789/'); // for files
$xml = simplexml_load_string($xmlContent); // for strings
foreach($xml->channel->channel as $channel) {
if($channel->client)
echo $channel->client->attributes()->name; // returns "US_ChairForce"
}
I think it's clear now. You have to iterate through every channel and look for clients.
sorry this is the code I updated:
<?PHP
echo "<table width=\"209\" bgcolor=\"#0d0d0d\">";
$xml = simplexml_load_file('http://ventrilostatus.net/xml/V98.DARKSTARLLC.COM:3789/'); // for files
//$xml = simplexml_load_string($xmlContent); // for strings
foreach($xml->channel as $lobby) {
echo "<tr><td>";
echo "<img src='http://view.light-speed.com//images/s_vent2/server_icon.gif' />";
echo "<font color=\"#FFFFFF\">";
echo $lobby->attributes()->name;
echo "</font>";
echo "</td></tr>";
}
foreach($xml->channel->channel as $channel) {
if($channel->attributes()->prot == "0"){
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_0_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $channel->attributes()->name;
echo "</font>";
echo "</td></tr>";
}else{
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_1_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $channel->attributes()->name;
echo "</font>";
echo "</td></tr>";
}
if($channel->client){
for ( $i = 0; $i < count($channel->client); $i++ ){
$client = $channel->client[ $i ];
if ( $client->attributes()->cid != $client->attributes()->cid )
continue;
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/player.gif' /><font color=\"#009e1a\">";
if($client->attributes()->admin == "1"){
echo $client->attributes()->name;
echo " <font color=\"#ff0000\">(Admin)</font>";
}else{
echo $client->attributes()->name;
}
echo "</td></tr>";
}
}
foreach($channel->channel as $subchannel) {
if($subchannel->attributes()->prot == "0"){
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_0_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $subchannel->attributes()->name;
echo "</font>";
echo "</td></tr>";
}else{
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_1_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $subchannel->attributes()->name;
echo "</font>";
echo "</td></tr>";
}
if($subchannel->client){
for ( $i = 0; $i < count($subchannel->client); $i++ ){
$client = $subchannel->client[ $i ];
if ( $client->attributes()->cid != $client->attributes()->cid )
continue;
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/player.gif' /><font color=\"#009e1a\">";
if($client->attributes()->admin == "1"){
echo $client->attributes()->name;
echo " <font color=\"#ff0000\">(Admin)</font>";
}else{
echo $client->attributes()->name;
}
echo "</td></tr>";
}
}
foreach($subchannel->channel as $subchannel2) {
if($subchannel2->attributes()->prot == "0"){
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_0_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $subchannel2->attributes()->name;
echo "</font>";
echo "</td></tr>";
}else{
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_1_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $subchannel2->attributes()->name;
echo "</font>";
echo "</td></tr>";
}
if($subchannel2->client){
for ( $i = 0; $i < count($subchannel2->client); $i++ ){
$client = $subchannel2->client[ $i ];
if ( $client->attributes()->cid != $client->attributes()->cid )
continue;
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/player.gif' /><font color=\"#009e1a\">";
if($client->attributes()->admin == "1"){
echo $client->attributes()->name;
echo " <font color=\"#ff0000\">(Admin)</font>";
}else{
echo $client->attributes()->name;
}
echo "</td></tr>";
}
}
foreach($subchannel2->channel as $subchannel3) {
if($subchannel3->attributes()->prot == "0"){
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_0_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $subchannel3->attributes()->name;
echo "</font>";
echo "</td></tr>";
}else{
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/channel_1_empty.gif' />";
echo "<font color=\"#ffffff\">";
echo $subchannel3->attributes()->name;
echo "</font>";
echo "</td></tr>";
}
if($subchannel3->client){
for ( $i = 0; $i < count($subchannel3->client); $i++ ){
$client = $subchannel3->client[ $i ];
if ( $client->attributes()->cid != $client->attributes()->cid )
continue;
echo "<tr><td> ";
echo "<img src='http://view.light-speed.com//images/s_vent2/player.gif' /><font color=\"#009e1a\">";
if($client->attributes()->admin == "1"){
echo $client->attributes()->name;
echo " <font color=\"#ff0000\">(Admin)</font>";
}else{
echo $client->attributes()->name;
}
echo "</td></tr>";
}
}
}
}
}
}
echo "</table>";
?>
which shows
lobby
channel
subchannel
subchannel