need some help please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
padster83
Forum Newbie
Posts: 4
Joined: Mon Feb 28, 2011 7:19 am

need some help please

Post by padster83 »

Hi its been about a year, since I had to code simple database and php and am stuck I am sure its something small I have over looked
there is one database called lightsclients, table name clients, it shows a query with a url to take to a page that sends the ID of the record so the next page gets the ID from the address bar and is used in the query to pull that specific information out in to the new page, fields

I have attached code really appreciate another set of eyes over this.
page with list and send url

Code: Select all

	
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");


$sql = "SELECT * FROM clients WHERE type like 'Artist'  ";

				
$clientsNum = '';

$getClients = mysql_query( $sql ) or die( mysql_error() );

while($clients = mysql_fetch_object($getClients) )
{

		
echo '<p>
			  <a href="index.php?page=clients&id='.$clients->id.'">'.$clients->name.'</a><br>
			  </p>';
	                   echo "";
			$clientsNum = $clients->id;
}

{

echo mysql_num_rows($getClients) ;
echo " of clients in this section";}


page to get the id and then use in the query online two so the rest of the array pulls information based on that.


Code: Select all

$id=$_GET['id'];
$getAllClients = mysql_query('SELECT * FROM lightsclients.clients WHERE id=".$id." ') or die(mysql_error());
	while ($clients = mysql_fetch_object($getAllClients)) {
		

		if (!empty($clients->name)) {
			echo "<h5>Name:</h5><p style='color:black;font-weight:100;font-size: 12px;'>" . $clients->name . "</p>";
		}
		if (!empty($clients->location)) {
			echo "<h5>Location:</h5>" . $clients->location . "</p>";
		}
		if (!empty($clients->bookingagent)) {
			echo "<h5>Booking Agent</h5><p style='color:black;font-weight:100;font-size: 12px;'>" . $clients->bookingagent . "</p>";
		}



		if (!empty($clients->image)) {
			echo "<h5>Image</h5><p style='color:black;font-weight:100;font-size: 12px;'>" . $clients->image . "</p>";
		}
		if (!empty($clients->bio)) {
			echo "<h5>Bio:</h5><p style='color:black;font-weight:100;font-size: 12px;'>" . $clients->bio . "</p>";
		}
		
                if (!empty($clients->website)) {
			  echo "<h5> Visit there personal web page</h5><p style='color:black;font-weight:100;font-size: 12px;'>";		
echo '<a href="http://'.$clients->website.'">'."click here".'</a></P>';
		}

                  
                }


padster83
Forum Newbie
Posts: 4
Joined: Mon Feb 28, 2011 7:19 am

Re: need some help please

Post by padster83 »

would really help some help on this please
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: need some help please

Post by social_experiment »

Patience is a virtue, learn it :)

You don't say what the problem is so im guessing you're record isn't displaying when you go to the page.

Code: Select all

$getAllClients = mysql_query('SELECT * FROM lightsclients.clients WHERE id=".$id." ') or die(mysql_error());
// try this
$getAllClients = mysql_query("SELECT * FROM clients WHERE id = '" . mysql_real_escape_string($id) . "' ") 
or die(mysql_error());
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: need some help please

Post by John Cartwright »

Please wait 24 hours before bumping your thread again -> see Forum Rules in my signature.
padster83
Forum Newbie
Posts: 4
Joined: Mon Feb 28, 2011 7:19 am

Re: need some help please

Post by padster83 »

social_experiment wrote:Patience is a virtue, learn it :)

You don't say what the problem is so im guessing you're record isn't displaying when you go to the page.

Code: Select all

$getAllClients = mysql_query('SELECT * FROM lightsclients.clients WHERE id=".$id." ') or die(mysql_error());
// try this
$getAllClients = mysql_query("SELECT * FROM clients WHERE id = '" . mysql_real_escape_string($id) . "' ") 
or die(mysql_error());
yea sorry, spent 3 hrs re writting it over and over again tryign to get it to render something out but i get nothing no error message no code nothing, i am at my wits end, they want this bit live tommrow noon! GMT why i am bit impatrient.
padster83
Forum Newbie
Posts: 4
Joined: Mon Feb 28, 2011 7:19 am

Re: need some help please

Post by padster83 »

Nah it didn't work if i replace the id for name i can make it echo the name
otherwise it renders nothing on the page

page can be seen here
http://lightsontalent.co.uk/index.php?page=actors
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: need some help please

Post by social_experiment »

Code: Select all

<a href="index.php?page=clients&id='.$clients->id.'">'.$clients->name.'</a>
Can you paste the result that you get from the first segment of code you pasted? (Specifically this hyperlink created by this code).
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply