Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 5th Apr 2012, 10:14 AM   #1
HyperActive Warrior
 
Join Date: 2009
Posts: 212
Thanks: 11
Thanked 5 Times in 5 Posts
Default
PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

say you have two tables one named notes and another named clients. clients has the col's ID notes has the col client_ID & mess_id

when I insert a new note it's entered tied to the client_id=id so they can be pulled according to the client

in the table for notes it's a list of all the notes the system has taking then we fetch them according to the id's that match (makes sence so far)

when I bring up index.php it shows a list of the clients name, phone,address,then a col that links to view notes <-- when this is clicked it brings up all the notes that are associated with the ID for that listing.. (again so far so good)

now here my issue index.php where the link is there for view notes I want to have it RED FONT COLOR IF there are ANY notes in notes that are assocaiated with that client... now since the list is echo'd out in a while statement that changes the ID as it pulls new records I can't figure out a way to get it to append to individual id's obviously prior to the while statement being ran...

does this make sence or more info needed?

solidsoul is offline  
Unread 5th Apr 2012, 12:05 PM   #2
Active Warrior
War Room Member
 
Join Date: 2011
Posts: 94
Thanks: 5
Thanked 26 Times in 20 Posts
Default
Re: PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

Could you post some code fragments as examples?

Viral Marketing Machine ONLY $9! How to create your own viral, monetised, niche websites that AUTO PROMOTE themselves on Youtube, Facebook, Twitter and Google. NO SITE CONTENT NEEDED![B]
s1ngular1ty is offline  
Unread 5th Apr 2012, 12:58 PM   #3
Warrior Member
 
Join Date: 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

can i see your code. I can't catch you actually, a code explains more than words.
k360 is offline  
Unread 5th Apr 2012, 01:04 PM   #4
HyperActive Warrior
War Room Member
 
Big Squid's Avatar
 
Join Date: 2009
Location: Living between LA & SD
Posts: 205
Thanks: 27
Thanked 36 Times in 33 Posts
Default
Re: PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

Couldn't you just use an IF Statement? Something like....

WHILE STATEMENT {
echo client;
echo phone;
echo address;
if(!empty(client_notes)) {
echo '<span class="make_red">';
echo notes;
echo '</span>';
}
Big Squid is offline  
Unread 5th Apr 2012, 01:51 PM   #5
HyperActive Warrior
 
Join Date: 2009
Posts: 212
Thanks: 11
Thanked 5 Times in 5 Posts
Default
Re: PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

client_notes.php
PHP Code:
<?php
include ("connect.php");
$id = $_GET['id'];

//this if statement will be used to change the messages to read
//if they are not read and are considered NEW they will be RED
//if they are marked READ they will be BLUE
if (isset($_GET['read'])); {
$read = $_GET['read'];

if (
$read=yes) {
$sql = "UPDATE `notes` SET `action`=$read, WHERE `notes`.`client_id`=0";
}
}
if (isset(
$_POST['submit'])) {
$message = $_POST['message'];
$date = date("F j, Y");
$client_id = $_GET['client_id'];
$mess_id = rand();

$insert = mysql_query("INSERT INTO `notes` VALUES ('$client_id','$mess_id','$date','$user','$message','')") or die (mysql_error());
if (
$insert) {
echo 
"<div align='center'><font color='red'>Note Added Successfully Please Close Popup Now!</font></div>";
exit();
}
}

//Client Notes - Should pull up notes related to client selected by ID
?>
<table align="center" border="1">
<tr>
<th>DATE</th>
<th>USER</th>
<th>MESSAGE</th>
<th>ACTION</th>
</tr>
<?php
$query 
= mysql_query("SELECT * FROM `notes` WHERE client_id=$id") or die("Sorry Mate Couldn't select datbase" . mysql_error());
while (
$row=mysql_fetch_array($query)) {
$num_row = mysql_num_rows($query);
if (
$num_row > 0) {
echo 
"<tr><td>" . $row['date'] . "</td><td>" . $row['user'] . "</td><td>" . $row['message'] . "</td><td><a href='client_notes.php?read=yes&mess_id=".$row['mess_id']."'><div align='center'><img border='0' src='images/checkmark.gif' width='45' height='45'></a></div></td></tr>";
}
else {
echo 
"No Messages To Produce";
}
}
echo 
"</table>";
?>
<div align="center">
<form action="client_notes.php?client_id=<?php echo $id; ?>" method="POST">
<fieldset id="Add_Notes">
<legend>ADD NOTES</legend>
<label for="message">Message:</label> 
<textarea cols="30" rows="5" name="message"> 
</textarea>
<input id="button1" type="submit" name="submit" value="ADD" /> 
</form>
</div>
index.php where the view notes link is located

PHP Code:
<?php
include("connect.php");
$username = "Desjardins";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fitzgerald Motors Client Management System</title>
<meta name="keywords" content="cms,cmr,client management system,fitzgerald motors" />
<meta name="description" content="Metal Full Site Template is provided by templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Language" content="en-us" />

<meta name="author" content="Niall Doherty" />

<script src="js/jquery-1.2.1.pack.js" type="text/javascript"></script>
<script src="js/jquery-easing.1.2.pack.js" type="text/javascript"></script>
<script src="js/jquery-easing-compatibility.1.2.pack.js" type="text/javascript"></script>
<script src="js/coda-slider.1.1.1.pack.js" type="text/javascript"></script>

<!-- 
The CSS. You can of course have this in an external .css file if you like.
Please note that not all these styles may be necessary for your use of Coda-Slider, so feel free to take out what you don't need.
-->

<!-- Initialize each slider on the page. Each slider must have a unique id -->
<script type="text/javascript">
jQuery(window).bind("load", function() {
jQuery("div#slider1").codaSlider()
// jQuery("div#slider2").codaSlider()
// etc, etc. Beware of cross-linking difficulties if using multiple sliders on one page.
});
</script>
<script type="text/javascript">
var GB_ROOT_DIR = "http://www.site.com/cms/greybox/";
</script>
<script type="text/javascript" src="greybox/AJS.js"></script>
<script type="text/javascript" src="greybox/AJS_fx.js"></script>
<script type="text/javascript" src="greybox/gb_scripts.js"></script>
<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" />

</head>
<body>
<style type="text/css">
div.scroll {
height: 270px;
width: 660px;
overflow: auto;
border: 1px solid #666;
background-color: #ccc;
padding: 8px;
}

label {font-family:Arial, Helvetica, sans-serif; display:inline-block;}
legend {font-size:16px; font-family:"Arial Black", Gadget, sans-serif; padding:2em 2em 2em 2em; }
#formwrapper {width:680px; background:#36F; margin:2em auto 0 auto; padding:2em 0 2em 0; border:solid 5px #00C; }
</style>
<div id="templatemo_site_title_bar_wrapper">
<div id="templatemo_site_title_bar">

<div id="site_title">
<h1><a href="http://www.templatemo.com" rel="nofollow" target="_parent">
<img src="images/logo.png" alt="CSS Templates" />
<span>&nbsp</span>

</a></h1>
</div>



</div> <!-- end of templatemo_site_title_bar -->
</div> <!-- end of templatemo_site_title_bar_wrapper -->

<div id="templatemo_content_wrapper">
<div id="templatemo_content">


<!-- start of slider -->


<div class="slider-wrap">
<div id="slider1" class="csw">
<div class="panelContainer">

<div class="panel" title="Home">
<div class="wrapper">

<h2>Welcome, <?php echo $username; ?></h2>
<div class="date">
<?php echo date("F j, Y"); ?>
</div>

<!--This is the home panel-->
<div class="image_wrapper fl_image">
<img src="images/CMS-image.jpg" alt="image"/>
</div>
<div>
System was created to give the financial dept of fitzgerald motors a better structure to tracking and following up on current and future leads.<br /><br />Below are key features built into CMS v1.0 and a quick tuorial on how to use.<br />
<div align="left">
<ul>
<li>Add/Remove Clients</li>
<li>Submit System Notes Per Client</li>
<li>Ping Users / Message Users</li>
<li>Set / Add / Remove Client Alerts</li>
</ul>
</div>

<br />
If you have any comments, question or concerns feel free to submit a system ticket or speak directly to the king of cars.

<div class="cleaner_h20"></div></div>


<p><a href="#2" class="cross-link" title="Go to Page 2">Next »</a></p>
</div>
</div>
<div class="panel" title="Clients">
<div class="wrapper">

<h2>Current Clients</h2>

<!--This is the Clients Panel-->
<table align="center" border="1">
<tr>
<th>NAME</th>
<th>PHONE</th>
<th>SIN</th>
<th>STOCK#</th>
<th>BANK APPROVAL</th>
<th>NOTES</th>
</tr>
<?php
$results 
= mysql_query("SELECT * FROM `clients`") or die(mysql_error());
while (
$row = mysql_fetch_array($results)) {
$num_results = mysql_num_rows($results);
if (
$num_results > 0) {

echo 
"<tr><td>" . $row['fname'] . $row['lname'] . "</td><td>" . $row['phone1'] . "</td><td>" . $row['sin'] . "</td><td>" . $row['stock_num'] . "</td><td>" . $row['bank_approval'] . "</td><td><a href='http://www.site.com/cms/client_notes.php?id=".$row['id']."'title='client_notes' rel='gb_page_center[800, 400]'>View Notes</td></tr>";

}
else {
echo 
"Nothing it must be empty mate";
}
}

echo 
"</table>";
?>

<div align="center"><A HREF="javascript:history.go(0)">Click to refresh the page</A></div>
<div class="cleaner_h20"></div>
<p><a href="#1" class="cross-link" title="Go to Page 1">« Previous</a> | <a href="#3" class="cross-link" title="Go to Page 3">Next »</a></p>
</div>
</div> 


<div class="panel" title="Add/Remove">
<div class="wrapper">

<h2>Add/Remove Clients</h2>
<!--This is the Add Remove Section-->
<?php
//first lets check to see if the user is already in the system

//check to see if the form button was pressed
//Things to add life insurance yes or no
//who do you bank with currently 
if (isset($_POST['submit'])) { 
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$sin = $_POST['sin'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$street_address = $_POST['street_address'];
$city = $_POST['city'];
$prov = $_POST['prov'];
$postal = $_POST['postal'];
$email = $_POST['email'];
$home_status = $_POST['home_status'];
$home_long = $_POST['home_long'];
$home_payment = $_POST['home_payment'];
$home_holder = $_POST['home_holder'];
$bank_mortgage = $_POST['bank_mortgage'];
$home_value = $_POST['home_value'];
$home_owe = $_POST['home_owe'];
$employer = $_POST['employer'];
$e_address = $_POST['e_address'];
$e_phone = $_POST['e_phone'];
$e_howlong = $_POST['e_howlong'];
$e_wageperhour = $_POST['e_wageperhour'];
$e_hoursperweek = $_POST['e_hoursperweek'];
$e_status = $_POST['e_status'];
$insuracne_company = $_POST['insurance_company'];
$i_phone = $_POST['i_phone'];
$i_policy = $_POST['i_policy'];
$stock_num = $_POST['stock_num'];
$bank_approval = $_POST['bank_approval'];
//29 varibles
$query = mysql_query("SELECT * FROM `clients` WHERE sin=$sin");
if (
mysql_num_rows($query) !=0 ) {
echo 
"<div align='center'><font color='red'>That User Is Already Assocaited With An Account Please Search Our Listings Idiot.</font></div>";
}
else {
$insert= mysql_query("INSERT INTO `clients` (fname,lname,sin,phone1,phone2,street_address,city,prov,postal,email,home_status,home_long,home_payment,home_holder,bank_mortgage,home_value,home_owe,employer,e_address,e_phone,e_howlong,e_wageperhour,e_hoursperweek,e_status,insurance_company,i_phone,i_policy,stock_num,bank_approval) VALUES ('$fname','$lname','$sin','$phone1','$phone2','$street_address','$city','$prov','$postal','$email','$home_status','$home_long','$home_payment','$home_holder','$bank_mortgage','$home_value','$home_owe','$employer','$e_address','$e_phone','$e_howlong','$e_wageperhour','$e_hoursperweek','$e_status','$insuracne_company','$i_phone','$i_policy','$stock_num','$bank_approval')");
}
if (
$insert) {
echo 
"<div align='center'><font color='red'>Listing added Successfully, Thanks</font></div>";
echo 
"<br />";


}
else {
echo 
"<div align='center'><font color='red'>I'm Sorry That Entry Was Not Added Correctly&nbsp;" . mysql_error() . "&nbsp;Please Try Again</font></div>";
}
}
//check to see if the submit button was pressed


if (isset($_POST['add_x'])) {
//show the conect according to this button
?>

<div id="formwrapper">
<div class="scroll">
<form id="application" action="index.php#3" method="POST">
<fieldset id="personal">
<legend>PERSONAL INFORMATION</legend>
<label for="firstname">First Name : </label> 
<input name="fname" id="fname" type="text" 
tabindex="1" />

<label for="lastname">Last Name : </label>
<input name="lname" id="lastname" type="text" 
tabindex="2" />


<label for="sin">Sin # : </label> 
<input name="sin" id="sin" type="text" tabindex="3" />

<label for="phone1">Primary Phone : </label>
<input name="phone1" id="phone1" type="text" tabindex="4" />

<label for="phone2">Cell Number : </label>
<input name="phone2" id="phone2" type="text" tabindex="5" />

<label for="address">Address : </label>
<input name="street_address" id="address" type="text" tabindex="6" />

<label for="city">City : </label>
<input name="city" id="city" type="text" tabindex="7" />

<label for="prov">Prov : </label>
<input name="prov" id="prov" type="text" tabindex="8" />

<label for="postal">Postal : </label>
<input name="postal" id="postal" type="text" tabindex="9" />

<label for="email">Email : </label>
<input name="email" id="name" type="text" tabindex="10" />

</fieldset>
<fieldset>

<legend>HOME INFORMATION</legend>
<label for="home_status">Rent Or Own : </label>
<input name="home_status" id="home_status" type="text" tabindex="11" />

<label for="home_payment">How Much Rent/Mrtg Payments : </label>
<input name="home_payment" id="home_payment" type="text" tabindex="12" />

<label for="home_holder">Bank or Landlord : </label>
<input name="home_holder" id="home_holder" type="text" tabindex="13" />

<label for="bank_holder">Who Holds Mortgage : </label>
<input name="bank_holder" id="bank_holder" type="text" tabindex="14" />

<label for="home_value">Home Value : </label>
<input name="home_value" id="home_value" type="text" tabindex="15" />

<label for="home_owe">How Much Is Owning : </label>
<input name="home_owe" id="home_owe" type="text" tabindex="16" />

</fieldset>
<fieldset>
<legend>Employment Information</legend>
<label for="employer">Employer : </label>
<input name="employer" id="employer" type="text" tabindex="17" />

<label for="e_address">Employer's Address : </label>
<input name="e_address" id="e_address" type="text" tabindex="18" />

<label for="e_phone">Employer's Phone : </label>
<input name="e_phone" id="e_phone" type="text" tabindex="19" />

<label for="e_howlong">How Long Employer : </label>
<input name="e_howlong" id="e_howlong" type="text" tabindex="20" />

<label for="e_wageperhour">How Much Per Hour : </label>
<input name="e_wageperhour" id="e_wageperhour" type="text" tabindex="21" />

<label for="e_hoursperweek">How Many Hours : </label>
<input name="e_hoursperweek" id="e_hoursperweek" type="text" tabindex="22" />

<label for="e_status">F/T or P/T : </label>
<input name="e_status" id="e_status" type="text" tabindex="23" />

</fieldset>
<fieldset>
<legend>Insurance Information</legend>
<label for="insurance_company">Insurance Company : </label>
<input name="insurance_company" id="insurance_company" type="text" tabindex="24" />

<label for="i_phone">Insurance Phone : </label>
<input name="i_phone" id="i_phone" type="text" tabindex="25" />

<label for="i_policy">Policy Number : </label>
<input name="i_policy" id="i_policy" type="text" tabindex="26" />

<label for="stock_num">Stock Number Interested : </label>
<input name="stock_num" id="stock_num" type="text" tabindex="27" />

<label for="bank_approval">Bank Approval : </label>
<input name="bank_approval" id="bank_approval" type="text" tabindex="28" />
</fieldset>

<p>
<input id="button1" type="submit" name="submit" value="Send" /> 
<input id="button2" type="reset" />
</p>
</form>
</div>
</div>
<?php


}
else if (isset(
$_POST['remove_x'])) {
//show content according to this button
echo "REMOVE BUTTON PRESSED";
}
else if (isset(
$_POST['edit_x'])) {
//show content according to this button
echo "EDIT BUTTON PRESSED";
}
else {
echo 
"Please Select An Operation&nbsp;<b>" . $username . "</b>";
echo 
"<br />";
?>
<div align="center">
<form method="POST" action="index.php#3">
<input type="image" name="add" value="add" src="images/add.png" width="75" height="72" />&nbsp;&nbsp;&nbsp;<input type="image" name="remove" src="images/remove.png" width="75" height="72" />&nbsp;&nbsp;&nbsp;<input type="image" name="edit" src="images/edit.png" width="75" height="72" />
</form>
</div>
<?php 
}
?>

<div class="cleaner_h10"></div>

<p><a href="#2" class="cross-link" title="Go to Page 2">« Previous</a> | <a href="#4" class="cross-link" title="Go to Page 4">Next »</a></p>

</div>
</div>

<div class="panel" title="Undecided">
<div class="wrapper">

<h2>UnderConstruction</h2>

<!--I'm going to keep this incase I want to add a LEft Front Image <div class="image_wrapper fl_image">
<img src="images/templatemo_image_05.jpg" alt="image"/>
</div> -->
<!-- And This in case of a Front Right Image
<div class="image_wrapper fr_image">
<img src="images/templatemo_image_06.jpg" alt="image"/>
</div> -->


<p><a href="#3" class="cross-link" title="Go to Page 3">« Previous</a> | <a href="#5" class="cross-link" title="Go to Page 5">Next »</a></p>
</div>
</div>
<div class="panel" title="Submit Ticket">
<div class="wrapper">

<h2>Submit Ticket</h2>


<div id="contact_form">

<form method="post" name="contact" action="#">
<label for="author">Name:</label> <input type="text" id="author" name="author" class="required input_field" />
<div class="cleaner_h10"></div>

<label for="email">Email:</label> <input type="text" id="email" name="email" class="validate-email required input_field" />
<div class="cleaner_h10"></div>

<label for="url">URL:</label> <input type="text" name="url" id="url" class="input_field" />
<div class="cleaner_h10"></div>

<label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea>
<div class="cleaner_h10"></div>

<input style="font-weight: bold;" type="submit" class="submit_btn" name="submitbutton" id="submitbutton" value=" Send " />
&nbsp;&nbsp;
<input type="reset" name="reset" id="reset" value=" Reset " />


</form>
</div>

<div class="address_info">
<h3>Mailing Address</h3>
111/222 Fusce quis diam sit amet tortor<br />
Vivamus vestibulum 10110, Mauris congue<br /><br />
<strong>Email:</strong> info [ at ] yourcompany [ dot ] com<br />
<strong>Website:</strong> www.templatemo.com

</div>

<div class="cleaner_h20"></div>

<p><a href="#4" class="cross-link" title="Go to Page 4">« Previous</a></p>
</div>
</div>

</div><!-- .panelContainer -->
</div><!-- #slider1 -->
</div><!-- .slider-wrap -->
<p id="cross-links" style="width:0px; height: 0px; font-size:0; overflow: hidden;">
Same-page cross-link controls:<br />
<a href="#1" class="cross-link">Page 1</a> | <a href="#2" class="cross-link">Page 2</a> | <a href="#3" class="cross-link">Page 3</a> | <a href="#4" class="cross-link">Page 4</a> | <a href="#5" class="cross-link">Page 5</a>
</p>
<!-- end of slider -->

</div> 
<!-- end of templatemo_content -->
</div> <!-- end of templatemo_content_wrapper -->
<div id="templatemo_footer_wrapper">
<div id="templatemo_footer">
Copyright © 2012 <a href="#">Your Company Name</a> | 
Designed by <a href="http://www.templatemo.com" rel="nofollow" target="_parent">Free CSS Templates</a> | 
Validate <a href="http://validator.w3.org/check?uri=referer">XHTML</a> &amp; <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>
</div> 
<div style="text-align: center; font-size: 0.75em;">Design Downloaded from <a href="http://www.template4all.com/">free CSS templates</a> | <a href="http://www.freethemes4all.com/">free website templates</a> | <a href="http://www.seodesign.us/" title="free wallpapers hd" rel="nofollow" target="_blank">Free Wallpapers HD</a>.</div>
<!-- end of templatemo_footer -->
</div> <!-- end of templatemo_footer_wrapper -->
</body>
</html>

solidsoul is offline  
Unread 5th Apr 2012, 01:53 PM   #6
HyperActive Warrior
 
Join Date: 2009
Posts: 212
Thanks: 11
Thanked 5 Times in 5 Posts
Default
Re: PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

and the reason to not use an if statement as suggested is cause then it's not checking the notes associated just the a certain ID

the while statement spits out a row per record stored based and appends the ID to view notes link - so that that when view notes is pressed _GET is used to grab the ID and show only notes associated to that ID...

issue I see is that the ID isn't present until it's passed through the while loop so a check prior to that how would I get the records PER row PER ID

hey sql go check the database and tell me if this particually ID has ANY notes assocaited with it that have an ACTION set to YES - that in lamins terms is what I want to do.. then when the while loop runs and the view notes link is there PER row right it would be RED if any notes associated to that ID are action=yes and uneffected otherwise...

solidsoul is offline  
Unread 6th Apr 2012, 02:36 AM   #7
HyperActive Warrior
War Room Member
 
Big Squid's Avatar
 
Join Date: 2009
Location: Living between LA & SD
Posts: 205
Thanks: 27
Thanked 36 Times in 33 Posts
Default
Re: PHP SOLUTION NEEDED
Share on: 
fb share twitter share gplus share more share

You could run an inner join query

SELECT clients.*, notes.*
FROM clients
INNER JOIN notes
ON (clients.ID = notes.client_id)
WHERE client_id >= 0

Then, as you're going through the WHILE, you could perform the IF statement.
Big Squid is offline  
Closed Thread


Bookmarks

Tags
needed, php, solution


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:17 PM.