MrTV
asked on
change php code to allow user input variaable
The code below how can i change the code so that user can change
$result = mysql_query(" SELECT * FROM `prdmas`
WHERE `Shelf1` =71 AND `Stare1` =1 ORDER BY course");
Shelf1` =71 AND `Stare1` =1 some time user want to in put Shelf1 is 70 , 69 70 or Stare1` = 4 ,3
etc
<?php
// connect to the database
mysql_connect(hostname,use rname,pass word);
// select the database
mysql_select_db(database) or die("Unable to select database");
// run the query and put the results in an array variable called $result
$result = mysql_query(" SELECT * FROM `prdmas`
WHERE `Shelf1` =71 AND `Stare1` =1 ORDER BY course");
// start a counter in order to number the input fields for each record
$i = 0;
// open a form
print "<form name='namestoupdate' method='post' action='update.php'>\n";
// start a loop to print all of the courses with their book information
// the mysql_fetch_array function puts each record into an array. each time it is called, it moves the array counter up until there are no more records left
while ($books = mysql_fetch_array($result) ) {
// assuming you have three important columns (the index (id), the course name (course), and the book info (bookinfo))
// start displaying the info; the most important part is to make the name an array (notice bookinfo[$i])
print "<input type='hidden' name='id[$i]' value='{$books['id']}' />";
print "<p>{$books['course']}: <input type='text' size='40' name='bookinfo[$i]' value='{$books['bookinfo'] }' /></p>\n";
// add 1 to the count, close the loop, close the form, and the mysql connection
++$i;
}
print "<input type='submit' value='submit' />";
print "</form>";
mysql_close();
?>
$result = mysql_query(" SELECT * FROM `prdmas`
WHERE `Shelf1` =71 AND `Stare1` =1 ORDER BY course");
Shelf1` =71 AND `Stare1` =1 some time user want to in put Shelf1 is 70 , 69 70 or Stare1` = 4 ,3
etc
<?php
// connect to the database
mysql_connect(hostname,use
// select the database
mysql_select_db(database) or die("Unable to select database");
// run the query and put the results in an array variable called $result
$result = mysql_query(" SELECT * FROM `prdmas`
WHERE `Shelf1` =71 AND `Stare1` =1 ORDER BY course");
// start a counter in order to number the input fields for each record
$i = 0;
// open a form
print "<form name='namestoupdate' method='post' action='update.php'>\n";
// start a loop to print all of the courses with their book information
// the mysql_fetch_array function puts each record into an array. each time it is called, it moves the array counter up until there are no more records left
while ($books = mysql_fetch_array($result)
// assuming you have three important columns (the index (id), the course name (course), and the book info (bookinfo))
// start displaying the info; the most important part is to make the name an array (notice bookinfo[$i])
print "<input type='hidden' name='id[$i]' value='{$books['id']}' />";
print "<p>{$books['course']}: <input type='text' size='40' name='bookinfo[$i]' value='{$books['bookinfo']
// add 1 to the count, close the loop, close the form, and the mysql connection
++$i;
}
print "<input type='submit' value='submit' />";
print "</form>";
mysql_close();
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.