Jump to content

create an array , add a value get value from an array plz help !


immunity

Recommended Posts

sorry about that :/

ok hear it is

 

i have an html with  input texts and i use this page to display member (from Mysql)

via javascript i send  the  "returnvalues.php?account="+document.....value+"...

 

so i get the page for example  "returnvalues.php?account=immunity&password=000000&email=&city="

 

Now inside returnvalues.php

 

I want to make query "Select * from account Where account ='immunity' AND password='000000'";

 

I dont know when account or password or email or city will be empty

 

I have to use array (i think) so

 

if ( $_GET['account'] !="" ) { add  inside array "account='".$_GET['account']."' " }

if ( $_GET['password'] !="") {add  inside array "password='".$_GET['password']."' "}

......

 

So the array will be filled only from values those isnt ""

 

No i create a string $sQuery "Select * from account ";

 

and I want to add all the strings of array; (if array is empty = all variables was "" so we let the sQuery as it is and we get all the table member) (if array has values then we add  if it's the index 0 "Where ".$a(in the index)  if it's the index >0 " ".$a(in that index)

something like this

$where = array();
if ( $_GET['account'] !="" ) { $where[] = "account='".  $_GET['account']."'";}
if ( $_GET['password'] !="") {$where[] = "password='".$_GET['password']."' "}
...
if(count($where) > 0) $where = ' WHERE '.implode("OR", $where);
$sQuery = "Select * from account". $where;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.