Ok im trying to get down this whole database thing. Simple bookmark program and im trying to learn to use mysql and i just cant seem to get it. Here are my functions..
thants to grab all links and their names, now it has been in many diffrent forms as ive tried everyhtign to get it to pull both the name(in col '0') and the url(in col '1'). I really have tried everything i know so i hope someone can help me
and here is the actuall output
like isaid ive tried alot of diffrent stuff so it may be like whooaaa whats he doing.. its jsut i started trying wierd things to see if they worked.. if someone knows what im talkign about maybe a little explanation of how to do it or point to a good tutorial site for this stuff? eventually i would like to make a community site and i need to learn how to pull data out correctly and put in array and sort out and what not. Thanks!
in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
Code:
function get_user_urls2($username)
{
//extract from the database all the URLs this user has stored
if (!($conn = db_connect()))
return false;
$result = mysql_query( "select * from bookmarks where username = '$username'");
if (!$result)
return false;
//create an array of the URLs
$url_array = array();
$link_array = array();
$name_array = array();
for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
{
$name_array[$count] = mysql_result($result, $count, "name");
$link_array[$count] = addslashes($row[1]);
$url_array[$count] = $name_array[$count]."###".$link_array[$count];
}
return $url_array ;
}
thants to grab all links and their names, now it has been in many diffrent forms as ive tried everyhtign to get it to pull both the name(in col '0') and the url(in col '1'). I really have tried everything i know so i hope someone can help me
Code:
function display_user_urls2($url_array)
{
//display the table of URLs
// set global variable, so we can test later if this is on the page
global $bm_table;
$bm_table = true;
?>
<br />
<form name=bm_table action="delete_bms.php" method=post>
<table width=300 cellpadding=2 cellspacing=0>
<?php
$color = "#cccccc";
echo "<tr bgcolor=$color><td><strong>Bookmark</strong></td>";
echo "<td><strong>Delete?</strong></td></tr>";
if (is_array($url_array) && count($url_array)>0)
{
foreach ($url_array as $url)
{
if ($color == "#cccccc")
$color = "#ffffff";
else
$color = "#cccccc";
$url = explode ("###", $url);
// remember to call htmlspecialchars() when we are displaying user data
echo "<tr bgcolor=$color><td><a href='".$url[1]."' target='_new'>".htmlspecialchars($url[0])."</a></td>";
echo "<td><input type=checkbox name=\"del_me[]\"
value=\"$url\"></td>";
echo "</tr>";
}
}
else
echo "<tr><td>No bookmarks on record</td></tr>";
?>
</table>
</form>
<?php
}
like isaid ive tried alot of diffrent stuff so it may be like whooaaa whats he doing.. its jsut i started trying wierd things to see if they worked.. if someone knows what im talkign about maybe a little explanation of how to do it or point to a good tutorial site for this stuff? eventually i would like to make a community site and i need to learn how to pull data out correctly and put in array and sort out and what not. Thanks!
in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?