I want to show a table if the vpn information isset but its notworking. Its showing a empty table with no username and pass. Instead of there are no vpm's setup yet.
A picture is here :
Code : http://snag.gy/kxB6r.jpg
result : http://snag.gy/EfdOW.jpg
( im using codeigniter )
use empty().
if(!empty($vpn)){
echo "Have data"
}
else{
echo "No data";
}
This will act as isset and count>0
Related
I'm attempting to get the results of a database table and echo the query results.
Here is my code:
$queryDB = $this->db->select('*')
->from('dr_template_relational')
->where('value_id', $categoryDetails['value_id'])
->where('subcategory_id', $categoryDetails['subcategory_id'])
->get();
echo "<br>";
echo "here is queryDB";
echo($queryDB);
echo "that was it";
$queryDB doesn't echo even so I'm sure the data is there. I'm wondering what I'm doing wrong. I'm not getting an error, but also don't get any output with echo($queryDB); on screen it displays:
here is queryDBthat was it
Right now, your approach is just echoing out the instance of the query.
In order to see the query results, you need to create them. There are several CI functions like result() and row()
at the end it could look like this:
foreach ($queryDB ->result() as $row){
echo $row->value_id;
echo $row->subcategory_id;
}
see Generating Query Results
hint: in order to see the generated query you could use
echo $this->$db->last_query();
i have been trying in create check on form validation on laravel
i need to query input with date and check more than check with many messages
like
if(){
$this->errorSchema->addError($error, $name); //symfony 1 way
}
how and where should i do that i have been thinking in creating custom validtaion but it returns true or false i need the date in the query to display like "this place is used for user XXX" XXX is data i got in the query
i want to return multi error if some record exist like
$resultset = 'select person form events where date < "some date"';
if ($resultset[enddate] > 'somedate'){
my error message should be "you cant add this event as $resultset['person'] overlape in this date "
}elseif($resultset[startdate] > 'somedate'){
i need here to return deffrent error message like "start date is overlapping with resultset['person']"
}
i am using requests class in laravel so please recommend me a method to override or any other way to this in laravel
thanks in advance
You can try to SELECT data which you'd like to return, your "XXX", from table by user's input.
Simple SELECT *** FROM table WHERE smth = user's_input;
If it return smth, you can just add it to your validator such as: "this place is used for user".$smth;
Else (if nothing returned, you send to user your default answer.)
Also if you add more code it will be easier to help you :)
I am trying to output a variable like this: <h1>{{ $unitcode }}</h1>
I have this code making that variable:
// Validation was successful.
$inputcode = Input::get('unitcode');
// First validation is successful. Next to check that it is a correct unit code.
$unitcode = DB::table('unitcodes')->where('unitcode', $inputcode)->first();
if(!$unitcode) {
// Input code is wrong. The unit does not exist.
return Redirect::route('get-buy')
->with('global', 'That unit code does not exist. Try again.');
} else {
// Success! Unit code exists!
return View::make('showbooks')
->with('unitcode', $unitcode);
}
When I run everything it gives me this:
ErrorException (E_UNKNOWN)
Array to string conversion (View: ..BLAH goes on to display path to view.
How can I get it to display the variable I want that was pulled from the DB?
Thanks!
In Laravel's DB abastraction layer a row from a database table (result of a SELECT ... LIMIT 1 - DB::...->first()) is an array.
You can send any kind of variables using View::...->with but you need to use them properly in the template itself ('showbooks').
You most probably are doing a {{{ unitcode }}} in the template which is actually similar to executing an echo $unitcode. Now if $unitcode is an array and echo requires a string then PHP automatically tries to convert it and fails (ErrorException (E_UNKNOWN)
Array to string conversion...).
What you need to do is use it correctly:
{{{ unitcode['unitcode'] }}}
And this will work because $unitcode is a key-value dictionary where each key is a column from the DB table with its associated value.
I am getting MLNumbers from RETS Server but now I need to get all the fields of all the MLNumbers and store into my database. Could anybody help me to write query to get the whole property Object.
If you have all the Listing Numbers then you just need to write a search query to pull all the results back and process the results. I haven't ever seen a field name MLNumber but you will have to figure that out:
<?php
$search = $rets->SearchQuery("Property","RES","(MLNumber=11111,22222,33333)");
while ($listing = $rets->FetchRow($search)) {
echo "Address: {$listing['StreetNumber']} {$listing['StreetName']}, ";
echo "{$listing['City']}, ";
echo "{$listing['State']} {$listing['ZipCode']} listed for ";
echo "\$".number_format($listing['ListPrice'])."\n";
}
$rets->FreeResult($search);
I think this should return the results you need. You will need to figure out the Resource/Class/Field name you need to use for your SearchQuery().
More PHRETS examples here.
i am using pyrocms for my web application.
i want create library for my module in addons.
when i use this code for tabel llist in my database.
$CI = & get_instance();
$all=$CI->db->list_tables();
i have "defualt_products" value in $all array. this means i have "default_products" table in my database. but when i use next code , result is false. why?
if(!$CI->db->table_exists("default_products"))
return false;
i use pyrocms 2.2.
You can use the dbprefix method to include you table prefix from database.php config file:
if ( !$CI->db->table_exists($CI->db->dbprefix('products')) ){
//there is no such table, products
echo "there is no table named ".$CI->db->dbprefix('products');
die();
}else{
//table found
echo "table found"; die();
}
In case it dose not work, then I think your problem is not this piece of code!
You aren't passing anything to table_exists. How is it supposed to know which table you are trying to check for? It takes one parameter...the table name you are checking for.
http://ellislab.com/codeigniter/user-guide/database/table_data.html
so, if you did this, and a table called "tablename" existed..then you would still get false, because table_exists returns TRUE if the table does exist.
if ($CI->db->table_exists('tablename')
{
return FALSE;
}