thehigherentity Posted June 12, 2006 Share Posted June 12, 2006 basicaly I have only just got my head round making and removing tables in mysql I have been using the following code to see if the tables were there or not, now im onto writing information into the table i dont seem to have any way of checking the info is actualy there.So my question is, can this code be changed to read the information within the tables too ?if so can somone point me in the right direction of how to go about thiswhat i could realy do with is it showing the rows and the values or information within them so i can actualy tell i am doing things rightthis would be a great help to me if somone could help with this[code]$link = mysql_connect($host, $user, $pass);$result = mysql_list_dbs($link);$row_numb = mysql_num_rows($result);while ($db_data = mysql_fetch_row($result )){ echo $db_data[0]."<br>"; $result2 = mysql_list_tables($db_data[0]); $num_rows2 = mysql_num_rows($result2); while($table_data = mysql_fetch_row($result2)) { echo "--".$table_data[0]."<br>"; } echo "==> $num_rows2 table(s) in ".$db_data[0]."<p>";}mysql_close($link);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11821-just-need-a-little-help-finding-whats-inside-mysql/ Share on other sites More sharing options...
poirot Posted June 13, 2006 Share Posted June 13, 2006 Maybe I am misunderstanding you, but you are looking for MySQL data retrieval, right?[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95441\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95441[/a][a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95443\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=95443[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11821-just-need-a-little-help-finding-whats-inside-mysql/#findComment-44806 Share on other sites More sharing options...
thehigherentity Posted June 13, 2006 Author Share Posted June 13, 2006 I can view the data in a table if i know what the rows are called, eg im using this at the moment[code]$link = mysql_connect($host, $user, $pass); // conect to the mysql databasesif (!mysql_select_db ($dbname)) die ("WE have a big problem, <br>I cant connect to the database $dbname"); // select the database to work with$query = "SELECT * from $tablename";$result = mysql_db_query($dbname, $query, $link);// create a tableprint ("<TABLE BORDER=1 WIDTH=\"75%\" CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>\n");print ("<TR ALIGN=CENTER VALIGN=TOP>\n");print ("<TD ALIGN=CENTER VALIGN=TOP>I.D</TD>\n");print ("<TD ALIGN=CENTER VALIGN=TOP>Username</TD>\n");print ("<TD ALIGN=CENTER VALIGN=TOP>Comments</TD>\n");print ("<TR>\n");while($row = mysql_fetch_array($result)){ print("<TR ALIGN=CENTER VALIGN=TOP>\n"); print("<TD ALIGN=CENTER VALIGN=TOP>$row[id]</TD>\n"); print("<TD ALIGN=CENTER VALIGN=TOP>$row[user_name]</TD>\n"); print("<TD ALIGN=CENTER VALIGN=TOP>$row[information]</TD>\n"); print("</TR>");}mysql_close($link);[/code]however, lets say i dont know the names of the rows "$row[user_name]" how can i find that out?and how can i find out how many of them there are?my problem is i like flat files becouse i can look inside and see for myself, but im working on somthingthats far too big for flat files so i realy need to learn mysql now, i have worked out its a lot easyer to work with then i thought but its just knowing how to do it in the first placethanks for any help you can give and i hope thats explained things a little better Quote Link to comment https://forums.phpfreaks.com/topic/11821-just-need-a-little-help-finding-whats-inside-mysql/#findComment-44818 Share on other sites More sharing options...
AndyB Posted June 13, 2006 Share Posted June 13, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]however, lets say i dont know the names of the rows "$row[user_name]"how can i find that out?and how can i find out how many of them there are?[/quote]I don't really understand your problem. How did you create the table in the first place. How did you create and define the fields that make up each row? How could you not actually know the structure of a database you created?Doing a little reading will help you learn faster than just asking questions. At worst, you'll get the terminology right :)[a href=\"http://www.htmlite.com/MYSQLintro.php\" target=\"_blank\"]http://www.htmlite.com/MYSQLintro.php[/a][a href=\"http://aspn.activestate.com/ASPN/docs/PHP/function.mysql-list-fields.html\" target=\"_blank\"]http://aspn.activestate.com/ASPN/docs/PHP/...ist-fields.html[/a] - but it won't tell you the definitions of each field! Quote Link to comment https://forums.phpfreaks.com/topic/11821-just-need-a-little-help-finding-whats-inside-mysql/#findComment-44822 Share on other sites More sharing options...
thehigherentity Posted June 13, 2006 Author Share Posted June 13, 2006 [!--quoteo(post=383064:date=Jun 12 2006, 08:47 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 12 2006, 08:47 PM) [snapback]383064[/snapback][/div][div class=\'quotemain\'][!--quotec--]I don't really understand your problem. How did you create the table in the first place. How did you create and define the fields that make up each row? How could you not actually know the structure of a database you created?Doing a little reading will help you learn faster than just asking questions. At worst, you'll get the terminology right :)[/quote]the database I have created isnt a problem right now, even though... I will come back to them in a few month and wont have a clue what i called the fields with the tables.I have created a small database with only 3 fields at the moment and there id, user and comment all i am doing in playing arround with these making sure i know how to delete move and change the information befor i even attempt to make anything with the connection.I have a guest book installed on my server and i have been trying to access the information within there too and this is were i have had some problems, I know how to find the table names but im lost on how to find the field names and I have read a number of sites and looked through my referance books but non of these seem to consider the fact that you could be working on somthing that somone else has created.I would of thought there would be a simple command to do this, it seems very logical to me?anyway thanks for the links, I will go check them out now see if i can find anything thereJust so you know i found what i wanted thanks for the help :)[code]mysql_field_name() [/code] Quote Link to comment https://forums.phpfreaks.com/topic/11821-just-need-a-little-help-finding-whats-inside-mysql/#findComment-44829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.