Forum Moderators: coopster

Message Too Old, No Replies

outputing values from mysql table

         

alenka99

2:24 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



I have problems with outputing values from a table in database

at below code i dont know how to output more then just one variable!
Please help
---------------

$result_array = array();
for ($count = 1; $row = mysql_fetch_row ($resultt); ++$count)
{
$result_array[$count] = addslashes($row[0]);
}
return $result_array;
}
-----------------------
function display_user_results

function display_user_results($result_array)
{
global $result_table;
$result_table = true;
?>
<br />
<form name=result_table action="delete_results.php" method=POST>
<table bgcolor=#bde1f0>
<?php
$color = "#3194ce";
if (is_array($result_array) && count($result_array)>0)
{
foreach ($result_array as $ex1, $ex2, $ex3, $ex4, $ex5, $ex6, $ex7, $ex8, $ex9, $ex10, $ex11, $ex12, $ex13, $ex14, $ex15, $ex16, $ex17, $ex18, $ex19, $ex20, $ex21, $ex22, $ex23, $ex24, $sum)
{

echo "<tr bgcolor=$color><td><a href=\"$ex1\">".htmlspecialchars($ex1)."</a></td>";
echo "</tr>";

<removed repetitive code>

echo "<tr bgcolor=$color><td><a href=\"$sum\">".htmlspecialchars($sum)."</a></td>";
echo "</tr>";
}
}
else
echo "<tr><td>Trenutno ni nobenega zapisa.</td></tr>";
?>
</table>
</form>
<?php
}
lp Alenkolina

[edited by: jatar_k at 5:24 pm (utc) on Jan. 19, 2004]
[edit reason] fixed sidescroll [/edit]

jatar_k

7:54 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld alenka99,

i dont know how to output more then just one variable!

I am not sure what you mean exactly. Do you mean only 1 row or that none of those variables output at all?

alenka99

8:34 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



here were the error acures.
I dont know how foreach works and if i can say $result_array as $ex1,...-->can here be more variables enumerated?

I just have to output them here on the screen. I allredy have them in the database.

foreach ($result_array as $ex1, $ex2, $ex3, $ex4, $ex5, $ex6, $ex7, $ex8, $ex9, $ex10, $ex11, $ex12, $ex13, $ex14, $ex15, $ex16, $ex17, $ex18, $ex19, $ex20, $ex21, $ex22, $ex23, $ex24, $sum)

jatar_k

8:49 pm on Jan 16, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try it this way

