enoxh
05-16-2012, 05:10 AM
Sorry I just realized this should have been in server side...
I'm trying to create a list of twitter users with a follow button next to each user. The user names are being pulled from a mysql database.
Here's the code I have so far. I can get a list of user names from my database, put it into an array and I can replace the user name in the first follow button. I need to sequentially replace the $row variable in the script at the bottom so the follow button points to the users account each time it iterates through the array?
I'm stuck on how to iterate this so that I get a list of all the users in the array with a follow button next to each user name.
Any help or ideas would be greatly appreciated!
I'm stuck and on a deadline.
<?php
// Connect to database server
mysql_connect("localhost", "root", "") or die (mysql_error ());
// Select database
mysql_select_db("tewxadb") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM users";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// Write the value of the column username (which is now in the array $row)
echo $row['username'] . "<br />";
}
// Close the database connection
mysql_close();
?>
<a href="https://twitter.com/" +$row(text) class="twitter-follow-button" data-show-count="true" data-lang="en">Follow </a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
I'm trying to create a list of twitter users with a follow button next to each user. The user names are being pulled from a mysql database.
Here's the code I have so far. I can get a list of user names from my database, put it into an array and I can replace the user name in the first follow button. I need to sequentially replace the $row variable in the script at the bottom so the follow button points to the users account each time it iterates through the array?
I'm stuck on how to iterate this so that I get a list of all the users in the array with a follow button next to each user name.
Any help or ideas would be greatly appreciated!
I'm stuck and on a deadline.
<?php
// Connect to database server
mysql_connect("localhost", "root", "") or die (mysql_error ());
// Select database
mysql_select_db("tewxadb") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM users";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// Write the value of the column username (which is now in the array $row)
echo $row['username'] . "<br />";
}
// Close the database connection
mysql_close();
?>
<a href="https://twitter.com/" +$row(text) class="twitter-follow-button" data-show-count="true" data-lang="en">Follow </a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>