I'm creating a list/menu form item and populating it from a database,=20
the code snippet looks like this:
<?
$db_name =3D "dbname";
$table_name =3D "endpage";
$connection =3D mysql_connect("localhost", "test", "test") or=20
die("Couldn't connect.");
$db =3D mysql_select_db($db_name, $connection) or die("Couldn't 
select=20=

database.");
$query =3D "select id, productname, bgcolor, imgsrc, cartlink,=20
categorylink, copy, price, titleimg from endpage";
$result =3D mysql_query($query);
$num_results =3D mysql_num_rows($result);
//$row =3D mysql_fetch_array($result);
$id =3D$row['id'];
$productname =3D$row['productname'];
$bgcolor =3D $row['bgcolor'];
$imgsrc =3D $row['imgsrc'];
$cartlink =3D $row['cartlink'];
$categorylink =3D $row['categorylink'];
$copy =3D $row['copy'];
$price =3D $row['price'];
$titleimg =3D $row['titleimg'];
?>=00
<p>Edit an item:</p>
<?
//create a list of editible items
echo "<form method=3Dpost action=3Dedit.php>";
echo "<select name=3Did>";
for ($i=3D0; $i <$num_results; $i++)
{
        $row =3D mysql_fetch_array($result);
        echo "<option value=3D$row[id]> $row[id], =
$row[productname]</option>";
}
echo "</select>";
echo "<input type=3Dsubmit name=3Dsubmit>";
echo "</form>";
?>=00=00

Everything is good, Everything is fine, so I decide to put the same=20
snippet of code in again, this time pointing to a different page -- 
One=20=

page lets you edit the fields, the other shows you the final output,=20
the item from the database featured on a web page.

<p>preview an endpage:</p>

<?
//create a list of editible items
echo "<form method=3Dpost action=3Dpreview.php>";
echo "<select name=3Did>";
for ($i=3D0; $i <$num_results; $i++)
{
        $row =3D mysql_fetch_array($result);
        echo "<option value=3D$row[id]> $row[id], =
$row[productname]</option>";
}
echo "</select>";
echo "<input type=3Dsubmit name=3Dsubmit>";
echo "</form>";
?>=00=00

The second instance does not work, I get a select with "," as each=20
option, no population with the id or productname. Clearly, I don't=20
understand something here, can anyone tell me what?

Thanks for the time,

Michael


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to