PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi I was wondering how do u echo out all of the containt of the database.
I got a simple code where i get a users id "unique number for everyone" and what i would like to get is so that when i:
<html>
<head>
<title>Two By Two Game</title>
</head>
<body bgcolor="#A4A8B0">
<center><h1>Users</h1>
<?php
include "../login/database.php";
$users =(isset($_GET['users'])) ? (int)$_GET['users'] : false;
if($users !== false)
{
$sqls="SELECT * FROM konto WHERE saved_id=$users"; //selecting all from DB "Konto" where saved_id is the same as in the array $id
}
else
{
echo "NO saved_id!"."<br>";
}
$results = mysql_query($sqls) or die("Kunde inte lägga till ny text:<br />" . mysql_error());//Skicka info till tabell.
while($rows = mysql_fetch_array( $results )) //fetching info from file and putting it in $row
{
echo $All Of The Database."<br>";
}
?>
</body>
</html>
now where it sais echo "$All Of The Database" there i want it to echo out all that is within the database where id is id.
If you want to print everything in the database, then you have to iterate through each table OR use various join queries to make a meaningful data stream.
In any case, here is how you iterate through a table. The same thing would apply to any other type of join query. Experiment to meet your needs.
Ok so that is the basic echo the fields one by one but say like i create one new field every "min"(Hypothesis) now i want 1 command to echo out all the tables all new as for the old. Is there a way?
I am looking for a echo whole database command. Is there or do i need to insert a new code snippet everytime there is a new field in the database?
There is no built in command, you need to write it yourself. You can use the example Jake gave you, but instead of outputting the fields manually you can iterate over the returned row.