Re: Re: data from db to a page and then to another page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

<?php
$bandname = "Someband";
?>
<form name="goto_info" action="band_info.php" method="post">
<input type="hidden" name="bandname" value="<?php echo $bandname; ?>">
<a href="band_info.php?bandname=$bandname" onclick="goto_info.submit();
return false;"><?php echo $bandname; ?></a>
</form>

and page2:

Bandname is <?php echo $_POST["bandname"]; ?>!

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux