got this code from internet and is suppose to show records from database but all i get is a white blank screen if any one can help cheers Doug <? error_reporting(E_ALL); // Connect database dbh=mysql_connect("localhost", "car", "57") or die('I cannot connect to database because: ' .mysql_error()) ; mysql_select_db("users"); // Get all records in all columns from table and put it in $result. $result=mysql_query("select * from phonebook"); while($row=mysql_fetch_assoc($result)){ // Output Echo "ID : $row['id'] <br/>"; Echo "Name : $row['name'] <br/>"; Echo "Email : $row['email'] <br/>"; Echo "Tel : $row['tel'] <hr>"; // Add a link with a parameter(id) and it's value. Echo '<a href="update.php?id='.$row['id'].'">Update</a>'; } mysql_close(); ?> PHP:
Hi, It may be some missing letters and case sensitive issues. Please have a look at my code: <?php error_reporting(E_ALL); // Connect database $dbh=mysql_connect("localhost", "car", "57") or die('I cannot connect to database because: ' .mysql_error()) ; mysql_select_db("users"); // Get all records in all columns from table and put it in $result.$result=mysql_query("select * from phonebook"); while($row=mysql_fetch_assoc($result)) { // Output Echo "ID : $row['id'] <br/>"; echo "Name : $row['name'] <br/>"; echo "Email : $row['email'] <br/>"; echo "Tel : $row['tel'] <hr>"; // Add a link with a parameter(id) and it's value. echo '<a href="update.php?id='.$row['id'].'">Update</a>'; } mysql_close($dbh); ?> PHP:
What kind of web server are you using (xampp, etc)? And what is your OS (Windows, Mac, Linux)? Perhaps there is something wrong with the configuration.
this code work for display on screen //Retrieves data from MySQL $data = mysql_query("SELECT * FROM members WHERE region='exchange' OR region='EXCHANGE/HIRE' or region='EXCHANGE' or region='HIRE'") or die(mysql_error()); if(mysql_num_rows( $data ) == 0) { echo 'No Results'; } else { //Puts it into an array $i=1; echo "<table>"; while($info = mysql_fetch_array( $data )) { echo "<tr> <td>$i</td> <td>". $info['name'] ."</td> <td>". $info['username'] ."</td> <td>". $info['email'] ."</td> </tr>"; $i++; } echo "</table>"; } ?> PHP: but hasnt got the update on it echo '<a href="update.php?id='.$row['id'].'">Update</a>'; how do i code this line to fit in with above
you can do like this: //Retrieves data from MySQL $data = mysql_query("SELECT * FROM members WHERE region='exchange' OR region='EXCHANGE/HIRE' or region='EXCHANGE' or region='HIRE'") or die(mysql_error()); if(mysql_num_rows( $data ) == 0) { echo 'No Results'; } else { //Puts it into an array $i=1; echo "<table>"; while($info = mysql_fetch_array( $data )) { echo "<tr> <td>$i</td> <td>". $info['name'] ."</td> <td>". $info['username'] ."</td> <td>". $info['email'] ."</td>"; echo '<td><a href="update.php?id='.$row['id'].'">Update</a></td>'; echo "</tr>"; $i++; } echo "</table>"; } PHP: