This is a discussion on Handling data returned by mysql_fetch_row() within the PHP General forums, part of the PHP Programming Forums category; My intentions is to have things working just like in PHPMyAdmin(in the search tab). First you retrieve the data ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
My intentions is to have things working just like in PHPMyAdmin(in the
search tab). First you retrieve the data from the database as rows (displayed in html document) and in the end of eatch row you have links to delete this row or update this row or what so ever. The problem really comes when you should affect only that row... Now here's something that i've wrote: $result = mysql_query ($sql); $row = mysql_fetch_row($result); while($row = mysql_fetch_array($result , MYSQL_NUM)) { echo " <table width=100% border=1 height=18 bgcolor=#DADADA onmouseover=this.style.backgroundColor='#ffcc99'; onmouseout=this.style.backgroundColor='#DADADA';> <tr> <td width=300> $row[0] </td> <td width=100> $row[1] </td> </tr> </table> ";} Now what whould I add here to make it work like in PHPMyAdmin? Any help appreciated! |
|
|||
|
> $result = mysql_query ($sql);
> $row = mysql_fetch_row($result); > while($row = mysql_fetch_array($result , MYSQL_NUM)) > { > echo " > <table width=100% border=1 height=18 bgcolor=#DADADA > onmouseover=this.style.backgroundColor='#ffcc99'; > onmouseout=this.style.backgroundColor='#DADADA';> > <tr> > <td width=300> $row[0] </td> > <td width=100> $row[1] </td> > </tr> > </table> > ";} > > Now what whould I add here to make it work like in PHPMyAdmin? > Any help appreciated! > You are wanting to edit/update an individual row? Well you need something to uniquely identify that row. Most commonly, an id field in your database that autoincrements. Because the ID field is unique you can use a select / update query to do something to it: ie: SELECT * FROM table WHERE id=4; BTW - to make your code easier to read, consider using mysql_fetch_assoc. Info on this at http://au3.php.net/mysql_fetch_assoc - there are also a few examples there to help you understand the function. |