foreach ($result_array as $ex) {

and then access each one as

$ex[0]
$ex[1]
$ex[2]
$ex[3]
$ex[4]
...
etc

alenka99

8:18 am on Jan 17, 2004 (gmt 0)

10+ Year Member



I did not mean to access the parts of a colon, i have a 26 colons in the tabel and i need to output them on the screen for users to see.

Maybe i did not declare my problem the write way, sorry for that but my english is not so very good.

SO: in a database there is a tabel like:
userEx1 Ex2...Ex24sum
gh 2 3 05
fg0 0 11
...

And that tabel should appear on the users screen.

Have i been at least a little been clearer.

Alenka

BitBanger

4:49 pm on Jan 17, 2004 (gmt 0)

10+ Year Member



There are a couple of ways to do what you want. Based on your existing html code this is probably the easiest. Instead of using 'foreach (....' replace it with:

list($user, $ex1, $ex2, $ex3, $ex4, $ex5, $ex6, $ex7, $ex8, $ex9, $ex10, $ex11, $ex12, $ex13, $ex14, $ex15, $ex16, $ex17, $ex18, $ex19, $ex20, $ex21, $ex22, $ex23, $ex24, $sum) = $result_array;

Then use the existing html code to display the data.

Another way is to replace the entire foreach loop you have (including the html code) and replace it with:


$numelements = count($result_array);
for ($i=1;$i<$numelements;$i++) {
echo "<tr bgcolor=$color><td><a href=\"{$result_array[$i]}\">".htmlspecialchars({$result_array[$i]})."</a></td>";
echo "</tr>";
}

This will output the entire array except the first entry which should be the user name. By using '$numelements' the code will auto adjust to however many elements are actually in the array instead of being hardcoded to 26.

Hope this is of some use.

alenka99

10:24 am on Jan 18, 2004 (gmt 0)

10+ Year Member



Thanks for the answers. The last solution outputed the tabel, but i couldnt get it to output the users values.

Then i got another solution and this one works very well but there is one mistake--Every time user clicks refresh button the values are stored in the database again. So if user clicks refresh button the output doubles.

My code now is:

$x1a = 1;
$x1aa = 2;
$x1b = 1;
$x1bb = 3;
$x2a = 0;
$x2aa = 0;
$x2b = 0;
$x2bb = 0;
$x2c = 0;
$x2cc = 4;
$x3a = 6;
$x3b = 5;
$x3c = 6;
$x4a = 6;
$x4b = 6;
$x5a = 4;
$x5b = 6;
$x5c = 6;
$x6pl = 6;
$x6ob = 6;
$x7a = 5;
$x7b = 6;
$x8a = 0;
$x8b = 0;
$x8c = 0;
$x9 = 0;
$x10 = 0;
$x11a = 0;
$x11b = 0;
$x12 = 0;
$sum = 55;

// poskusi dodati zapis
if (add_result($x1a,$x1aa,$x1b,$x1bb,$x2a,$x2aa,$x2b, $x2bb,$x2c,$x2cc,$x3a,$x3b,$x3c,$x4a,$x4b,$x5a,$x5 b,$x5c,$x6pl,$x6ob,$x7a,$x7b,$x8a,$x8b,$x8c,$x9,$x10,$x11a,$x11b,$x12,$sum))
echo '<p>&nbsp</p>Tvoji rezultati so bili shranjeni v bazo.<p>&nbsp</p>';
else
echo '<p>&nbsp</p>Zapisa ni bilo mogoče dodati.<p>&nbsp</p>';

global $HTTP_SESSION_VARS;
$valid_user = $HTTP_SESSION_VARS['valid_user'];

$connection=db_connect();
$query = "SELECT * FROM results WHERE username='$valid_user'";
$result = mysql_query($query , $connection) or die("<b>Query Failed</b><br>\n".$query."<br>\n".mysql_errno().": ".mysql_error());

// poberi imena polj iz baze
$total_number_of_fields = mysql_num_fields($result);
for ($i = 0; $i < $total_number_of_fields; $i++) {
$keys[$i] = mysql_field_name($result , $i);
}

$color="#3194ce";
// začni tabelo
echo "<center><table bgcolor=#bde1f0>";

// naslovna vrstica
echo "<tr bgcolor=$color>";
foreach ($keys as $key) {
echo "<td><strong>".$key."</strong></td>";
}
echo "</tr>";

// rezultati
while ($row = mysql_fetch_assoc($result)) { // čez vse vrstice
echo "<tr>";
foreach ($keys as $key) { // čez vsako kolono te vrstice
echo "<td>";
echo (is_null($row[$key]) && empty($row[$key]))? "&nbsp;" : $row[$key];
echo "</td>";
}
echo "</tr>";
}

echo "</table></center><p>&nbsp</p>";

// sprosti rezultate iz spomina
mysql_free_result($result);
unset($keys,$row);
mysql_close($connection);

The connection with database is made before, i di not put the code in here.

LP Alenka

alenka99

10:35 am on Jan 18, 2004 (gmt 0)

10+ Year Member



Oh ja and i would like to have an option for users that they could delete outputs they would choose. Any suggestions how to do that.

Thanks, alenka

BitBanger

2:54 pm on Jan 18, 2004 (gmt 0)

10+ Year Member



alenka99:
Thanks for the answers. The last solution outputed the tabel, but i couldnt get it to output the users values.

Sorry, I erred in the code I posted. Here is the correction.

echo "<tr bgcolor=$color><td><a href=\"{$result_array[$i]}\">".htmlspecialchars($result_array[$i])."</a></td>";
echo "</tr>";
}

I escaped the results in the htmlspecialchars() function call when I shouldn't have.

alenka99

10:46 am on Jan 19, 2004 (gmt 0)

10+ Year Member



Thanks for all your help Bit Banger but i still didnt get it to work.
Al i can think now is to paste all the code i have for this script and ask you to look at it, but i know there is a lot to ask.

So i wil totaly understand if you will say go to hell.

But since i dont have anyone to ask i will try anyway.

The code:

1.add_results.php--> here i must add that variables have constant values, since it is easier to work. i will change them then when my script wil work fine

<modnote>Way too much code see charter [webmasterworld.com] re: code dumps</modnote>

Whell that is all the code i have, as i have said i woul extremly appreciate if you could look at the code and help me.

BY, Alenka

