Handling data returned by mysql_fetch_row()

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-01-2005
nizar.jouini@webinfo.fi
 
Posts: n/a
Default Handling data returned by mysql_fetch_row()

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!

Reply With Quote
  #2 (permalink)  
Old 08-04-2005
Michael Phipps
 
Posts: n/a
Default Re: Handling data returned by mysql_fetch_row()

> $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.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0