data from db to a page and then to another page
am 07.01.2009 10:54:02 von Mika Jaaksi
------=_Part_8690_23184443.1231322042694
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
I already can get the data from database to a page. Now I want to make link
from that data to next page and on that new page it should show all the data
that is related.
example:
data from database
-->
page1 where listed:
band1 (a href)
band2 (a href)
band3 (a href)
....
and when clicking for example band3
-->
page2 where listed band info:
bandname
bandhistory
bandmembers
....
So, how should I do this? Should I somehow use $_POST method to send/deliver
band_id to the next page?
------=_Part_8690_23184443.1231322042694--
Re: data from db to a page and then to another page
am 07.01.2009 15:15:00 von Phpster
The easiest way is to pass the record id via a $_GET and then query
for your record
Bastien
Sent from my iPod
On Jan 7, 2009, at 4:54 AM, "Mika Jaaksi" wrote:
> I already can get the data from database to a page. Now I want to
> make link
> from that data to next page and on that new page it should show all
> the data
> that is related.
>
> example:
>
> data from database
> -->
> page1 where listed:
>
> band1 (a href)
> band2 (a href)
> band3 (a href)
> ...
>
> and when clicking for example band3
> -->
> page2 where listed band info:
>
> bandname
> bandhistory
> bandmembers
> ...
>
> So, how should I do this? Should I somehow use $_POST method to send/
> deliver
> band_id to the next page?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: data from db to a page and then to another page
am 07.01.2009 19:42:53 von Mika Jaaksi
------=_Part_17891_10205852.1231353773184
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Thanks for the aswers, but there is still some problems.
I tested this code(below) and it works but when I add it to the rest of my
code it stops working.
Here's the working code:
page1:
$bandname = "Someband";
?>
and page2:
Bandname is !
_________________________________________________
Now, here's the one I've been fighting with:
include("XXXXXXX.inc.php");
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM band";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "Bands
";
?>
bandname |
---|
$i=0;
while ($i < $num) {
$bandname=mysql_result($result,$i,"bandname");
?>
|
++$i;
}
echo "
";
?>
For some reason this doesn't post bandname to band_info page...
------=_Part_17891_10205852.1231353773184--
Re: Re: data from db to a page and then to another page
am 07.01.2009 23:00:40 von dmagick
Mika Jaaksi wrote:
> Thanks for the aswers, but there is still some problems.
>
> I tested this code(below) and it works but when I add it to the rest of my
> code it stops working.
>
> Here's the working code:
>
> page1:
>
>
> $bandname = "Someband";
> ?>
>
>
> and page2:
>
> Bandname is !
Where are you inserting this data to the bands table? Did it work? Did
you get an error back from mysql?
If you check the db manually, is the data there?
That will at least tell you if the insert is the problem or if it's the
retrieval.
> Now, here's the one I've been fighting with:
>
>
> include("XXXXXXX.inc.php");
> mysql_connect($host,$username,$password);
> @mysql_select_db($database) or die( "Unable to select database");
> $query="SELECT * FROM band";
> $result=mysql_query($query);
>
> $num=mysql_numrows($result);
If you're going to show all results, you could probably do this:
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
}
Saves keeping a counter, doing a mysql_num_rows etc.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php