Jump to content

daviddivine

Members
  • Posts

    7
  • Joined

  • Last visited

daviddivine's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is because your SQL query is incorrect. Try running the same query in phpmyadmin and you should probably get the same error.
  2. Hi, this is probably because your SQL query is querying from the dbname (employee_directory, which is probably wrong) rather than the table. (Maybe .. employees or something..). A correct query should look like this : SELECT * FROM `employee_directory`.`tablename` ORDER BY lastname; All make sure that your database name is really "employee_directory" and not just a tablename in the database. I really doubt if both the queried table and dbname have the same name (employee_directory). Good luck!
  3. Here's what you might really want to do : : Also lookout for the "You are now Connected to MySQL" text as echoed upon a succeful connection. If this doesn't work, you might have to look at your connection details <?php $dbhost = 'localhost'; $dbuser = 'w187_dxxxxxxx'; $dbpass = 'Dxxxxxxx'; // Connect to database server $conn = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die (mysql_error()); echo "You are now connected to MySQL<br /><br />"; // Select database $dbname = 'employee_directory'; mysql_select_db($dbname,$conn);#Connection call added as second parameter // Get data from the database depending on the value of the id in the URL $query = "SELECT * FROM employee_directory ORDER BY lastname"; $result = mysql_query($query) or die("Query Could Not Be Established".mysql_error()); ?> <table width="50%"> <tr> <th width="3%">ID</th> <th width="48%">Last Name</th> <th width="25%">Cell</th> <th width="24%">Email</th> </tr> <?php $rows = array(); while($allrows = mysql_fetch_array($result))$rows []= $allrows; foreach ($rows AS $row) { echo "<tr>"; echo "<td>".$row['id']."</td>"; echo "<td>".$row['lastname']."</td>"; echo "<td>".$row['cellphone']."</td>"; echo "<td>".$row['email']."</td>"; echo "</tr>"; } //clossing brackets ?> </table>
  4. Uhmm... yes. Validate your form with Javascript/jQuery then submit the form (submit()) to the desired page if no error(s) was found.
  5. Read up form file upload on this link : http://www.w3schools.com/php/php_file_upload.asp Then also learn a little more about MySQL about the move_uploaded_file()
  6. You should probably do this : echo '<a href="?tutor=link">Tutor</a> | <a href="?institute=link">Institute</a>'; if (isset($_REQUEST['tutor'])) { $q = "SELECT 'tutor' AS Member_Type, tutor_code AS Member_Code, tutor_name AS Member_Name FROM tutors"; } elseif (isset($_REQUEST['institute'] { $q = "SELECT 'institute', institute_code, institute_name FROM institutes"; } else { $q = "SELECT 'tutor' AS Member_Type, tutor_code AS Member_Code, tutor_name AS Member_Name FROM tutors UNION SELECT 'institute', institute_code, institute_name FROM institutes"; } $r = mysqli_query( $dbc, $q); echo '<table border="1"> <tr> <td>Member Type</td> <td>Member Code</td> <td>Member Name</td> </tr>'; while ( $row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr> <td>'.$row['Member_Type'].'</td> <td>'.$row['Member_Code'].'</td> <td>'.$row['Member_Name'].'</td> </tr>'; } echo '</table>';
  7. If you must use sessions, just assign an empty session array to loop across each div and session it accordingly. E.g $_SESSION['customer_names'] = array(); foreach ($name_of_customers AS $name_of_customer) { echo '<div>'. $name_of_customer .'</div>'; $_SESSION['customer_names'] [ ] = $name_of_customer } You can always retreive your session contents in the next page by accessing the $_SESSION['customer_names'] array. e.g if (!empty($_SESSION['customer_names']) { foreach ($_SESSION['customer_names'] AS $names) { echo '<div>'. $names .'</div>'; } }
×
×
  • 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.