Jump to content

imdead

Members
  • Posts

    116
  • Joined

  • Last visited

Everything posted by imdead

  1. @ginerjm Thankyou, I understand that it's horribley messy and ugly. I've implemented some of your suggestions so far, although i'm still getting stuck on the SQL errors if i add any apostrophes to the statement <?php include"header.php"; error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); $success=""; ?> <div id="info"> <?php if (isset($_SESSION['username'])) { $action = $_GET["action"]; ////DELETE A JOB //// if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } ////EDITING A JOB///// if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); if ($_POST) { $editid = $_GET['editid']; $job_title = htmlspecialchars($_POST["job_title"]); $job_description = htmlspecialchars($_POST["job_description"]); $job_type = $_POST["job_type"]; $job_area = $_POST["job_area"]; $hot_job = $_POST["hot_job"]; $nurse_vet = $_POST["nurse_vet"]; $query2 = "UPDATE jobs SET job_title='$job_title', job_description='$job_description', job_type='$job_type', job_area='$job_area', hot_job='$hot_job', nurse_vet='$nurse_vet' WHERE id='$editid' LIMIT 1"; $sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $query2"); }else { $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query($s) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row["job_title"]); $job_description = htmlspecialchars($row['job_description']); $job_type = $row['job_type']; $job_area = $row['job_area']; $hot_job = $row['hot_job']; $nurse_vet = $row['nurse_vet']; echo("<form name='add' method='post' action='?action=edit&editid=$id'>"); echo("<input type='hidden' name='editid' value='$editid'>"); } } } ////ADDING A JOB//// if ($action == "add"){ $add = $_POST["add"]; $job_title = htmlspecialchars($_POST["job_title"]); $job_description = htmlspecialchars($_POST["job_description"]); $job_type = $_POST["job_type"]; $job_area = $_POST["job_area"]; $hot_job = $_POST["hot_job"]; $nurse_vet = $_POST["nurse_vet"]; $query = "INSERT INTO jobs (job_title, job_description, job_type, job_area, hot_job, nurse_vet) VALUES ('$job_title', '$job_description', '$job_type', '$job_area', '$hot_job', '$nurse_vet')"; $sql = mysql_query($query) or die (mysql_error()); } ///EMPTY //// if ($action == ""){ $job_title=""; $job_description=""; $job_type=""; $hot_job=""; $nurse_vet=""; $job_area=""; } ?> <form name='add' method='post' action='?action=add'> Job Title:<br /><input type='text' size='50' name='job_title' value="<?php echo htmlspecialchars($job_title); ?>"><br /> Job Description: <br /><textarea rows='10' cols='50' name='job_description'><?php echo htmlspecialchars($job_description); ?></textarea><br /> Job Type: <br /><select name='job_type'><option <?php if($job_type=="Permanent") echo 'selected="selected"'; ?>>Permanent</option><option <?php if($job_type=="Locum or Contract") echo 'selected="selected"'; ?>>Locum or Contract</option></SELECT><br /> Hot Job?<br /> Yes <input type='radio' name='hot_job' value='Yes' <?php if($hot_job=="YES") echo 'checked'; ?>> No <input type='radio' name='hot_job' value='no' <?php if($hot_job=="NO") echo 'checked'; ?>><br /> Nurse or Vet job?<br />Vet <input type='radio' name='nurse_vet' value='Vet' <?php if($nurse_vet=="Vet") echo 'checked'; ?>> Nurse <input type='radio' name='nurse_vet' value='Nurse' <?php if($nurse_vet=="Nurse") echo 'checked'; ?>><br /> Job Area:<br /><select name='job_area'><option <?php if($job_area=="East Anglia") echo 'selected="selected"'; ?>>East Anglia</option><option <?php if($job_area=="All UK") echo 'selected="selected"'; ?>>All UK</option><option <?php if($job_area=="London / South East") echo 'selected="selected"'; ?>>London / South East</option><option <?php if($job_area=="Midlands") echo 'selected="selected"'; ?>>Midlands</option><option <?php if($job_area=="North West") echo 'selected="selected"'; ?>>North West</option><option <?php if($job_area=="Northern Ireland") echo 'selected="selected"'; ?>>Northern Ireland</option><option <?php if($job_area=="Scotland") echo 'selected="selected"'; ?>>Scotland</option><option <?php if($job_area=="South") echo 'selected="selected"'; ?>>South</option><option <?php if($job_area=="South West") echo 'selected="selected"'; ?>>South West</option><option <?php if($job_area=="Southern Ireland") echo 'selected="selected"'; ?>>Southern Ireland</option><option <?php if($job_area=="Wales") echo 'selected="selected"'; ?>>Wales</option><option <?php if($job_area=="Yorkshire / North East") echo 'selected="selected"'; ?>>Yorkshire / North East</option></SELECT><br /> <input type='Submit' value='Submit'></div> <?php if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table cellspacing=20 cellpadding=20>"); if(isset($_GET["desc"])){ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID DESC"; }else{ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID ASC"; } echo("<td><a href=add_jobs.php?desc>Ref#:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet:</td><td>Edit:</td><td>Delete:</td><td>Hot:</td>"); ?> <form name='hotbox' action='hot_update.php' method='POST'> <?php $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row['job_title']); $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $nurse_vet = $row['nurse_vet']; $hotbox = $row['hot_job']; $position=18; $job_description2 = substr($job_description, 0, $position); ECHO "<tr><td><strong>$id</strong></td>"; ECHO "<td><strong>$job_title</strong></td>"; ECHO "<td><strong>$job_description2 ...</strong></td>"; ECHO "<td><strong>$job_type</strong></td>"; ECHO "<td><strong>$job_area</strong></td>"; ECHO "<td><strong>$nurse_vet</strong></td>"; ECHO "<td><a href='add_jobs.php?action=edit&editid=$id'>Edit</a></td>"; ECHO "<td><a href='add_jobs.php?action=delete&delid=$id'>Delete</a></td>"; ?> <td><input name="ONOFF[]" type="checkbox" value="<?php echo $row['id']; ?>" <?php if($row['hot_job'] == 'YES') { echo "checked='checked' "; } ?>/></td></tr> <?php } ?></p><input type='Submit' value='Update'></form></table> </div> <?php }else{echo'Stop hacking';} include"footer.php"; ?>
  2. Thanks very much, that worked for displaying the title, although when editing I still get this error if there is an apostrophe Editing a Job:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'r', job_description='tyrtyff', job_type='Permanent', job_area='East Anglia', hot' at line 1 IN UPDATE jobs SET job_title='twetwe ' r', job_description='tyrtyff', job_type='Permanent', job_area='East Anglia', hot_job='no', nurse_vet='Nurse' WHERE id='473' LIMIT 1
  3. Hello everyone, Please bear with me, this is really messy I have a few questions, i've tried to render 3 different pages, Default, Edit and Delete, however the edit and default page, keep messing with each other and screwing the forms. <?php if (isset($_SESSION['username'])) { if ($_SESSION['userlevel'] = '3'){ $action = $_GET["action"]; ////DELETE A JOB //// if ($action == "delete"){ $delid = $_GET['delid']; $query = "DELETE FROM jobs WHERE id=".$delid." LIMIT 1"; $sql = mysql_query($query); echo("Job succesfully deleted! [ <a href='add_jobs.php'>Back</a> ]"); } ////EDITING A JOB///// if ($action == "edit"){ print("<strong>Editing a Job:</strong>"); if ($_POST) { $editid = $_GET['editid']; $job_title = htmlspecialchars($_POST['job_title']); $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $query2 = "UPDATE jobs SET job_title='$job_title', job_description='$job_description', job_type='$job_type', job_area='$job_area', hot_job='$hot', nurse_vet='$nurse_vet' WHERE id='$editid' LIMIT 1"; $sql = mysql_query($query2) or die ('Error: '.mysql_error () . " IN $query2"); }else { $editid = $_GET['editid']; $s = "SELECT * FROM jobs WHERE id=".$editid." LIMIT 1"; $sql = mysql_query(htmlspecialchars($s)) or die ('Error: '.mysql_error () . " IN $s"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row["job_title"]); $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $hot = $row['hot']; $nurse_vet = $row['nurse_vet']; echo("<form name='add' method='post' action='?action=edit&editid=$id'>"); echo("<input type='hidden' name='editid' value='$editid'>"); } } } ////ADDING A JOB//// if ($action == "add"){ $add = $_POST['add']; $job_title = $_POST['job_title']; $job_description = $_POST['job_description']; $job_type = $_POST['job_type']; $job_area = $_POST['job_area']; $hot = $_POST['hot']; $nurse_vet = $_POST['nurse_vet']; $id = mysql_insert_id(); $query = "INSERT INTO jobs (id, job_title, job_description, job_type, job_area, hot_job, nurse_vet) VALUES ('$id', '$job_title', '$job_description', '$job_type', '$job_area', '$hot', '$nurse_vet')"; $sql = htmlspecialchars(mysql_query($query)) or die (mysql_error()); } ///EMPTY //// if ($action == ""){ $job_title=""; $job_description=""; } ?> <strong>Add A New Job!</strong> <br /> <br /> <form name='add' method='post' action='?action=add'> <input type='hidden' name='?action=add'> Job Title:<br /><input type='text' size='50' name='job_title' value='<?php echo htmlspecialchars($job_title); ?>'><br /> Job Description: <br /><textarea rows='10' cols='50' name='job_description'><?php echo $job_description; ?></textarea><br /> Job Type: <br /><select name='job_type'><option>Permanent</option><option>Locum or Contract</option></SELECT><br /> Hot Job?<br /> Yes <input type='radio' name='hot' value='Yes'> No <input type='radio' name='hot' value='no' checked><br /> Nurse or Vet job?<br />Vet <input type='radio' name='nurse_vet' value='Vet'> Nurse <input type='radio' name='nurse_vet' value='Nurse' checked><br /> Job Area:<br /><select name='job_area'><option>East Anglia</option><option>All UK</option><option>London / South East</option><option>Midlands</option><option>North West</option><option>Northern Ireland</option><option>Scotland</option><option>South</option><option>South West</option><option>Southern Ireland</option><option>Wales</option><option>Yorkshire / North East</option></SELECT><br /> <input type='Submit'></div> <?php if($success == TRUE) { print("<strong>Success!</strong>"); } echo("<br>"); echo("</form>"); print("<strong>Existing Jobs:</strong>"); print("<br />"); print("<br />"); echo("<table class=main cellspacing=20 cellpadding=20>"); if(isset($_GET["desc"])){ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID DESC"; echo("<td><a href=add_jobs.php>Ref#:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet:</td><td>Edit:</td><td>Delete:</td><td>Hot:</td>"); }else{ $query = "SELECT * FROM jobs WHERE 1=1 ORDER by ID ASC"; echo("<td><a href=add_jobs.php?desc>Ref#:</td><td>Title:</td><td>Description:</td><td>Type:</td><td>Area:</td><td>Nurse/Vet:</td><td>Edit:</td><td>Delete:</td><td>Hot:</td>"); } ?> <form name='hotbox' action='hot_update.php' method='POST'> <?php $sql = mysql_query($query); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job_title = htmlspecialchars($row['job_title']); $job_description = $row['job_description']; $job_type = $row['job_type']; $job_area = $row['job_area']; $nurse_vet = $row['nurse_vet']; $hotbox = $row['hot_job']; $position=18; $job_description2 = substr($job_description, 0, $position); ?> <tr><td><strong><?php echo $id; ?></strong></td><td><strong><?php echo $job_title; ?></strong></td><td><strong><?php echo $job_description2; ?>...</strong></td><td><strong><?php echo $job_type; ?></strong></td><td><strong><?php echo $job_area; ?></strong></td><td><strong><?php echo $nurse_vet; ?></strong></td><td><a href='add_jobs.php?action=edit&editid=<?php echo $id; ?>'>Edit</a></td><td><a href='add_jobs.php?action=delete&delid=<?php echo $id; ?>'>Delete</a></td><td><input name="ONOFF[]" type="checkbox" value="<?php echo $row['id']; ?>" <?php if($row['hot_job'] == 'YES') { echo "checked='checked' "; } ?>/></td></tr> <?php } ?></p><input type='Submit' value='Update'></form></table> </div> <?php }else{echo'Stop hacking';}} ?> < Also you see how the Title wont display the whole title due to the " ' " How do i prevent this? This is how the page renders
  4. Username: test Password: test it'd be eaiser if people registered though so they game was functional
  5. Hey guys, I've tried my hardest to create an online game, give it a whirl. i'll unpause when we get to 20 players. There's a help page to get you started. Post here with any bugs or comments! http://www.delusionalkev.com/sn/ Thankyou http://www.delusionalkev.com/sn/text.txt
  6. Thankyou Psycho and requinix I've used your tips and corrected everything, cheers
  7. Hiya i'm working on a project, which involves a list of checkboxes which are automaticly populated by the database which is currently working at while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $hotbox = $row['hot_job']; ?> <form name='hotbox' action='hot_update.php' method='POST'> <tr><td><strong><?php echo $id; ?></strong></td> <td><input name="ONOFF<? echo $row['id']; ?>" type="checkbox" id="ONOFF" value="1" <?php if ($row['hot_job'] == 'YES') { echo "checked";} else {} ?> </td></tr> <?php } ?> however when the user has unchecked/checked the correct boxes and clickes update, nothing changes. Here is my current code foreach($_POST['id'] as $id) { $onoff = 0; if (isset($_POST["ONOFF".$id])) { $onoff = 1; } if($onoff == 1) { $sql1="UPDATE jobs SET hot_job='".$onoff."' WHERE id='".$id."'"; } else { $sql1="UPDATE jobs SET hot_job='".$onoff."' WHERE id='".$id."'"; } echo $id; echo $onoff; $result1=mysql_query($sql1); } ?> The mysql setup is id hot_job 1 YES 2 YES 3 NO 4 YES ect Any help would be greatly appreciated
  8. resolved by using <!--[if IE]> <script> document.createElement('header'); document.createElement('nav'); document.createElement('section'); document.createElement('article'); document.createElement('aside'); document.createElement('footer'); document.createElement('hgroup'); </script> <![endif]-->
  9. I've already tried this and matched up the website to the clean markup, yet this makes the website broken in all browsers? Edit: i just rechecked using the correct markup and 'This document was successfully checked as HTML5!'
  10. Hey everyone, i'm helping create a website for a friend over at http://www.kevin-cornish.com/jerrihart/history.html if you check it out you can see that the page loads perfectly on every browser however, looks horrible in IE8. Any suggestions?
  11. Hey guys i have a problem, I have a form to upload 2 image files however sometimes i want to only upload the one file, but if i only upload one image, it tells me that it can't upload because there is no name for the second image. I tried fixing it with if (isset($fieldname2)) however i just realised that $feildname2 is always set so im not quite sure how to fix? ($action == "add"){ $add = $_POST['add']; $reference = $_POST['reference']; $category = $_POST['category']; $sub_cat = $_POST['sub_cat']; $fieldname = 'file'; $fieldname2 = 'file2'; error_reporting(E_ALL); ini_set('display_errors',1); is_uploaded_file($_FILES[$fieldname]['tmp_name']); getimagesize($_FILES[$fieldname]['tmp_name']); if (isset($fieldname2)) { is_uploaded_file($_FILES[$fieldname2]['tmp_name']); getimagesize($_FILES[$fieldname2]['tmp_name']); } $now = time(); while(file_exists($uploadFilename = $uploadsDirectory.$_FILES[$fieldname]['name'])) { $now++; } if (isset($fieldname2)) { while(file_exists($uploadFilename2 = $uploadsDirectory.$_FILES[$fieldname2]['name'])) { $now++; } } move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename); if (isset($fieldname2)) { move_uploaded_file($_FILES[$fieldname2]['tmp_name'], $uploadFilename2); } $sqlname = $_FILES[$fieldname]['name']; if (isset($fieldname2)) { $sqlname2 = $_FILES[$fieldname2]['name']; } $id = mysql_insert_id(); $query = "INSERT INTO cakes (id, reference, category, sub_cat, image, image2) VALUES ('$id', '$reference', '$category', '$sub_cat','$sqlname','$sqlname2')"; $sql = mysql_query($query) or die (mysql_error()); } echo("<form name='add' method='post' enctype='multipart/form-data' action='?action=add'>"); echo("<input type='hidden' name='MAX_FILE_SIZE' value='3000000"); echo("<input type='hidden' name='?action=add'>"); echo("<table class=main cellspacing=0 cellpadding=2 width=60%>"); echo("<tr><td>Reference: </td><td align='right'><input type='text' size=50 name='reference' value='$reference'></td></tr>"); echo("<tr><td>Category: </td><td align='center'><select name='category'><option>Occasional</option><option>Special</option><option>Figures</option><option>Novelty</option><option>Wedding</option></SELECT></td></tr>"); echo("<tr><td>Sub Category: </td><td align='center'><select name='sub_cat'><option></option><option>Birthday</option><option>Anniversary</option><option>Christmas</option><option>Christening</option><option>Valentine</option><option>Mothers Day</option><option>Fathers Day</option><option>Easter</option></select></td></tr>"); echo("<tr><td>Cake Image: </td><td align='center'><input id='file' type='file' name='file'></td></tr>"); echo("<tr><td>Cake Image 2: </td><td align='center'><input id='file2' type='file' name='file2'></td></tr>"); echo("Before uploading an image please resize the image to 290px x 218px"); echo("<tr><td></td><td><div align='right'><input type='Submit'></div></td></tr>"); echo("</table>");
  12. Hello all, im creating a website for a client and have ran into a brick wall. I'm using javascript to magnify images, like this $html .= '<p><img src="../../../images/cakes/'.$image.'" class="magnify" style="clear: both;" height="289px" width="177px" alt="NO IMAGE UPLOADED"></img><br />'; Which is working fine, however i have added a button below saying 'View another image' which on click i want to display the other image, however it is enlarging the 'View another image' button instead of the actual picture, this is the code. $html .= '<img class="magnify" src="../../../images/view-another.gif"><img src="../../../images/cakes/'.$image.'"></img></img></p>';
  13. aha with some slight changes thats got it thankyou very much, with the cols though depending on how many it needs, should i use a count first and then use the result as the var?
  14. I've tried taking the <P> tags out, and this was the result
  15. That br is for the text, not for the next image
  16. Hello, i created this script for a client and have ran into an annoying error with the results displaying on a new line for each result instead of side by side, any help is welcome Cheers <?php $subcat = mysql_real_escape_string(strip_tags(htmlspecialchars(protect($_GET['subcat'])))); $cat = mysql_real_escape_string(strip_tags(htmlspecialchars(protect($_GET['cat'])))); $sql = @mysql_query("SELECT * FROM cakes WHERE category =\"$cat\" AND sub_cat=\"$subcat\" ORDER BY id DESC"); while ($row = mysql_fetch_array($sql)) { $reference = $row['reference']; $image = $row['image']; echo ("<p><img src='./images/cakes/$image' height='289px' width='177px' alt='IMAGE OF CAKE'></img><br />"); echo ("<b>Reference:</b>$reference"."</p>"); } if (!$reference) { echo 'There are no cakes in this category yet.'; } ?> I know the errors only going to be something small i'm missing, but i've been coding all day
  17. Anybody know of any commerce scripts i can use to setup an online cake selling shop? Thankyou in advanced
  18. Right got it working! Cheers everyone function unread($user) { $sql_pm_r = mysql_query("SELECT id, COUNT(*) as unread FROM messages WHERE reciever='" . $user . "' AND recieved='0' GROUP BY reciever") or die(mysql_error()); $rows = mysql_fetch_assoc($sql_pm_r); if ($rows['unread'] > 0) { $pms = '<a href="inbox.php" >('.$rows['unread'].')</a>'; } else { $pms = '<a href="inbox.php" >(0)</a>'; } echo $pms; }
  19. Thorpe how do you mean? and using that function didn't do anything. at the moment i have this echo'ing (1)Resource id #11USERNAME with function unread() { global $user; $sql_pm_r = mysql_query("SELECT COUNT(*) FROM messages WHERE reciever='". $user ."' AND recieved='0'") or die(mysql_error()); $num_rows = mysql_num_rows($sql_pm_r); $sql_pm_check = mysql_query("SELECT id FROM messages WHERE reciever='" . $user . "' AND recieved='0' LIMIT 1") or die(mysql_error()); $num_new_pm = mysql_num_rows($sql_pm_check); if ($num_new_pm > 0) { $pms = '<a href="inbox.php" >('.$num_rows.')</a>'; } else { $pms = '<a href="inbox.php" >(0)</a>'; } echo $pms; echo $sql_pm_r; echo $user; }
  20. Right just fixed a slight issue, $user was empty. Working now function unread() { global $user; mysql_query("SELECT COUNT(*) FROM messages WHERE reciever=" . $user . " AND recieved='0'") or die(mysql_error()); $num_rows = mysql_num_rows($sql_pm_r); $sql_pm_check = mysql_query("SELECT id FROM messages WHERE reciever=" . $user . " AND recieved='0' LIMIT 1"); $num_new_pm = mysql_num_rows($sql_pm_check); if ($num_new_pm > 0) { $pms = '<a href="inbox.php" >('.$num_rows.')</a>'; } else { $pms = '<a href="inbox.php" >(0)</a>'; } echo $pms; echo $sql_pm_r; echo $user; } However i get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USERNAME AND recieved='0'' at line 1 Which i fixed by changing ". $user ." to '". $user ."' Now it's echo'ing (0)USERNAME Which means $sql_pm_r is empty right?
  21. Hey, im trying to create a little function that displays how many unread messages a user has this is my function function unread() { $sql_pm_r = mysql_query("SELECT COUNT(*) FROM messages WHERE reciever=" . $user . " AND recieved='0'"); $num_rows = mysql_num_rows($sql_pm_r); $sql_pm_check = mysql_query("SELECT id FROM messages WHERE reciever=" . $user . " AND recieved='0' LIMIT 1"); $num_new_pm = mysql_num_rows($sql_pm_check); if ($num_new_pm > 0) { $pms = '<a href="inbox.php" >('.$num_rows.')</a>'; } else { $pms = '<a href="inbox.php" >(0)</a>'; } echo $pms; } and i'm calling it on the index page as normal like unread(); However not matter how many unread messages i have, i always get (0), this is how my sql table looks id reciever sender subject message recieved
  22. Thankyou! that second query was the one which was causing the extra query on each status, so now i'm constantly loading lesser queries. Cheers for that! if anybody wants to see the faster code it's, $sql = sqlcount(mysql_query("SELECT s.statusid, s.status, s.time_posted, s.userid, u.username, u.avatar_url FROM statuses AS s LEFT JOIN users AS u ON s.userid = u.id ORDER BY s.statusid DESC")); while ($row = mysql_fetch_assoc($sql)) { $status_id = htmlspecialchars($row['statusid']); $status = htmlspecialchars($row['status']); $time_posted = htmlspecialchars($row['time_posted']); $status_userid = htmlspecialchars($row['userid']); $usernamestatus = $row['username']; $avatar_url = $row['avatar_url']; if (empty($avatar_url)) { $avatar = "<img src='$directory_self/images/default_avatar.gif' height='50px' width='50px' />"; }else{ $avatar = "<img src='$directory_self/photos/$usernamestatus/$avatar_url' height='50px' width='50px' />"; } echo '<div id="content">'; echo "<br />"; echo $avatar; echo "<a href=\"profile.php?id=$status_userid\">". $usernamestatus ."</a>"; echo "<br />"; $status = str_replace(array_keys($bbcode), array_values($bbcode), $status); echo $status; if($userid == $status_userid){ echo " <span class=x><a href=delete_status.php?id=$status_id>x</a></span>"; } echo "<br />"; echo format_date($time_posted); echo "<br />"; echo "<br />"; ?> <div id="like<?php echo"$status_id"; ?>"><a href="#" style="text-decoration: none" class="like" id="<?php echo"$status_id"; ?>"><span class="like_b"> <?php echo LANG_LIKE; ?> </span></a></div> <div id="unlike<?php echo"$status_id"; ?>" style="display:none"><span class="youlike_b"> <?php echo"$user"; echo LANG_LIKES_THIS; ?> </span><a href="#" class="unlike" id="<?php echo"$status_id"; ?>"><span class="unlike_b"> <?php echo LANG_UNLIKE; ?> </span></a></div> <?php echo "</div>"; } ?>
  23. hey guys, in my script i displays status' the users have posted. However when the users status' got over like 20, i noticed it was affected load times greatly as lots of SQL is looping. <?php $sql = sqlcount(mysql_query("SELECT * FROM statuses LEFT JOIN users ON statuses.userid = users.id ORDER BY statusid DESC")); while ($row = mysql_fetch_assoc($sql)) { $status_id = htmlspecialchars($row['statusid']); $status = htmlspecialchars($row['status']); $time_posted = htmlspecialchars($row['time_posted']); $status_userid = htmlspecialchars($row['userid']); $sql2 = sqlcount(mysql_query("SELECT username,avatar_url FROM users WHERE id=$status_userid LIMIT 1")); while ($row2=mysql_fetch_array($sql2)){ $usernamestatus = $row2['username']; $avatar_url = $row2['avatar_url']; if (empty($avatar_url)) { $avatar = "<img src='$directory_self/images/default_avatar.gif' height='50px' width='50px' />"; }else{ $avatar = "<img src='$directory_self/photos/$usernamestatus/$avatar_url' height='50px' width='50px' />"; } echo '<div id="content">'; echo "<br />"; echo $avatar; echo "<a href=\"profile.php?id=$status_userid\">". $usernamestatus ."</a>"; echo "<br />"; $status = str_replace(array_keys($bbcode), array_values($bbcode), $status); echo $status; if($userid == $status_userid){ echo " <span class=x><a href=delete_status.php?id=$status_id>x</a></span>"; } echo "<br />"; echo format_date($time_posted); echo "<br />"; echo "<br />"; ?> <div id="like<?php echo"$status_id"; ?>"><a href="#" style="text-decoration: none" class="like" id="<?php echo"$status_id"; ?>"><span class="like_b"> <?php echo LANG_LIKE; ?> </span></a></div> <div id="unlike<?php echo"$status_id"; ?>" style="display:none"><span class="youlike_b"> <?php echo"$user"; echo LANG_LIKES_THIS; ?> </span><a href="#" class="unlike" id="<?php echo"$status_id"; ?>"><span class="unlike_b"> <?php echo LANG_UNLIKE; ?> </span></a></div> <?php echo "</div>"; } } ?> Is there a way to shorten this code and make it run faster, without as many queries? Cheers
  24. I can't honestly see whats wrong with this code, it's print'ing correct with the print_r. Array ( [value1] => 2 [option] => - [value2] => 1 ) however i can't actually echo out the value1,value2 or option? It says the vars are empty yet it can still print_r the values so i know there not empty <?php if(isset($_POST["submit"])){ $value1=$_POST["value1"]; $value2=$_POST["value2"]; $option=$_POST["option"]; } print_r($_POST); echo"$value1"; ?> <form action="index.php" name="submit" method="post"> <input type="text" name="value1"> <select name="option"> <option>+</option> <option>-</option> <option>*</option> <option>/</option> </select> <input type="text" name="value2"> <input type="submit" value="submit"> </form>
×
×
  • 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.