-   Programming (
-   -   MySQL/PHP - checkboxes etc (

linuxfond 05-06-2004 05:12 PM

MySQL/PHP - checkboxes etc

Sorry for not doing my homework. Naturally, I should figure this out myself, but at this moment I got no time for this, hence I ask for your, LQ experts', help.

Here is a simple code:



$link = mysql_connect("localhost","root","");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM periodicals" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=70% border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
print "</table>\n";

Obviously, it connects to the database "bibliography" and produces an HTML output with the contents of the table "periodicals". All this is perfect, but, not useful. I need the results to appear in a table containing a form, which will display a checkbox next to each raw so that I can check it and insert into the next page by hitting on Subimt button. I might need to check a few checkboxes in order to pick up more than one record. Tonight I spent well over four hours, and I am still not arriving at anything working. A little hint would get me started. Thank you.

Mara 05-06-2004 05:22 PM

One of the rules is that we don't do homeworks, so you'll get a tip...For every entry you get from your SELECT create a checkbox with an unique name. When you then click 'submit' your next script will have the values of checked checkboxes.

linuxfond 05-07-2004 05:12 AM

Thanks. I will try that. In a mean time try to bundle ODBC with the OpenOffice. Maybe that's the tool wich I could customise to do what I need.

All times are GMT -5. The time now is 08:57 AM.