[edited by: jatar_k at 5:25 pm (utc) on Jan. 19, 2004]

BitBanger

2:45 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



First of all, do you want the output to display horizontally, or vertically? Your header suggests that you want a vertical output, while the data portion suggests a horizontal layout. Based on your code structure, a horizontal layout is easier.

Appologies in advance. I know english is not your first language, so I will describe my terms.


Horizontal:
¦ Nal 1.a) ¦ Nal 1.aa) ¦ Nal 1.b) ¦ Nal 1.bb) ¦ ... ¦
¦ 1 ¦ 1 ¦ 1 ¦ 1 ¦ ... ¦
.
.

Vertical:
¦ Nal 1.a) ¦ 1 ¦
¦ Nal 1.aa) ¦ 1 ¦
¦ Nal 1.b) ¦ 1 ¦
¦ Nal 1.bb) ¦ 1 ¦
.
.
.


The columns do not line up, but hopefully you can see what I mean.

I'm assuming that $results_array actually does contains the data you want. Do you get any output at all from your existing code?

For a horizontal output, replace your display_user_results function with the following.

function display_user_results($result_array)
{
//prikaži tabelo zapisov

// postavi globalno spremenljivko, da bomo kasneje lahko testirali kaj je na strani
global $result_table;
$result_table = true;
?>
<br />
<form name=result_table action="delete_results.php" method=POST>
<table bgcolor=#bde1f0>
<?php
$color = "#3194ce";
echo "<tr bgcolor=$color>
<td><strong>Nal 1.a)</strong></td>";

<snipped extra code>

<td><strong>Nal 12.</strong></td>";
<td><strong>Vsota</strong></td>";
echo "<td><strong>Zbriši?</strong></td>";
echo "</tr>";

if (is_array($result_array) && count($result_array)>0) {
$numelements = count($result_array);
echo "<tr bgcolor=$color>";
for ($i=1;$i<$numelements;$i++) {
echo "<td><a href=\"{$result_array[$i]}\">".htmlspecialchars($result_array[$i])."</a></td>";
}
echo "</tr>";
}
else
echo "<tr><td>Trenutno ni nobenega zapisa.</td></tr>";
?>
</table>
</form>
<?php
}

Mostly this changes your header into a single row of <td>'s followed by a single row of the data in $result_array. Changing this into a vertical list is a bit more complicated, but lets see if this code works first.

Also, please describe what you see and what you think needs to be fixed. This will make debugging easier.

[edited by: jatar_k at 5:17 pm (utc) on Jan. 19, 2004]
[edit reason] see note in msg 10 [/edit]

alenka99

4:42 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



Hey there, i realy appreciate your help, but i still didnt get it to work. The problem is that the record are sabed in the database-->i can check that with PHPMyAdmin. So the problem is in displaying them. The horizontal way would be even better, but the results do not display anyway.

See now i got the another solution for displaying the records but here i have another problem, cos i dont know how to add a colon for deleting the records.

The below script is what i have now:

if (add_result($x1a,$x1aa,$x1b,$x1bb,$x2a,$x2aa, $x2b,$x2bb,$x2c,$x2cc,$x3a,$x3b,$x3c,$x4a,$x4b, $x5a,$x5b,$x5c,$x6pl,$x6ob,$x7a,$x7b,$x8a,$x8b, $x8c,$x9,$x10,$x11a,$x11b,$x12,$sum))
echo '<p>&nbsp</p><h3>Tvoji rezultati so bili shranjeni v bazo.</h3>Za ogled rezultatov bazi klikni na spodnji link Moji rezultati.<p>&nbsp</p>';
else
echo '<p>&nbsp</p>Zapisa ni bilo mogoče dodati.<p>&nbsp</p>';

global $HTTP_SESSION_VARS;
$valid_user = $HTTP_SESSION_VARS['valid_user'];

$connection=db_connect();
$query = "SELECT * FROM results WHERE username='$valid_user'";
$result = mysql_query($query , $connection) or die("<b>Query Failed</b><br>\n".$query."<br>\n".mysql_errno().": ".mysql_error());

// poberi imena polj iz baze
$total_number_of_fields = mysql_num_fields($result);
for ($i = 0; $i < $total_number_of_fields; $i++) {
$keys[$i] = mysql_field_name($result , $i);
}

$color="#3194ce";
// začni tabelo
echo "<center><table bgcolor=#bde1f0>";

