Jump to content

n00b needing some help with MySQL and PHP page creation


Hidoshi

Recommended Posts

I'm currently trying to wrap my head around PHP and MySQL, and while the process hasn't been entirely unsuccessful, I'm hitting a pretty big wall.

 

I have a list of members and their info in a MySQL database. I then have a PHP page which retrieves said info correctly and prints off the first name, last name, their region, etc, ordered by last name. That's all fine and dandy. However, I want to be able to generate a dynamic page from their first and last name which will then include an "about" section. I know it can be done, I'm just lacking in how to get there.

 

For instance, I've seen where search terms can be parsed as hxxp://www.yoursite.com/members.php?First+Last and it outputs info that way. That's great, exactly what I'm looking for. I don't want to have permanent member pages, just retrieval of info and such.

 

Does anyone know any tutorials I could use? Or just basic tips for coding and such? Thanks very much for your consideration.

Link to comment
Share on other sites

this is what i use , this should help you

<?php
}
	if (mysql_num_rows($result) < 1) {
		 echo 'This ID does not exist in the database<br>';
		 echo "<a href=\"index.php\">Return to Image Page</a>";
		 exit();
	}
exit();
}
	else {
	 echo "Unknown Image ID! <br />";
	 echo "<a href=\"index.php\">Return to Image Page</a>";
	 exit();
	}
}
//No ID passed to page, display user list:
$query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`";
$result = mysql_query($query) or die("Error:" . mysql_error());

if (mysql_num_rows($result) > 0) {
?>
<table class="welcome_port"><tr><td>Welcome this is my portfolio.</td></tr></table>
<table id="portfolio">
<?php
               $loop = 3;
		   $loop1 = 3;
	while($row=mysql_fetch_array($result)){ // Start looping table row

	if ($loop == 3) {
                        echo "<tr>";
                }
	$toecho1 .= '<td><a href="?image_id='.$row['image_id'].'">Details</a></td><td>    </td>';
	$toecho .= '<td><a href="'.$row['image_link'].'" rel="lightbox [main]" title="'.$row['image_caption']. '" ><img src="'.$row['image_link'].'"width="150px" /></a></td><td>    </td>';

                
                if ($loop == 3) 
			{
                        echo "</tr>";
                        $loop=0;
                }   


	}
               if (substr($toecho, -5) != "</tr>") {
                  $toecho .= "</tr>";
               }
               echo $toecho;
               echo $toecho1;
}

?>		
</table>
<?php
		if (mysql_num_rows($result) < 1) {
		echo "No Images To Display";
		}

mysql_close();
?>

Link to comment
Share on other sites

sorry, the script i posted is missing stuff and to complex

try this one

 

if ($_SESSION['logged_in'] == true)
{
if (isset($_GET['edit'])) {
if ((int) $_GET['edit'] > 0) {

$userid = $_GET['edit'];
$sql = "SELECT * FROM hayleyedit WHERE `page_name`='{$page_id}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$welcome = $row['content'];
?>
<p>Editing <?php echo "$page_id"; ?></p>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><textarea name="content" cols="60" rows="20" title="Edit Site Content"><?php echo "$welcome"; ?></textarea><br /><input type="submit"  value="Change" title="Save Changes"/></form>
<?php

if (mysql_num_rows($result) < 1) {
     echo 'This ID does not exist in the database<br>';
 echo "<a href=\"live_edit.php\">Return to Members Page</a>";
 exit();
}
exit();
}
else {
echo "Unknown User ID! <br />";
echo "<a href=\"live_edit.php\">Return to Members Page</a>";
exit();
}
}
//No ID passed to page, display user list:
$query = "SELECT page_name, content FROM hayleyedit";
$result = mysql_query($query) or die("Error:" . mysql_error());

if (mysql_num_rows($result) > 0) {
echo "User List:<br />";
while ($row = mysql_fetch_assoc($result)) {
  echo '<table border="1"><tr><td><a href="?id=' . $row['page_name'] . '">' . $row['content'] . '</a></td></tr></table>';
}
}
}
else
{
header("Location:http://".$_SERVER[HTTP_HOST]);
}

Link to comment
Share on other sites

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.