Page 1 of 1

need some help please

Posted: Mon Feb 28, 2011 7:26 am
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>';
		}

                  
                }



Re: need some help please

Posted: Mon Feb 28, 2011 10:08 am
by padster83
would really help some help on this please

Re: need some help please

Posted: Mon Feb 28, 2011 10:19 am
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());

Re: need some help please

Posted: Mon Feb 28, 2011 10:41 am
by John Cartwright
Please wait 24 hours before bumping your thread again -> see Forum Rules in my signature.

Re: need some help please

Posted: Mon Feb 28, 2011 5:42 pm
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.

Re: need some help please

Posted: Mon Feb 28, 2011 7:02 pm
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

Re: need some help please

Posted: Tue Mar 01, 2011 10:40 am
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).