If I have an array of say, some ID's of users. How could i do something like this:
$array = array(1,40,20,55,29,48);
$sql = "SELECT * FROM `myTable` WHERE `myField`='$array'";
Is there a simple way to do this, I thought about looping through array items and then building up one big "WHERE -- OR -- OR -- OR" statement but i thought tha...
I'm developing a site which has urls like this:
site.com/james
site.com/james/photos
Schema for this urls are this: site.com/USERNAME/APPLICATION
Both username and application names are checking from db yb program logic. I set the route for this but Zend is routing all requests to this route.
But there is same controllers and admin ...
I'm using php and need to do a bunch of select statements on the same table and column and get the rows that match those values.
I have all the values I'm searching on in an array and right now I'm just looping and doing a select statement on each one separately. How could I put this all into one select statement and ditch the loop?
Ri...
Hello
I would like to get data using SNMP from a router. The data shall be used for a graph I guess using the jquery flot.
But my issue is I do not know how to get my webpage to read the data using SNMP from the router.
I normally use MRTG but I would like to learn how to handcode it if possible.
BR. Anders
...
Rather new to php, so sorry if this seems stupid. I'm really copying a lot of this from previously written code from other developers at my company.
The way we run a query is basically like this:
$qry = new SQLQuery;
$sqlString = "SELECT * FROM database.table WHERE table.text = '" .
$textVar . "' and table.text2 = '" . $...
Here's my RegisterController:
public function saveforminformationAction(){
$request = $this->getRequest();
if($request->isPost()){
//I NEED HELP WITH THE getFormValues() METHOD.
$formResults = $this->getFormValues();
$db = $this->_getParam('db');
$data = array(
...
I would like to know what are the best ways/practices to browse a SVN (like http://core.svn.wordpress.org/) with Zend Framework. As a student learning Zend Framework, I am not very used with this framework so I would like to start on the right direction. It has to do simple tasks like list all files, retrieve a revision of a file, get th...
Hi there I was wondering whether someone know how to remove both the url and the link text from all anchor tags in a big paragraph of text. once remove if I could store them in an array for later use.
Im sure this is possible but I really struggle with regex.
Hopefully there is someone out there who has came across this before or who ...
I've got a client who wants their videos (provided by a third party) displayed on their web site. The web site uses swfobject to display the video, so I thought that it would be easiest to grab that and slightly modify it so that it works on the client's web site.
Using PHP DOMDocument seems the way to go, but unfortunately the HTML tha...
How can I just obtain the string value of a Xml node using xpath in PHP?
I RTFM but there is more complicated situations, using foreach I want just my node text.
XML:
<ValCurs Date="00.00.0000" name="Official exchange rate">
<Valute ID="47">
<NumCode>978</NumCode>
<CharCode>EUR</CharCode>
<Nominal>1</Nominal>
<Name>Euro</Name>
...
There's a blog post comment on this page: http://www.codinghorror.com/blog/2010/02/the-nonprogramming-programmer.html#comments by Paul Jungwirth which includes a little programming task:
"You have the numbers 123456789, in that order. Between each number, you must insert either nothing, a plus sign, or a multiplication sign, so that the...
Is there a way to format in PHP a number always keeping its sign (+ or -)?
In .NET this will be something like:
string myString = number.ToString("+#;#");
...
Hi, I’m new to CodeIgniter, I was wondering if it’s considered a good practice to restrict direct access to your view-files? Obviously they are going to contain a lot of php-code that relies on variables and what not passed to them from the controller, so the php-code could easily come up with an error if it’s directly accessed couldn’t ...
Hi everyone,
How do you use the email->attach function?
I can't figure what is happen, cos when i put the code for email->attach the mesage came in blank(the mail body) and there is no attach.
If i remove that code line, everything come back to normal..
thank you
my controller (sendmail.php)
<?php
class Sendmail extends Controlle...
hi guys
I want to do something but cant figure out how to do this (i m newbie in php)
suppose, i have a list of URL's which shows live with this preg_replace,
$html = preg_replace('/\s(\w+:\/\/)(\S+)/', ' <a href="http://localhost/get.php?url=\\1\\2" target="_blank"> GO</a> ', $html);
my output is like
http://localhost/get.php?ur...
I've implemented more complex AJAX before with javascript and PHP, but for some reason this refuses to work. This is copied almost directly from the W3 example.
var xmlhttp;
function changeLoc(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="acti...
I decided that I would like to track the searches that users are making on my site, so I created a MySQL table called 'Searches' with a few simple fields, and a model (class) to facilitate the insertion and management of the saved searches.
The model function that saves the search is:
public function create() {
$q = $this->db->quer...
I have multiple functions, each running their own SQL query that needs to be inside a transaction... I'm using a static $link to save having to pass around links between functions... for example:
function db() {
$user = "username";
$pass = "password";
$db = "database";
$server = "localhost";
static $link;
if(is_null($link)){
$l...
Somehow I managed to make the date work,
<td width="67"><font size="3"><b>*Date</b></td>
<td width="3">:</td>
<td width="168"><input name="adate" type="text" id="adate" maxlength="20" value="<?php echo date("Y/m/d") . "<br />"; ?>">
how do I echo the time in this form:
<td width="67"><font size="3"><b>*Time</b></td>
<td width=...
Hello, I am trying to figure out how I can update my sql query dynamically.
On the main page, I have a pagination script that counts how many pages there will be:
<?php
function generate_pagination($sql) {
include_once('config.php');
$per_page = 3;
//Calculating no of pages
$result = mysql_query($sql);
$count = mysql_num_row...