// naslovna vrstica
echo "<tr bgcolor=$color>";
foreach ($keys as $key) {
echo "<td><strong>".$key."</strong></td>";
}
echo "</tr>";

// rezultati
while ($row = mysql_fetch_assoc($result)) { // čez vse vrstice
echo "<tr>";
foreach ($keys as $key) { // čez vsako kolono te vrstice
echo "<td>";
echo (is_null($row[$key]) && empty($row[$key]))? "&nbsp;" : $row[$key];
echo "</td>";
}
echo "</tr>";
}

echo "</table></center><p>&nbsp</p>";

// sprosti rezultate iz spomina
mysql_free_result($result);
unset($keys,$row);
mysql_close($connection);

[edited by: jatar_k at 5:21 pm (utc) on Jan. 19, 2004]

BitBanger

5:08 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



So the latest code should display a single row of labels, followed by a single row of data. Does it display correctly?

When you say you want to delete the results, do you mean the entire user record? Or do you want to delete a single result?

alenka99

6:01 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



Yes this code displays users records and with option for deleting i ment to delte the entire user record.

Let as say that curent user has saved 5 records and he has decided that he wants to delete the first and the third record,m the whole row.

I would like to have at the end of each row a button for deliting a record or an option to check if a user wants to delete marked record.

I hope i explained a little better.

lp Alenka

BitBanger

6:46 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



Yes, that better describes the problem.

Lets do this in steps.
The first issue is to uniquely identify every record in the database. The simplest way to do that is to add a primary key field named 'ID' and set it to NOT NULL and auto_increment. This should be simple to do if you are using phpMyAdmin to setup your table.

Next you need to add a single column to your output table with something like this as it's content:


echo "<td><a href=\"del_record.php?id={$row['ID']}&amp;return_to={$_SERVER['PHP_SELF']}\">Delete</a></td>";

This should go inside the 'while' loop, after the 'foreach' loop where you dump the actual data to the table.

Now create another php file named 'del_record.php' in the same directory as your current code. In it you will need something like:


<?php
include ('<your db_connect() code>');
$connection=db_connect();
mysql_query("DELETE FROM results WHERE `ID`={$_GET['id']} LIMIT 1");
header ("Location: {$_GET['return_to']}");
?>

If everything works right, clicking on the new 'Delete' link will load the new del_record.php which will delete the row, then refresh the current page. You will need to make sure you properly handle this refresh. In other words, do not add the record back into the table.

There is little error checking in this code, and there are some security issues that should be looked at.

alenka99

7:48 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



UOU thanks i wil try it but tomorow cos i am prety tired tonight.

For tonight i would have just one more question-->is it posible to prevent that user could click the refresh button on IE or that the page would ignore the clicked refresh button-->see i have problems with doubeling the records saved in the database.

lp Alenka

alenka99

8:05 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



OR even better it would be if i could do the following:
When a user would click on the button called insert into databse the function add_result() would execute instead of some .php page and would have to allow clicking on the button just once.

Big problems i have, dont i.

Thanks, Alenka

BitBanger

8:55 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



I assume that the data will get into the page using a form. If this is the case, then try replacing:

$x1a = 1;
$x1aa = 2;
.
.
.
$x12 = 0;
$sum = 55;

// poskusi dodati zapis
if (add_result($x1a,$x1aa,$x1b,$x1bb,$x2a,$x2aa,$x2b,
$x2bb,$x2c,$x2cc,$x3a,$x3b,$x3c,$x4a,$x4b,$x5a,$x5b,
$x5c,$x6pl,$x6ob,$x7a,$x7b,$x8a,$x8b,$x8c,$x9,$x10,$x11a,$x11b,$x12,$sum))
echo '<p>&nbsp</p>Tvoji rezultati so bili shranjeni v bazo.<p>&nbsp</p>';
else
echo '<p>&nbsp</p>Zapisa ni bilo mogoče dodati.<p>&nbsp</p>';


With:

$x1a = 1;
$x1aa = 2;
.
.
.
$x12 = 0;
$sum = 55;

