Appzmaster Posted December 23, 2008 Share Posted December 23, 2008 I have a database that has a table that stores vcard info from my messaging system. I am looking for a way to format this data on a web page I can parse the info if I paste it to a file and use a php class to parse it but i want to parse the data directly from the database possibly to a table on the web page. If anyone knows a way please let me know I have been up all night trying to get it to work. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/ Share on other sites More sharing options...
ngreenwood6 Posted December 23, 2008 Share Posted December 23, 2008 I don't know anything about vcard data but if it is the database you will need to query it to get it out like this: <?php //make the connection to the database mysql_connect("host","username","password"); //select the database you are using mysql_select_db("database") //make a query $query = "SELECT * FROM table"; //get the data $results = mysql_query($query); //display the data while($row = mysql_fetch_array($results)) { echo $row['field1']; echo "<br>"; echo $row['field2']; } Basically that will connect to you mysql server and get the data and display everything from the table from field1 and field2(you can add more or make it formatted in a table in the while loop). you will have to put your own data into the field1, field2, table, host, username, password, and database fields. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722355 Share on other sites More sharing options...
Maq Posted December 23, 2008 Share Posted December 23, 2008 I have been up all night trying to get it to work. Thanks in advance. Can we see what you've been up all night working on? It's easier for us to modify your code and give you ideas rather than creating a whole new class and script for your data. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722430 Share on other sites More sharing options...
Appzmaster Posted December 23, 2008 Author Share Posted December 23, 2008 Actually the first replay is almost exactly what I have. The issue is the data in the table looks like XML to me and I was looking for a way to parse that info and display it how it should look like Name: Foo Org: Foo .inc etc I will post the data in the table also. <?php include 'config.php'; include 'opendb.php'; //include 'vcard.php'; //include 'Contact_Vcard_Parse.php'; $profile = $_GET['lookup']; if ( $profile == "" ) { exit("<h1> This user does not exist! </h1>"); } //Query database for VCard info $result = mysql_query("SELECT * FROM ofVCard WHERE username='".$_GET['lookup']."'") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>User Name</th> <th>Profile</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $profilename = $row; // Print out the contents of each row into a table echo "<tr><td>"; echo $row['username']; echo "</td><td>"; echo $row['vcard']; echo "</td></tr>"; } if ( $profilename == "" ) { exit("<h1> This user does not have a profile yet! </h1>"); } echo "</table>"; ?> <vCard xmlns="vcard-temp"><N><FAMILY></FAMILY> <GIVEN>Gerry</GIVEN> <MIDDLE/> </N> <ORG><ORGNAME/> <ORGUNIT/> </ORG> <FN>Gerry</FN> <URL/> <TITLE/> <NICKNAME/> <PHOTO><TYPE>image/jpeg</TYPE><BINVAL>Lots of crazy text</BINVAL></PHOTO> <EMAIL><HOME/><INTERNET/><PREF/><USERID>gsvetly@</USERID> </EMAIL> <TEL><PAGER/><WORK/><NUMBER/> </TEL> <TEL><CELL/><WORK/><NUMBER/> </TEL> <TEL><VOICE/><WORK/><NUMBER/> </TEL> <TEL><FAX/><WORK/><NUMBER/> </TEL> <TEL><PAGER/><HOME/><NUMBER/> </TEL> <TEL><CELL/><HOME/><NUMBER/> </TEL> <TEL><VOICE/><HOME/><NUMBER/> </TEL> <TEL><FAX/><HOME/><NUMBER/> </TEL> <ADR><WORK/><PCODE/> <REGION/> <STREET/> <CTRY/> <LOCALITY/> </ADR> <ADR><HOME/><PCODE/> <REGION/> <STREET/> <CTRY/> <LOCALITY/> </ADR> </vCard> Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722814 Share on other sites More sharing options...
ngreenwood6 Posted December 23, 2008 Share Posted December 23, 2008 So does the data look like that in the database? Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722816 Share on other sites More sharing options...
Appzmaster Posted December 23, 2008 Author Share Posted December 23, 2008 Yes that is a copy and past from the field in the table. I am quite the noobie with php I have been playing with it a lot lately I love it so far. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722824 Share on other sites More sharing options...
ngreenwood6 Posted December 23, 2008 Share Posted December 23, 2008 I would have it parse the data when it goes into the database rather than having it parsed coming out. You don't really need to store all of that data and then parse it when it comes out. seems like a waste. I would try to parse the data before you insert it into the database. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722825 Share on other sites More sharing options...
Appzmaster Posted December 23, 2008 Author Share Posted December 23, 2008 If I had that option I would love to do that but the thing is this is sort of an addon I am working on I have no control over the values going in as it is created by another application that is all java based I suppose I could rip it apart but I have never worked much with java before. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722841 Share on other sites More sharing options...
ngreenwood6 Posted December 23, 2008 Share Posted December 23, 2008 You may want to start a new post about parsing xml data as that is what it looks like to me. i do not have any idea how to go about doing that. sorry I couldn't be more helpful. Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722842 Share on other sites More sharing options...
Appzmaster Posted December 24, 2008 Author Share Posted December 24, 2008 Ok I will try that and you were helpful don't worry =) Quote Link to comment https://forums.phpfreaks.com/topic/138179-formatting-vcard-data-from-a-mysql-table/#findComment-722861 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.