Jump to content

Recommended Posts

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.

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.

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.

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>

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.

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.

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.