if(isset($_POST['submit'])) {
// poskusi dodati zapis
if (add_result($x1a,$x1aa,$x1b,$x1bb,$x2a,$x2aa,$x2b,
$x2bb,$x2c,$x2cc,$x3a,$x3b,$x3c,$x4a,$x4b,$x5a,$x5b,
$x5c,$x6pl,$x6ob,$x7a,$x7b,$x8a,$x8b,$x8c,$x9,$x10,$x11a,$x11b,$x12,$sum))
echo '<p>&nbsp</p>Tvoji rezultati so bili shranjeni v bazo.<p>&nbsp</p>';
else
echo '<p>&nbsp</p>Zapisa ni bilo mogoče dodati.<p>&nbsp</p>';
}
echo "<form name=\"input_data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">
echo "<input type=\"submit\" value=\"Submit\"></input>
echo "</form>

Later you can replace all the assigns like '$x1a = 1;' with '$x1a = $_POST['x1a']' and add and '<input type="text" name="x1a"></input>' to the form.

Right now this will place a submit button that will only update the database when it is pressed. Later, by adding all the 'form' elements instead of the assigns, it will allow the user to input the data into the database.

Again, this is a simplified version. You will need to add error checking.

alenka99

9:35 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



There is a problem becouse my pages test.php and validation for that test are separated. I have to php pages: test.php and validate.php. And i had done the part with if (isset...) but since i am validating the test on the other page then submit button is putted i can not prevent that, since the $_POST['submit'] is allwys true.
The test and validation are separated becouse they are both very long.

Now i have made it so, that function for adding the recors is separated from the validatin. But whatever i do i can not prevent that user could refresh the page where the function add_record is called and in that case the output doubles.

I hope you can see where is the problem.

l Alenka

alenka99

9:36 pm on Jan 19, 2004 (gmt 0)

10+ Year Member



Oh ja and i just had these done for easier reading:

'$x1a = 1;' with '$x1a = $_POST['x1a']'

In the code i am using i use $_POST for transfering the variables just made the way you wrote.

alenka99

9:37 am on Jan 20, 2004 (gmt 0)

10+ Year Member



Hey BITBANGER.
So much thanks for advice how to delete records. I have made it so and it works great except for two things:
1. my add_result function doesnot work anymore:
$x1a = $_POST['x1a'];
$x1aa = $_POST['x1aa'];...

if (add_result($x1a,$x1aa,$x1b,$x1bb,$x2a,$x2aa,$x2b, $x2bb,$x2c,$x2cc,$x3a,$x3b,$x3c,$x4a,$x4b,$x5a, $x5b,$x5c,$x6pl,$x6ob,$x7a,$x7b,$x8a,$x8b,$x8c, $x9,$x10,$x11a,$x11b,$x12,$sum))
{
echo '<p>&nbsp</p><h3>Tvoji rezultati so bili shranjeni v bazo.<p></h3>Za ogled rezultatov v bazi klikni na spodnji link Moji rezultati ali pa na povezavo:</p>';
do_html_URL('display_results.php','<center>Želim si ogledati rezultate shranjene v podatkovni bazi!</center>');
echo '<p>&nbsp</p>';
}
else
echo '<p>&nbsp</p>Zapisa ni bilo mogoče dodati.<p>&nbsp</p>';

2. the ID number is shown on the screen but i would like just to be writen Delete without the Id number.

Thanks a lot, i just hope you can help me a little more with that thing to work properly.

BY Alenka

[edited by: jatar_k at 4:29 pm (utc) on Jan. 20, 2004]
[edit reason] sidescroll [/edit]

alenka99

10:44 am on Jan 20, 2004 (gmt 0)

10+ Year Member



Sorry, my mistake for the ID number output--> i have resolve it now, but the function add_result stil doesnot work.

Should there be insreted the $ID too?

BitBanger

2:13 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



No, you do not need to insert the ID field. It is handled automatically by the database.

One thing that I have found that helps in debugging SQL statements is to echo the query to the screen. Then copy that query to the SQL window of phpMyAdmin. If there is a syntax error in the SQL statement, then phpMyAdmin will point you to where the error is.

alenka99

2:57 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



Sorry now i realy dont understand you.

Did you mean to do the following:
echo "mysql_query( "insert into results values
('$valid_user', '$x1a', '$x1aa', '$x1b', '$x1bb', '$x2a', '$x2aa', '$x2b', '$x2bb', '$x2c', '$x2cc', '$x3a', '$x3b', '$x3c', '$x4a', '$x4b', '$x5a', '$x5b', '$x5c', '$x6pl', '$x6ob', '$x7a', '$x7b', '$x8a', '$x8b','$x8c', '$x9', '$x10', '$x11a', '$x11b', '$x12', '$sum' )"));";

This returns me the parse error on the screen unexpecting t_string, expecting ; or,

