Jump to content

fetch_row


hedonomania

Recommended Posts

Hi guys, I hav question concerning retriving the data from mysql.

I set the following code, but as a result i am getting a single cells in one column. Instead I would like to get the results as the whole rows with the cells i'm looking for. Any help? Thanks in advance!

 

$query_string="SELECT Type FROM $tablename WHERE name like'%$type%'";

$result_id=mysql_query($query_string,$mydb);

$column_count=mysql_num_fields($result_id);

print "<table border=1 align=center>\n";

$row=mysql_fetch_array($result_id);

 

while ($row=mysql_fetch_array($result_id)) {

print "<tr align=left valign=top>";

for ( $column_num=0;
 $column_num<$column_count;
 $column_num++)
 print "<td>$row[$column_num]</td>\n";
 
 print "</tr>\n";
 }

 print "</table>\n";

Link to comment
Share on other sites

I think I didn't put my thoughts clearly :) i am getting my single column as a row now, which is not what i wanted.

I would like to get the results from the searched field plus the associated values from other fields in the database. e.g. when i have the dabase composed of name and surname fields and i search the name field, and i get John, i want to get not only the name but also the surname so i want to see John Muller... thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.