this is my first post here - so hello people!
now to my question: i did a dynamic linklist where everybody can enter url's and they are shown again in the list, so this part works quite well already. i gave the values in the database an ID (it's an own column) and i use this to query specific lines. now when i wanna update one value thats no problem but when i wanna delete the whole row i have one missing ID-number which hinders my query from working right, so i would have to replace the ID after every delete - now my question is is there any way to read the line-number without giving it an explicit ID, i read about that row_pointer but i don't really know how to use it yet, is it incremented by every operation quite like a streamreader or do i have to set it? and is it possible to do a query like WHERE row_pointer = something... ?
thanks in advance!
oh and another thing: what data-type should i take to store a complete file (about 1 -2 mb) in a database - i know this might sound strange but it would really help me...
how to use row_pointer
Moderator: General Moderators
i think i found what i am looking for:
$result = @mysql_fetch_array($resultset)
my problem was that i could query like SELECT all data WHERE bla = 0 but then i couldn't read the single lines within the result, only the first one, so i did that query for every single ID again and again... will have to try that if it works, anyway thanks for the reply!
btw: i'm gonna remake the whole thing anyway (probably not for the last time), somehow i never manage to have a program done - there's always something to change - i mean this one is already running but it's performance should be horrible and it's ugly code ;o) guess you know what i mean...
$result = @mysql_fetch_array($resultset)
my problem was that i could query like SELECT all data WHERE bla = 0 but then i couldn't read the single lines within the result, only the first one, so i did that query for every single ID again and again... will have to try that if it works, anyway thanks for the reply!
btw: i'm gonna remake the whole thing anyway (probably not for the last time), somehow i never manage to have a program done - there's always something to change - i mean this one is already running but it's performance should be horrible and it's ugly code ;o) guess you know what i mean...
Is this what you're looking for:
Code: Select all
<?php
$mysql = "SELECT * FROM table_name";
$query = mysql_query($mysql) or die("Cannot query the database.<br>" . mysql_error());
while ($result = mysql_fetch_array($query)) {
echo $result['column1'];
echo $result['column2'];
echo $result['column2'];
// .. etc
}
?>
Last edited by McGruff on Thu Aug 11, 2005 11:17 am, edited 1 time in total.
well that's not exactly what i wanted to do but i will adjust my program anyway so this will have to work:
i didn't know that every mysql_fetch_row gives the next row, so i did every time a new query for the next line-ID-number i have in my table...
this way i still can't say give me the stuff at row-number 3 or something (without having a lineID-column to query) but you can't have everything...
thanks for helping!
Code: Select all
<?
$connection = @mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname) or die( "Unable to select database");
if (!$connection)
{
echo "no connection to the database possible!\n";
exit;
}
$query = "SELECT * FROM $table WHERE sectionID='1'";
$query_result_handle = mysql_query ($query) or die("Query failed");
$num_of_rows = mysql_num_rows ($query_result_handle) or die ("The query: '$query' did not return any data");
print "The query: '$query' returned $num_of_rows rows of data.";
$row = mysql_fetch_row ($query_result_handle);
print "<b>Fetching row #$count from the query.</b>";
print "Value stored at the first index position of \$row: '$row[0]'";
$row = mysql_fetch_row ($query_result_handle);
print "<b>Fetching row #$count from the query.</b>";
print "Value stored at the first index position of \$row: '$row[0]'";
mysql_close();
?>this way i still can't say give me the stuff at row-number 3 or something (without having a lineID-column to query) but you can't have everything...
thanks for helping!