-1

Okay What im looking to do return all the data a user has already submitted on one page. So basicly they are already loged in so I should know there email address and I just want to pull all the mysql data and display all the data under that email address

So basicly mysql has email as first colum and then and bunch of junk and I want to display all the junk if the email colume equals the same email that they are loged in as

here is my code im on the right track but not quite there

 <?php
    session_start();
    include 'config.php';
    $_SESSION['Email']=$Email;

    mysql_select_db("DATABASEJUNK") or die ("Couldn't find database.");

    $query = mysql_query("SELECT * FROM DATABASELIST WHERE Email='$Email'");

    $numrows = mysql_num_rows($query);

    while ($row = mysql_fetch_assoc($query))
      echo $row['Url'];

 ?>
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
bush man
  • 147
  • 2
  • 2
  • 8
  • Where would the `$Email` variable come from? Is it set in the `config.php`? If so, please share that code as well. – Oldskool Nov 29 '12 at 09:54
  • $_SESSION['Email']=$Email; or $Email=$_SESSION['Email']; ? – Mohammed H Nov 29 '12 at 09:54
  • can you tell which track you are on or what your output is? – freaky Nov 29 '12 at 10:04
  • please note that the `mysql_xx()` functions you're using are considered obsolete and insecure. Ideally you should be using the equivalent `mysqli_xx()` funcs instead, or the PDO library. See also http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-function-in-php – SDC Nov 29 '12 at 10:05
  • also, be wary of SQL injection attacks in your query. I don't know how you're populating `$_SESSION['Email']`, but if it's from user input, it needs to be escaped when added to the query like this, otherwise it's open to being hacked. – SDC Nov 29 '12 at 10:07

1 Answers1

0

i think what you need is something like that

while ($row = mysql_fetch_assoc($query)){
  foreach($row as $value){
     echo $value;
  }
}

if course you need to put this at the correct part of your script. or save the output of $value to an array

$allUsers = new Array();
while ($row = mysql_fetch_assoc($query)){
  $user = new Array();
  foreach($row as $key => $value){
     $user[$key] = $value;
  }
  $allUsers[] = $user;
}

this gives you an array with all users ... and each user has its own data as key! if you want just 1 user forget about the $allUser arrays and keep just the rest (if mysql_num_rows() == 1)

Mik
  • 1,705
  • 1
  • 14
  • 26