Jump to content

malikah

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

malikah's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, does anyone know where I'm going wrong here? $name = ""; $email = ""; $subject = ""; $message = ""; $fieldVals = array($name, $email, $subject, $message); foreach($fieldVals as $key => $val) $fieldVals[$key] = "abc"; echo $name; echo $email; echo $subject; echo $message; //output: <nothing> (I was hoping to see "abc" for each variable). Cheers.
  2. I'm trying to link to a page that takes its own parameter and then checks that parameter to open another page which also has its own parameters: href='blah.php?page=view.php?a=apple&b=ball&c=car' And of course this isn't working - any ideas how I can get this to work? Cheers.
  3. You mean this? $private $conn; function __construct() { $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME); }
  4. I'm trying to create an associative array: $valsOne = array("A","B","C","D","E"); $valsTwo = array("apple","orange","grape","kiwi","banana"); for($i=0;$i<sizeof($valsOne);$i++) { $bigArray[$i] = $valsOne[$i]; $bigArray[$valsOne[$i]] = $valsTwo[$i]; } foreach($bigArray as $key => $value) echo $key . "=" . $value . "<br />"; I was hoping that the output would show the letter and then the fruit, but instead I get this: 0=A A=apple 1=B B=orange 2=C C=grape 3=D D=kiwi 4=E E=banana What am I doing wrong?
  5. This worked for me procedurally: $query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS where table_name='table'"; if(mysqli_real_query($dblink, $query)) { $result = mysqli_store_result($dblink); while($row = mysqli_fetch_assoc($result)) { foreach($row as $_colName => $_colValue) { echo "{$_colValue}<br />"; } } } Unfortunately, I can't figure out the object-oriented equivalent. Here's my attempt: $query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS where table_name='table'"; if($stmt = $this->conn->prepare($query)) { $stmt->execute(); $stmt->store_result(); while($row = $stmt->fetch()) { foreach($row as $_colName => $_colValue) { echo "{$_colValue}<br />"; } } }
  6. OK, I used "DESCRIBE table" to get it working: $query = "DESCRIBE table"; if($stmt = $this->conn->prepare($query)) { $stmt->execute(); $stmt->store_result(); echo $stmt->num_rows(); $stmt->close(); } NOW.. All I need is to return the names of each field...
  7. So far this works for ROWS but I need something for COLUMNS: $query = "SELECT * FROM table"; if($stmt = $this->conn->prepare($query)) { $stmt->execute(); $stmt->store_result(); echo $stmt->num_rows(); $stmt->close(); }
×
×
  • 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.