Jump to content

promotec

Members
  • Posts

    8
  • Joined

  • Last visited

promotec's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Gristoi thankyou for your input I think you are correct however, I think the way I was going about things was wrong, I think I just need to add the COUNT (email) needs adding to the top query on my script then have that echo the result in my table below that. Im just not sure of the correct syntax to do so I played around for a day or two and didn't succeed :-(
  2. Hi Guys I have been working on a script for my website, the script itself works fine and does what it is meant to I have a free tarot reading request page, the visitor enters name-email-gender- and a question into the form and submits it, this data is written to MySQL. When I call the script below, it reads from MySQL creates a array of any free reading requests and displays them in a table. I then click on delete or answer and access those functions in other scripts, this all works great. heres a screen capture of the output. I have created another column called readings Im trying to inset a routine that queries MySQL and counts how many readings that visitor has had including the current reading request. based on how many records have the visitors email address, heres the code Im trying to insert into the script. <!-- Start of revisit count code--> <?php $times = "$row['name']"; { $query = "SELECT email, COUNT(email) FROM contacts WHERE Name='$times'"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "". $row['COUNT(email)'] .""; }} ?> <!-- End of revisit count code --> The code as a standalone script works, but when entered into my script it stops the array output after the first row/record, I have tried including it as a iframe, clalling the file with a query string to pass the email variable to that script, struck problems , I have tried as an include but it wouldn't work calling the file name with a query string in the include statement. Here is my script <?php require_once('cfg.php'); $sql = "SELECT * FROM contacts WHERE answer IS NULL ORDER BY id ASC"; $result = mysql_query($sql) or die(mysql_error()); ?> <html> <head> <title>Free Reading Requests</title> </head> <body> <h3><p align="center">Free Reading Admin.</p></h2> <p></p> <div align="center"><form action="list.php" method="post"> <input type="submit" value="View Answered Questions." /> </form></div> <p></p> <?php while($row = mysql_fetch_array($result)): ?> <table align="center" cellspacing="2" cellpadding="2" border="1"> <tr> <td> <table border=0 width=1450 style='table-layout:fixed' > <col width=50> <col width=200> <col width=225> <col width=75> <col width=500> <col width=100> <col width=150> <col width=100> <col width=100> <tr bgcolor="#C4F868"> <td>ID</td> <td>Name</td> <td>Email</td> <td>Gender</td> <td align="center">Question</td> <td align="center">Readings</td> <td>Date/Time</td> <td align="center">Delete</td> <td align="center">Answer</td> </tr> <tr bgcolor="#F3F4A4"> <td valign="top"><?php echo $row['id']; ?></td> <td valign="top"><?php echo $row['name']; ?></td> <td valign="top"><?php echo $row['email']; ?></td> <td valign="top"><?php echo $row['gender']; ?></td> <td valign="top"><?php echo $row['question']; ?></td> <td valign="top"> <!-- Start of revisit count code--> <?php $times = "$row['name']"; { $query = "SELECT email, COUNT(email) FROM contacts WHERE Name='$times'"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "". $row['COUNT(email)'] .""; }} ?> <!-- End of revisit count code --> </td> <td valign="top"><?php echo $row['date']; ?></td> <td align="center" valign="top"> <form action="delete.php" method="post"> <input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>" /> <input type="submit" value="Delete" /> </form> </td> <td align="center" valign="top"> <form action="answer.php?id=<?php echo $row['id']; ?>" method="post"> <input type="submit" value="Answer" /> </form> </td> </tr> <tr> <td align="center" colspan="7"></td> </tr> </table> </tr> </table> </p> <?php endwhile; ?> </body> </html> Inserting a routine in the middle of the array output appears problematic is there any way around this problem, I tried inserting the code further up the script and just using a variable in the TD but that didn't work. as I think the main routine has to be below the array routine... My head hurts :-) Heres some feedback off another forum, a guy did answer then wouldn't elaborate any further this stops your code dead $times = "$row['name']"; You don't need it nor do you need to get a second query. Add the SELECT email, COUNT(email)..... to the original query, at the top of the page, and print this column as you do all others. Use COUNT(email) AS number_email or something like that. So my question is this how do I include SELECT email, COUNT(email) as part of this query <?php require_once('cfg.php'); $sql = "SELECT * FROM contacts WHERE answer IS NULL ORDER BY id ASC"; $result = mysql_query($sql) or die(mysql_error()); ?> so that the count email function becomes part of the array then prints for each record in the table. and also is this the correct way to echo the email count for each record in the table. <td valign="top"><?php echo $row['number_email']; ?></td> Sorry for being so long winded guys, but any assistance would be greatly appreciated, it got me stumped, and while a simple addition to the original script, its worthwhile for me to accomplish. Kind regards Chris
  3. Ok I have solved it, I didn't need to use an a href, just the url itself then it comes up hyperlinked, thankyou for your assistance anyway guys much appreciated.
  4. No this isn't working it is what the headers where to start with which surprised me when the ahref just showed as code, this is what has me baffled.
  5. Hi guys a simple php mail question, I am using the following mail routine to send a email from a script, its all working just fine except the <a href="">Click Here to View</a> is showing the code on the resulting email not just the hyperlinked Click Here to View. heres my code below I tried swapping content type header from text/html to multipart/alternative that didn't make any difference, any suggestion would be very helpful. $to = "$email"; $subject = "$name Your Free Reading From ClairVision Network"; //headers and subject $headers = "MIME-Version: 1.0\r\n"; $headers = "Content-type: multipart/alternative charset=iso-8859-1\r\n"; $headers = "From: \"ClairVision Network\" <\"admin@clairvision.net\">\r\n"; $body = "ClairVision Free Reading Request\n\n"; $body .= "Hello ".$name." Thankyou for requesting a free reading from ClairVision Network.\n\n"; $body .= "Your free reading has been done by ".$reader." who is one of our resident clairvoyants.\n\n"; $body .= "View ".$reader."'s public profile page:\n\n <a href=http://clairvision.net/index.php?page=user&action=pub_profile&id=$readerid>Click Here to View</a> \n\n"; $body .= "Here is the question you have asked:\n \n".$question."\n\n"; $body .= "Here is the answer to your question:\n \n".$answer."\n\n"; $body .= "Thankyou for visiting ClairVision Network\n\n"; $body .= "Kind regards ".$reader."\n\n"; mail($to, $subject, $body, $headers); Kind regards Chris
  6. Thankyou Barand you are a champion, that was the info I needed that has solved my main problem and Muddy_Funster thankyou as well for the time you took to assist me much appreciated and you imput will also be utilized. The second issue was redirecting the script back to the form when execution has completed using the header method runs into probs as this script will be included in another script with the include statement. Can the form be in the same script, Im not exactly sure without researching it heres my theory firstly ill try to explain in words the script gets called online.php?online=1 (output from the form) the script checks whether there are any variables IF it finds the query string with the ?online=1 it completes the processing routine and writes the given value to MySQL then continues to the next routine which echo's the form, If the script doesn't find any query string/variables it bypasses the processing routine and goes straight to the echo the form, ill include an example the syntax wont be correct but just as an example <?php $dbhost = 'localhost:3036'; $dbuser = 'promotec_admin'; $dbpass = 'moldflow888'; $conn = mysql_connect($dbhost, $dbuser, $dbpass if(!isset($_POST['online'])){ $online = $_POST["online"]; if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = "UPDATE oc_t_user SET online_status='$online' WHERE s_username='Promotec'"; mysql_select_db('promotec_osclass'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not update data: ' . mysql_error()); } mysql_close($conn); } else{ echo "<form method='post' action='online2.php'><input type='hidden' name='online' value='1'> <input type='submit' value='Online'></form> "; } exit(); ?> Any assistance with the correct syntax for the above would be greatly appreciated, I was a webdeveloper for many years but 95% of the programming was out sourced now after a break of 5 years, saying im rusty is an understatement to say the least *grin* Kind regards Chris
  7. Hi guys the outcome Im trying to achieve is adding an offline button and online button to a membership area im using and offline form button and a online form button to send either a 1 value or a 0 value to the php script to update the MySQL field online_status this is the form buttons (page online ,php) <form method='post' action='online2.php'> <input type="hidden" name="online" value="1"> <input type="submit" value="Online"> </form> <form method='post' action='online2.php'> <input type="hidden" name="online" value="0"> <input type="submit" value="Offline"> </form> This is the script to collect the form output (page online2 ,php) <?php $dbhost = 'localhost:3036'; $dbuser = 'promotec_admin'; $dbpass = 'moldflow888'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); $online = $_POST["online"]; if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'UPDATE oc_t_user SET online_status="$online" WHERE s_username="Promotec"'; mysql_select_db('promotec_osclass'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not update data: ' . mysql_error()); } mysql_close($conn); ?> I cant get it to work using the $online variable as the SET value if I replace the $online variable with a 1 or a 0 it works fine and updates the database field fine but using the variable as the SET value it doesn't update the database field.... it doesn't show an error but doesn't update the online_status field also is there a way of making the script redirect back to the page (online.php) with the form buttons once the script has executed I tried via form hidden redirect but that didn't work Ive spent hours playing with it to no avail, any advice would be much appreciated Kind regards Chris
×
×
  • 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.