[PHP-DB] Re: data from db to a page and then to another page

2009-01-07 Thread Mika Jaaksi
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]; ?!

_

Now, here's the one I've been fighting with:

?
include(XXX.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 bcenterBands/center/bbrbr;

?
table border=0 cellspacing=2 cellpadding=2
tr
thfont face=Arial, Helvetica, sans-serifbandname/font/th
/tr

?
$i=0;
while ($i  $num) {
$bandname=mysql_result($result,$i,bandname);
?
tr
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
/tr
?
++$i;
}
echo /table;
?

For some reason this doesn't post bandname to band_info page...


Re: [PHP-DB] Re: data from db to a page and then to another page

2009-01-07 Thread Chris

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(XXX.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