Can you please look at my function add_result and try to tel me what is wrong with it.

Thanks, alenka

alenka99

3:21 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



It has to be something wrong with the ID field in the database since even the old version doesnot work anymore.
Do you have any idea what could it be?

This is how i have putted into the database table:
ID bigint(20) not null auto_increment Spremeni Zavrži Primary Indeks Unique full text

I have tried to putt varchar but it did not work either

BitBanger

4:19 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



Did you mean to do the following:
echo "mysql_query( "insert into results values
('$valid_user', '$x1a', '$x1aa', '$x1b', '$x1bb', '$x2a', '$x2aa', '$x2b', '$x2bb', '$x2c', '$x2cc', '$x3a', '$x3b', '$x3c', '$x4a', '$x4b', '$x5a', '$x5b', '$x5c', '$x6pl', '$x6ob', '$x7a', '$x7b', '$x8a', '$x8b','$x8c', '$x9', '$x10', '$x11a', '$x11b', '$x12', '$sum' )"));";

No, I meant:


$query = "insert into results values ('$valid_user', '$x1a', ... )";
echo $query;
mysql_query($query);

In any case, the query is not valid. Since you don't want to insert the `ID` field, but let the database manage it, you must identify the columns that you do want inserted.

Please refer to h**p://www.mysql.com/doc/en/INSERT.html for details.

A quote from the above manual page:

If you specify no column list for INSERT ... VALUES or INSERT ... SELECT, values for all columns in the table must be provided in the VALUES() list or by the SELECT. If you don't know the order of the columns in the table, use DESCRIBE tbl_name to find out.

Change the query to this form:

"INSERT INTO results (col1,col2,...) VALUES ('$valid_user', '$x1a', ...)"

Where (col1,col2,...) is a list of the field names you want to insert in the same order as the data you are inserting. Any field not listed will take it's default value. Use the same syntax for an UPDATE which allows you to do a partial record update.

The online manuals for MySQL and PHP are great resources for learning how to use them.

alenka99

4:42 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



Now i did what you told me to do and the error i get is:

Column count doesn't match value count at row 1

jatar_k

4:51 pm on Jan 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Then you are trying to insert more or fewer values than there are in the actual table.

Take a look at the columns in the table and try to match them up with your insert statement.

alenka99

5:03 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



Dont know. This are the fields i have in the database
username varchar(16)
1a int(11)
1aa int(11)
1b int(11)
1bb int(11)
2a int(11)
2aa int(11)
2b int(11)
2bb int(11)
2c int(11)
2cc int(11)
3a int(11)
3b int(11)
3c int(11)
4a int(11)
4b int(11)
5a int(11)
5b int(11)
5c int(11)
6pl int(11)
6ob int(11)
7a int(11)
7b int(11)
8a int(11)
8b int(11)
8c int(11)
9 int(11)
10 int(11)
11a int(11)
11b int(11)
12 int(11)
sum int(11)
id bigint(20)
and except the id field whitch is auto_increment i try to insert in every other with:
if (!mysql_query( "INSERT INTO results (username,1a,1aa,1b,1bb,2a,2aa,2b,2bb,2c,2cc,3a,3b,3c,4a,4b,5a,5b,5c,6pl,6ob,7a,7b,8a,8b,8c,9,10,11a,11b,12,sum) VALUES ('$valid_user', '$x1a', '$x1aa', '$x1b', '$x1bb', '$x2a', '$x2aa', '$x2b', '$x2bb', '$x2c', '$x2cc', '$x3a', '$x3b', '$x3c', '$x4a', '$x4b', '$x5a', '$x5b', '$x5c', '$x6pl', '$x6ob', '$x7a', '$x7b', '$x8a', '$x8b','$x8c', '$x9', '$x10', '$x11a', '$x11b', '$x12', '$sum' )"))
return false;

return true;

where: $x1a = $_POST['x1a'];...

I am realy confused. The only thing i changed from when it was working is that have added a field id into the databse table

I realy have no clue anymore.

Please help me if you can.

LP Alenka

alenka99

5:15 pm on Jan 20, 2004 (gmt 0)

10+ Year Member



Now i have found out-->the fields name shouldnt be just the number or what-->i realy did not know that!

But i still do not get it why did it work before?

Strange thing happen in my life every day.

Thanks to all of you for helping me. If someone knows what megic thing happend please explain to me.

lp Alenka

This 32 message thread spans 2 pages: 32